summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-08-25 18:02:12 +0000
committerMartin Odersky <odersky@gmail.com>2008-08-25 18:02:12 +0000
commit73021214bcdec9e99551e36d33d5d6ed8d39a8f0 (patch)
tree6a6ea6619964e2f518c05f5ddb4bc198c9951e00 /src
parentcd6ed4e12b272750bc7bf6f41e9d1bfe5f0cfc8a (diff)
downloadscala-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.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala15
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