File tree 2 files changed +17
-3
lines changed
src/dotty/tools/dotc/typer 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -1460,12 +1460,16 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1460
1460
}
1461
1461
case wtp : MethodType if ! pt.isInstanceOf [SingletonType ] =>
1462
1462
val arity =
1463
- if (defn.isFunctionType(pt)) defn.functionArity(pt)
1463
+ if (defn.isFunctionType(pt))
1464
+ if (! isFullyDefined(pt, ForceDegree .none) && isFullyDefined(wtp, ForceDegree .none))
1465
+ // prioritize method parameter types over expected types as parameter types of the eta-expanded closure
1466
+ 0
1467
+ else defn.functionArity(pt)
1464
1468
else if (pt eq AnyFunctionProto ) wtp.paramTypes.length
1465
1469
else - 1
1466
- if (arity >= 0 && ! tree.symbol.isConstructor)
1470
+ if (arity >= 0 && ! tree.symbol.isConstructor) {
1467
1471
typed(etaExpand(tree, wtp, arity), pt)
1468
- else if (wtp.paramTypes.isEmpty)
1472
+ } else if (wtp.paramTypes.isEmpty)
1469
1473
adaptInterpolated(tpd.Apply (tree, Nil ), pt, EmptyTree )
1470
1474
else if (wtp.isImplicit)
1471
1475
err.typeMismatch(tree, pt)
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ def second [sA, sB <: sA](foo : sA, bar : sB): sB = bar
3
+ def expectString (s : String ) = s
4
+
5
+ def test = {
6
+ val x = second(Set .empty[String ], Set .empty)
7
+ x map expectString
8
+ second(Set .empty[String ], Set .empty) map expectString
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments