diff options
author | Martin Odersky <odersky@gmail.com> | 2008-08-25 18:02:12 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-08-25 18:02:12 +0000 |
commit | 73021214bcdec9e99551e36d33d5d6ed8d39a8f0 (patch) | |
tree | 6a6ea6619964e2f518c05f5ddb4bc198c9951e00 | |
parent | cd6ed4e12b272750bc7bf6f41e9d1bfe5f0cfc8a (diff) | |
download | scala-73021214bcdec9e99551e36d33d5d6ed8d39a8f0.tar.gz scala-73021214bcdec9e99551e36d33d5d6ed8d39a8f0.tar.bz2 scala-73021214bcdec9e99551e36d33d5d6ed8d39a8f0.zip |
Fixed problem with implicits in type safe cons ...
Fixed problem with implicits in type safe cons example.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 567ff3479e..16e99a2d99 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -459,7 +459,16 @@ trait Infer { val tvars = tparams map freshVar if (isCompatible(restpe.instantiateTypeParams(tparams, tvars), pt)) { try { - solvedTypes(tvars, tparams, tparams map varianceInType(restpe), + // If the restpe is an implicit method, and the expected type is fully defined + // optimze type varianbles wrt to the implicit formals only; ignore the result type. + // See test pos/jesper.scala + val varianceType = restpe match { + case mt: ImplicitMethodType if isFullyDefined(pt) => + MethodType(mt.paramTypes, AnyClass.tpe) + case _ => + restpe + } + solvedTypes(tvars, tparams, tparams map varianceInType(varianceType), false, lubDepth(List(restpe, pt))) } catch { case ex: NoInstance => null @@ -922,10 +931,12 @@ trait Infer { */ def inferExprInstance(tree: Tree, undetparams: List[Symbol], pt: Type) { if (inferInfo) - println("infer expr instance "+tree+"\n"+ + println("infer expr instance "+tree+":"+tree.tpe+"\n"+ " undetparams = "+undetparams+"\n"+ " pt = "+pt) substExpr(tree, undetparams, exprTypeArgs(undetparams, tree.tpe, pt), pt) + if (inferInfo) + println("inferred expr instance "+tree) } /** Substitite free type variables `undetparams' of polymorphic argument |