We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 804b786 commit a9d2706Copy full SHA for a9d2706
compiler/src/dotty/tools/dotc/transform/EtaReduce.scala
@@ -33,13 +33,11 @@ class EtaReduce extends MiniPhase:
33
case Apply(Select(fn, nme.apply), args)
34
if meth.paramss.head.corresponds(args)((param, arg) =>
35
arg.isInstanceOf[Ident] && arg.symbol == param.symbol)
36
- && isPurePath(fn) =>
37
- val treeSym = tree.tpe.widen.typeSymbol
38
- val fnSym = fn.tpe.widen.typeSymbol
39
- if treeSym == fnSym && defn.isFunctionClass(fnSym) then
40
- report.log(i"eta reducing $tree --> $fn")
41
- fn
42
- else tree
+ && isPurePath(fn)
+ && fn.tpe <:< tree.tpe
+ && defn.isFunctionClass(fn.tpe.widen.typeSymbol) =>
+ report.log(i"eta reducing $tree --> $fn")
+ fn
43
case _ => tree
44
45
0 commit comments