@@ -38,17 +38,10 @@ class BetaReduce extends MiniPhase:
3838
3939 override def description : String = BetaReduce .description
4040
41- override def transformApply (app : Apply )(using Context ): Tree = app.fun match
42- case Select (fn, nme.apply) if defn.isFunctionType(fn.tpe) =>
43- val app1 = BetaReduce (app, fn, List (app.args))
44- if app1 ne app then report.log(i " beta reduce $app -> $app1" )
45- app1
46- case TypeApply (Select (fn, nme.apply), targs) if fn.tpe.typeSymbol eq defn.PolyFunctionClass =>
47- val app1 = BetaReduce (app, fn, List (targs, app.args))
48- if app1 ne app then report.log(i " beta reduce $app -> $app1" )
49- app1
50- case _ =>
51- app
41+ override def transformApply (app : Apply )(using Context ): Tree =
42+ val app1 = BetaReduce (app)
43+ if app1 ne app then report.log(i " beta reduce $app -> $app1" )
44+ app1
5245
5346object BetaReduce :
5447 import ast .tpd ._
@@ -118,31 +111,6 @@ object BetaReduce:
118111 case _ =>
119112 tree
120113
121- /** Beta-reduces a call to `fn` with arguments `argSyms` or returns `tree` */
122- def apply (original : Tree , fn : Tree , argss : List [List [Tree ]])(using Context ): Tree =
123- fn match
124- case Typed (expr, _) =>
125- BetaReduce (original, expr, argss)
126- case Block ((anonFun : DefDef ) :: Nil , closure : Closure ) =>
127- BetaReduce (anonFun, argss)
128- case Block ((TypeDef (_, template : Template )) :: Nil , Typed (Apply (Select (New (_), _), _), _)) if template.constr.rhs.isEmpty =>
129- template.body match
130- case (anonFun : DefDef ) :: Nil =>
131- BetaReduce (anonFun, argss)
132- case _ =>
133- original
134- case Block (stats, expr) =>
135- val tree = BetaReduce (original, expr, argss)
136- if tree eq original then original
137- else cpy.Block (fn)(stats, tree)
138- case Inlined (call, bindings, expr) =>
139- val tree = BetaReduce (original, expr, argss)
140- if tree eq original then original
141- else cpy.Inlined (fn)(call, bindings, tree)
142- case _ =>
143- original
144- end apply
145-
146114 /** Beta-reduces a call to `ddef` with arguments `args` */
147115 def apply (ddef : DefDef , argss : List [List [Tree ]])(using Context ) =
148116 val bindings = new ListBuffer [DefTree ]()
0 commit comments