Skip to content

Extract semanticDB for lifted definitions #21856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Clean up EtaExpansion lifting functions
Remove redundant LiftErased, make some lifting functions private if unused outside of class
  • Loading branch information
natsukagami committed Oct 29, 2024
commit 7fba5a32955aaf483457183fd168ce2e23604f6d
13 changes: 3 additions & 10 deletions compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ abstract class Lifter {
/** The tree of a lifted definition */
protected def liftedDef(sym: TermSymbol, rhs: Tree)(using Context): MemberDef = ValDef(sym, rhs)

/** Is lifting performed on erased terms? */
protected def isErased = false

private def lift(defs: mutable.ListBuffer[Tree], expr: Tree, prefix: TermName = EmptyTermName)(using Context): Tree =
if (noLift(expr)) expr
else {
Expand Down Expand Up @@ -117,8 +114,7 @@ abstract class Lifter {
case Apply(fn, args) =>
val fn1 = liftApp(defs, fn)
val args1 = liftArgs(defs, fn.tpe, args)
if isErased then untpd.cpy.Apply(tree)(fn1, args1).withType(tree.tpe) // application may be partial
else cpy.Apply(tree)(fn1, args1)
cpy.Apply(tree)(fn1, args1)
case TypeApply(fn, targs) =>
cpy.TypeApply(tree)(liftApp(defs, fn), targs)
case Select(pre, name) if isPureRef(tree) =>
Expand All @@ -141,7 +137,7 @@ abstract class Lifter {
*
* unless `pre` is idempotent.
*/
def liftNonIdempotentPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree =
private def liftNonIdempotentPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree =
if (isIdempotentExpr(tree)) tree else lift(defs, tree)

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

object LiftErased extends LiftComplex:
override def isErased = true

/** Lift all impure or complex arguments to `def`s */
object LiftToDefs extends LiftComplex {
override def liftedFlags: FlagSet = Method
Expand Down