@@ -1125,6 +1125,7 @@ class Typer extends Namer
1125
1125
newTypeVar(apply(bounds.orElse(TypeBounds .empty)).bounds)
1126
1126
case _ => mapOver(t)
1127
1127
}
1128
+
1128
1129
val pt1 = pt.stripTypeVar.dealias
1129
1130
if (pt1 ne pt1.dropDependentRefinement)
1130
1131
&& defn.isContextFunctionType(pt1.nonPrivateMember(nme.apply).info.finalResultType)
@@ -1133,22 +1134,25 @@ class Typer extends Namer
1133
1134
i """ Implementation restriction: Expected result type $pt1
1134
1135
|is a curried dependent context function type. Such types are not yet supported. """ ,
1135
1136
tree.srcPos)
1137
+
1136
1138
pt1 match {
1137
- case pt1 if defn.isNonRefinedFunction(pt1) =>
1138
- // if expected parameter type(s) are wildcards, approximate from below.
1139
- // if expected result type is a wildcard, approximate from above.
1140
- // this can type the greatest set of admissible closures.
1141
- (pt1.argTypesLo.init, typeTree(interpolateWildcards(pt1.argTypesHi.last)))
1142
- case SAMType (sam @ MethodTpe (_, formals, restpe)) =>
1143
- (formals,
1144
- if (sam.isResultDependent)
1145
- untpd.DependentTypeTree (syms => restpe.substParams(sam, syms.map(_.termRef)))
1146
- else
1147
- typeTree(restpe))
1148
1139
case tp : TypeParamRef =>
1149
1140
decomposeProtoFunction(ctx.typerState.constraint.entry(tp).bounds.hi, defaultArity, tree)
1150
- case _ =>
1151
- (List .tabulate(defaultArity)(alwaysWildcardType), untpd.TypeTree ())
1141
+ case _ => pt1.findFunctionTypeInUnion match {
1142
+ case pt1 if defn.isNonRefinedFunction(pt1) =>
1143
+ // if expected parameter type(s) are wildcards, approximate from below.
1144
+ // if expected result type is a wildcard, approximate from above.
1145
+ // this can type the greatest set of admissible closures.
1146
+ (pt1.argTypesLo.init, typeTree(interpolateWildcards(pt1.argTypesHi.last)))
1147
+ case SAMType (sam @ MethodTpe (_, formals, restpe)) =>
1148
+ (formals,
1149
+ if sam.isResultDependent then
1150
+ untpd.DependentTypeTree (syms => restpe.substParams(sam, syms.map(_.termRef)))
1151
+ else
1152
+ typeTree(restpe))
1153
+ case _ =>
1154
+ (List .tabulate(defaultArity)(alwaysWildcardType), untpd.TypeTree ())
1155
+ }
1152
1156
}
1153
1157
}
1154
1158
@@ -1399,7 +1403,7 @@ class Typer extends Namer
1399
1403
if (tree.tpt.isEmpty)
1400
1404
meth1.tpe.widen match {
1401
1405
case mt : MethodType =>
1402
- pt.stripNull match {
1406
+ pt.findFunctionTypeInUnion match {
1403
1407
case pt @ SAMType (sam)
1404
1408
if ! defn.isFunctionType(pt) && mt <:< sam =>
1405
1409
// SAMs of the form C[?] where C is a class cannot be conversion targets.
0 commit comments