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 @@ -2006,8 +2006,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
2006
2006
// prioritize method parameter types as parameter types of the eta-expanded closure
2007
2007
0
2008
2008
else defn.functionArity(ptNorm)
2009
- else if (pt eq AnyFunctionProto ) wtp.paramInfos.length
2010
- else - 1
2009
+ else {
2010
+ val nparams = wtp.paramInfos.length
2011
+ if (nparams > 0 || pt.eq(AnyFunctionProto )) nparams
2012
+ else - 1 // no eta expansion in this case
2013
+ }
2014
+
2011
2015
if (arity >= 0 && ! tree.symbol.isConstructor)
2012
2016
typed(etaExpand(tree, wtp, arity), pt)
2013
2017
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