File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 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
20062006 // prioritize method parameter types as parameter types of the eta-expanded closure
20072007 0
20082008 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+
20112015 if (arity >= 0 && ! tree.symbol.isConstructor)
20122016 typed(etaExpand(tree, wtp, arity), pt)
20132017 else if (wtp.paramInfos.isEmpty)
Original file line number Diff line number Diff line change @@ -21,9 +21,18 @@ object Test {
2121 def sum2 (x : Int , ys : Int * ) = (x /: ys)(_ + _)
2222 val h1 : ((Int , Seq [Int ]) => Int ) = sum2
2323
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
2938}
You can’t perform that action at this time.
0 commit comments