diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-08-15 14:21:37 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-15 17:46:19 +0200 |
commit | 8ca3cdb569789ab360336a8e498b815fa0097f94 (patch) | |
tree | fe4739928c87fa59dd69b532f722e431c205953a | |
parent | 46d57d47e81c8794a9a3594e080576788cc92324 (diff) | |
download | scala-8ca3cdb569789ab360336a8e498b815fa0097f94.tar.gz scala-8ca3cdb569789ab360336a8e498b815fa0097f94.tar.bz2 scala-8ca3cdb569789ab360336a8e498b815fa0097f94.zip |
materializeImplicit and implicitsOfExpectedType
Previously these guys were coupled in a single method. Now they are separated.
In my opinion that helps understanding the stuff going on in implicit search.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 924d590edb..a34fc71b8f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1337,13 +1337,7 @@ trait Implicits { /** Materializes implicits of magic types (currently, manifests and tags). * Will be replaced by implicit macros once we fix them. */ - private def materializeImplicit(pt: Type): SearchResult = { - def fallback = { - searchImplicit(implicitsOfExpectedType, false) - // shouldn't we pass `pt` to `implicitsOfExpectedType`, or is the recursive case - // for an abstract type really only meant for tags? - } - + private def materializeImplicit(pt: Type): SearchResult = pt match { case TypeRef(_, sym, _) if sym.isAbstractType => materializeImplicit(pt.dealias.bounds.lo) // #3977: use pt.dealias, not pt (if pt is a type alias, pt.bounds.lo == pt) @@ -1359,12 +1353,11 @@ trait Implicits { // unlike `dealias`, `betaReduce` performs at most one step of dealiasing // while dealias pops all aliases in a single invocation case sym if sym.isAliasType => materializeImplicit(pt.betaReduce) - case _ => fallback + case _ => SearchFailure } case _ => - fallback + SearchFailure } - } /** The result of the implicit search: * First search implicits visible in current context. @@ -1397,6 +1390,10 @@ trait Implicits { result = materializeImplicit(pt) + // `materializeImplicit` does some preprocessing for `pt` + // is it only meant for manifests/tags or we need to do the same for `implicitsOfExpectedType`? + if (result == SearchFailure) result = searchImplicit(implicitsOfExpectedType, false) + if (result == SearchFailure) { context.updateBuffer(previousErrs) Statistics.stopTimer(oftypeFailNanos, failstart) |