Implicit is incorrectly expanded (Highlight Implicit)
object using {
private trait Closeable {
def close(): Unit
}
private object Closeable {
implicit def asCloseable[R <: { def close() }](r: R): Closeable = new Closeable {
def close() { r.close() }
}
}
def apply[R <% Closeable, T](resource: R)(op: R => T): T = {
try {
op(resource)
} finally {
if (resource != null) resource.close() // <-- try CMD+1 (quick fix) and expand the implicit
}
}
}
CMD+1 (quick fix) on resource and then `expand implicit` results in apply(resource).close(), which is clearly wrong. It should expand to asCloseable(resource).close().
Leave a comment
on 2012-06-05 20:14 *
By Mirco Dotta
Summary changed from Highlight implicit resolved to wrong implicit declaration to Implicit is incorrectly expanded (Highlight Implicit)