diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2009-11-24 09:09:49 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2009-11-24 09:09:49 +0000 |
commit | c46145f0408b30bbd126d293ccf67792f307479a (patch) | |
tree | c36f529ae8272b368f1efb20dce6758a8d4e8a0b /src/compiler | |
parent | ef3fb07b53cf4468332461c9d5cf523019bcd9c9 (diff) | |
download | scala-c46145f0408b30bbd126d293ccf67792f307479a.tar.gz scala-c46145f0408b30bbd126d293ccf67792f307479a.tar.bz2 scala-c46145f0408b30bbd126d293ccf67792f307479a.zip |
close #2665 and close #2667: use weak conforman...
close #2665 and close #2667: use weak conformance in polymorphic case of
isApplicable reviewed by: odersky
exprTypeArgs now takes a comparison function: isWeaklyCompatible is )
passed in isApplicable's typesCompatible (to mimic what happens in the )
monomorphic case Martin: please review as this is different from my )
original proposal (that one broke type inference, this one passes all )
tests and does not slow down quick.comp )
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 712d469662..d11f263677 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -496,9 +496,9 @@ trait Infer { * @param pt ... * @return ... */ - private def exprTypeArgs(tparams: List[Symbol], restpe: Type, pt: Type): List[Type] = { + private def exprTypeArgs(tparams: List[Symbol], restpe: Type, pt: Type, checkCompat: (Type, Type) => Boolean = isCompatible): List[Type] = { val tvars = tparams map freshVar - if (isCompatible(restpe.instantiateTypeParams(tparams, tvars), pt)) { + if (checkCompat(restpe.instantiateTypeParams(tparams, tvars), pt)) { try { // 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. @@ -788,7 +788,8 @@ trait Infer { try { val uninstantiated = new ListBuffer[Symbol] val targs = methTypeArgs(undetparams, formals, restpe, argtpes, pt, uninstantiated) - (exprTypeArgs(uninstantiated.toList, restpe.instantiateTypeParams(undetparams, targs), pt) ne null) && + // #2665: must use weak conformance, not regular one (follow the monorphic case above) + (exprTypeArgs(uninstantiated.toList, restpe.instantiateTypeParams(undetparams, targs), pt, isWeaklyCompatible) ne null) && isWithinBounds(NoPrefix, NoSymbol, undetparams, targs) } catch { case ex: NoInstance => false diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 1a8db1f27d..c3ca5d7e30 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2148,6 +2148,10 @@ trait Typers { self: Analyzer => val pre = fun.symbol.tpe.prefix var sym = fun.symbol filter { alt => + // must use pt as expected type, not WildcardType (a tempting quick fix to #2665) + // now fixed by using isWeaklyCompatible in exprTypeArgs + // TODO: understand why exactly -- some types were not inferred anymore (`ant clean quick.bin` failed) + // (I had expected inferMethodAlternative to pick up the slack introduced by using WildcardType here) isApplicableSafe(context.undetparams, followApply(pre.memberType(alt)), argtypes, pt) } if (sym hasFlag OVERLOADED) { |