File tree 2 files changed +20
-7
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -2010,8 +2010,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
2010
2010
// prioritize method parameter types as parameter types of the eta-expanded closure
2011
2011
0
2012
2012
else defn.functionArity(ptNorm)
2013
- else if (pt eq AnyFunctionProto ) wtp.paramInfos.length
2014
- else - 1
2013
+ else {
2014
+ val nparams = wtp.paramInfos.length
2015
+ if (nparams > 0 || pt.eq(AnyFunctionProto )) nparams
2016
+ else - 1 // no eta expansion in this case
2017
+ }
2018
+
2015
2019
if (arity >= 0 && ! tree.symbol.isConstructor)
2016
2020
typed(etaExpand(tree, wtp, arity), pt)
2017
2021
else if (wtp.paramInfos.isEmpty)
Original file line number Diff line number Diff line change @@ -21,9 +21,18 @@ object Test {
21
21
def sum2 (x : Int , ys : Int * ) = (x /: ys)(_ + _)
22
22
val h1 : ((Int , Seq [Int ]) => Int ) = sum2
23
23
24
- // Not yet:
25
- // val h1 = repeat
26
- // val h2: (String, Int, Int) = h1
27
- // val h3 = sum
28
- // val h4: (Int, => Int) = h3
24
+ val h3 = repeat
25
+ val h4 : ((String , Int , Int ) => String ) = h3
26
+ val h5 = sum
27
+ val h6 : ((Int , => Int ) => Int ) = h5
28
+
29
+ class A
30
+ class B
31
+ class C
32
+ implicit object b extends B
33
+
34
+ def foo (x : A )(implicit bla : B ): C = ???
35
+
36
+ val h7 = foo
37
+ val h8 : A => C = h7
29
38
}
You can’t perform that action at this time.
0 commit comments