diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 25 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 3 |
3 files changed, 22 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index ed0f73f0ad..195219b9a3 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -4029,7 +4029,7 @@ A type's typeSymbol should never be inspected directly. /** First try, on the right: * - unwrap Annotated types, BoundedWildcardTypes, - * - bind TypeVars on the right, if lhs is not Annotated nor BoundedWildcard + * - bind TypeVars on the right, if lhs is not Annotated nor BoundedWildcard * - handle common cases for first-kind TypeRefs on both sides as a fast path. */ def firstTry = tp2 match { @@ -4479,9 +4479,9 @@ A type's typeSymbol should never be inspected directly. (DoubleClass.tpe /: ts) ((t1, t2) => if (isNumericSubType(t1, t2)) t1 else t2) def isWeakSubType(tp1: Type, tp2: Type) = - tp1 match { + tp1.deconst.normalize match { case TypeRef(_, sym1, _) if isNumericValueClass(sym1) => - tp2 match { + tp2.deconst.normalize match { case TypeRef(_, sym2, _) if isNumericValueClass(sym2) => sym1 == sym2 || numericWidth(sym1) < numericWidth(sym2) case tv2 @ TypeVar(_, _) => @@ -4490,7 +4490,7 @@ A type's typeSymbol should never be inspected directly. isSubType(tp1, tp2) } case tv1 @ TypeVar(_, _) => - tp2 match { + tp2.deconst.normalize match { case TypeRef(_, sym2, _) if isNumericValueClass(sym2) => tv1.registerBound(tp2, isLowerBound = false, numBound = true) case _ => diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 6bbacfa311..ed5b64138f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -368,21 +368,28 @@ self: Analyzer => * correspond to the HasMethodMatching type, * or otherwise if `tp' is compatible with `pt'. */ - def matchesPt(tp: Type, pt: Type, undet: List[Symbol]) = - isCompatible(tp, pt) || { + def matchesPt(tp: Type, pt: Type, undet: List[Symbol]) = { + isCompatible(tp, pt) || + isView && { pt match { - case Function1(arg, HasMethodMatching(name, argtpes, restpe)) => + case Function1(arg, res) => normalize(tp) match { case Function1(arg1, res1) => - (arg <:< arg1) && - (res1.member(name) filter (m => isApplicableSafe(undet, m.tpe, argtpes, restpe))) != NoSymbol - case _ => - false + (arg.deconst weak_<:< arg1) && { + res match { + case HasMethodMatching(name, argtpes, restpe) => + (res1.member(name) filter (m => + isApplicableSafe(undet, m.tpe, argtpes, restpe))) != NoSymbol + case _ => + res1 <:< res + } + } + case _ => false } - case _ => - false + case _ => false } } + } //if (traceImplicits) println("typed impl for "+wildPt+"? "+info.name+":"+depoly(info.tpe)+"/"+undetParams+"/"+isPlausiblyCompatible(info.tpe, wildPt)+"/"+matchesPt(depoly(info.tpe), wildPt, List())) if (isPlausiblyCompatible(info.tpe, wildPt) && diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 3b2f917a05..712d469662 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -418,7 +418,8 @@ trait Infer { case TypeRef(_, sym1, _) => !sym1.isClass || { tp2.normalize match { - case TypeRef(_, sym2, _) => !sym2.isClass || (sym1 isSubClass sym2) + case TypeRef(_, sym2, _) => + !sym2.isClass || (sym1 isSubClass sym2) || isNumericSubType(tp1, tp2) case _ => true } } |