Skip to content

Commit 7fba5a3

Browse files
committed
Clean up EtaExpansion lifting functions
Remove redundant LiftErased, make some lifting functions private if unused outside of class
1 parent a3786a5 commit 7fba5a3

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ abstract class Lifter {
3939
/** The tree of a lifted definition */
4040
protected def liftedDef(sym: TermSymbol, rhs: Tree)(using Context): MemberDef = ValDef(sym, rhs)
4141

42-
/** Is lifting performed on erased terms? */
43-
protected def isErased = false
44-
4542
private def lift(defs: mutable.ListBuffer[Tree], expr: Tree, prefix: TermName = EmptyTermName)(using Context): Tree =
4643
if (noLift(expr)) expr
4744
else {
@@ -117,8 +114,7 @@ abstract class Lifter {
117114
case Apply(fn, args) =>
118115
val fn1 = liftApp(defs, fn)
119116
val args1 = liftArgs(defs, fn.tpe, args)
120-
if isErased then untpd.cpy.Apply(tree)(fn1, args1).withType(tree.tpe) // application may be partial
121-
else cpy.Apply(tree)(fn1, args1)
117+
cpy.Apply(tree)(fn1, args1)
122118
case TypeApply(fn, targs) =>
123119
cpy.TypeApply(tree)(liftApp(defs, fn), targs)
124120
case Select(pre, name) if isPureRef(tree) =>
@@ -141,7 +137,7 @@ abstract class Lifter {
141137
*
142138
* unless `pre` is idempotent.
143139
*/
144-
def liftNonIdempotentPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree =
140+
private def liftNonIdempotentPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree =
145141
if (isIdempotentExpr(tree)) tree else lift(defs, tree)
146142

147143
/** Lift prefix `pre` of an application `pre.f(...)` to
@@ -154,7 +150,7 @@ abstract class Lifter {
154150
* Note that default arguments will refer to the prefix, we do not want
155151
* to re-evaluate a complex expression each time we access a getter.
156152
*/
157-
def liftPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree =
153+
private def liftPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree =
158154
tree match
159155
case tree: Literal => tree
160156
case tree: This => tree
@@ -218,9 +214,6 @@ object LiftCoverage extends LiftImpure {
218214
}
219215
}
220216

221-
object LiftErased extends LiftComplex:
222-
override def isErased = true
223-
224217
/** Lift all impure or complex arguments to `def`s */
225218
object LiftToDefs extends LiftComplex {
226219
override def liftedFlags: FlagSet = Method

0 commit comments

Comments
 (0)