summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2017-02-21 15:10:25 +0100
committerGitHub <noreply@github.com>2017-02-21 15:10:25 +0100
commit76bfb9e0e5f38ce264f2a03490731f5865fa468f (patch)
treea3a324424ea62cae2ff2f1f7c804b58446acffe0 /src/compiler/scala
parentdabec1a262fafd26bf6976ac3f0b81445ddb5f29 (diff)
parent1d22ee4ba3032941cdc45677a7ce6082fd317580 (diff)
downloadscala-76bfb9e0e5f38ce264f2a03490731f5865fa468f.tar.gz
scala-76bfb9e0e5f38ce264f2a03490731f5865fa468f.tar.bz2
scala-76bfb9e0e5f38ce264f2a03490731f5865fa468f.zip
Merge pull request #5708 from szeiger/issue/si10194
SI-10194: Fix abstract type resolution for overloaded HOFs
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 837ccf7e06..65d1910364 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3333,15 +3333,15 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
def handleOverloaded = {
val undetparams = context.undetparams
- def funArgTypes(tps: List[Type]) = tps.map { tp =>
- val relTp = tp.asSeenFrom(pre, fun.symbol.owner)
+ def funArgTypes(tpAlts: List[(Type, Symbol)]) = tpAlts.map { case (tp, alt) =>
+ val relTp = tp.asSeenFrom(pre, alt.owner)
val argTps = functionOrSamArgTypes(relTp)
//println(s"funArgTypes $argTps from $relTp")
argTps.map(approximateAbstracts)
}
- def functionProto(argTps: List[Type]): Type =
- try functionType(funArgTypes(argTps).transpose.map(lub), WildcardType)
+ def functionProto(argTpWithAlt: List[(Type, Symbol)]): Type =
+ try functionType(funArgTypes(argTpWithAlt).transpose.map(lub), WildcardType)
catch { case _: IllegalArgumentException => WildcardType }
// To propagate as much information as possible to typedFunction, which uses the expected type to
@@ -3355,21 +3355,21 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// do not receive special treatment: they are typed under WildcardType.)
val altArgPts =
if (settings.isScala212 && args.exists(treeInfo.isFunctionMissingParamType))
- try alts.map(alt => formalTypes(alt.info.paramTypes, argslen)).transpose // do least amount of work up front
+ try alts.map(alt => formalTypes(alt.info.paramTypes, argslen).map(ft => (ft, alt))).transpose // do least amount of work up front
catch { case _: IllegalArgumentException => args.map(_ => Nil) } // fail safe in case formalTypes fails to align to argslen
else args.map(_ => Nil) // will type under argPt == WildcardType
val (args1, argTpes) = context.savingUndeterminedTypeParams() {
val amode = forArgMode(fun, mode)
- map2(args, altArgPts) { (arg, argPts) =>
+ map2(args, altArgPts) { (arg, argPtAlts) =>
def typedArg0(tree: Tree) = {
// if we have an overloaded HOF such as `(f: Int => Int)Int <and> (f: Char => Char)Char`,
// and we're typing a function like `x => x` for the argument, try to collapse
// the overloaded type into a single function type from which `typedFunction`
// can derive the argument type for `x` in the function literal above
val argPt =
- if (argPts.nonEmpty && treeInfo.isFunctionMissingParamType(tree)) functionProto(argPts)
+ if (argPtAlts.nonEmpty && treeInfo.isFunctionMissingParamType(tree)) functionProto(argPtAlts)
else WildcardType
val argTyped = typedArg(tree, amode, BYVALmode, argPt)