Skip to content

Commit a9d2706

Browse files
committed
Simplify type match test
1 parent 804b786 commit a9d2706

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/src/dotty/tools/dotc/transform/EtaReduce.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ class EtaReduce extends MiniPhase:
3333
case Apply(Select(fn, nme.apply), args)
3434
if meth.paramss.head.corresponds(args)((param, arg) =>
3535
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
36+
&& isPurePath(fn)
37+
&& fn.tpe <:< tree.tpe
38+
&& defn.isFunctionClass(fn.tpe.widen.typeSymbol) =>
39+
report.log(i"eta reducing $tree --> $fn")
40+
fn
4341
case _ => tree
4442
case _ => tree
4543

0 commit comments

Comments
 (0)