@@ -3333,15 +3333,15 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3333
3333
def handleOverloaded = {
3334
3334
val undetparams = context.undetparams
3335
3335
3336
- def funArgTypes (tps : List [Type ]) = tps .map { tp =>
3337
- val relTp = tp.asSeenFrom(pre, fun.symbol .owner)
3336
+ def funArgTypes (tpAlts : List [( Type , Symbol ) ]) = tpAlts .map { case (tp, alt) =>
3337
+ val relTp = tp.asSeenFrom(pre, alt .owner)
3338
3338
val argTps = functionOrSamArgTypes(relTp)
3339
3339
// println(s"funArgTypes $argTps from $relTp")
3340
3340
argTps.map(approximateAbstracts)
3341
3341
}
3342
3342
3343
- def functionProto (argTps : List [Type ]): Type =
3344
- try functionType(funArgTypes(argTps ).transpose.map(lub), WildcardType )
3343
+ def functionProto (argTpWithAlt : List [( Type , Symbol ) ]): Type =
3344
+ try functionType(funArgTypes(argTpWithAlt ).transpose.map(lub), WildcardType )
3345
3345
catch { case _ : IllegalArgumentException => WildcardType }
3346
3346
3347
3347
// 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
3355
3355
// do not receive special treatment: they are typed under WildcardType.)
3356
3356
val altArgPts =
3357
3357
if (settings.isScala212 && args.exists(treeInfo.isFunctionMissingParamType))
3358
- try alts.map(alt => formalTypes(alt.info.paramTypes, argslen)).transpose // do least amount of work up front
3358
+ try alts.map(alt => formalTypes(alt.info.paramTypes, argslen).map(ft => (ft, alt)) ).transpose // do least amount of work up front
3359
3359
catch { case _ : IllegalArgumentException => args.map(_ => Nil ) } // fail safe in case formalTypes fails to align to argslen
3360
3360
else args.map(_ => Nil ) // will type under argPt == WildcardType
3361
3361
3362
3362
val (args1, argTpes) = context.savingUndeterminedTypeParams() {
3363
3363
val amode = forArgMode(fun, mode)
3364
3364
3365
- map2(args, altArgPts) { (arg, argPts ) =>
3365
+ map2(args, altArgPts) { (arg, argPtAlts ) =>
3366
3366
def typedArg0 (tree : Tree ) = {
3367
3367
// if we have an overloaded HOF such as `(f: Int => Int)Int <and> (f: Char => Char)Char`,
3368
3368
// and we're typing a function like `x => x` for the argument, try to collapse
3369
3369
// the overloaded type into a single function type from which `typedFunction`
3370
3370
// can derive the argument type for `x` in the function literal above
3371
3371
val argPt =
3372
- if (argPts .nonEmpty && treeInfo.isFunctionMissingParamType(tree)) functionProto(argPts )
3372
+ if (argPtAlts .nonEmpty && treeInfo.isFunctionMissingParamType(tree)) functionProto(argPtAlts )
3373
3373
else WildcardType
3374
3374
3375
3375
val argTyped = typedArg(tree, amode, BYVALmode , argPt)
0 commit comments