Skip to content

Commit

Permalink
Keep inlined nodes until backend phase
Browse files Browse the repository at this point in the history
Refactoring of inlined nodes to simplify the work on scala#17055.
This work is based on scala#18229.
  • Loading branch information
Tetchki committed Jul 17, 2023
1 parent 40d44d3 commit 135f6cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.core.Decorators.em
import dotty.tools.dotc.report
import dotty.tools.dotc.inlines.Inlines

/*
*
Expand Down Expand Up @@ -479,6 +480,10 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
case t: TypeApply => // dotty specific
generatedType = genTypeApply(t)

case inlined @ Inlined(_, _, _) =>
genLoadTo(Inlines.dropInlined(inlined) , expectedType, dest)
generatedDest = dest

case _ => abort(s"Unexpected tree in genLoad: $tree/${tree.getClass} at: ${tree.span}")
}

Expand Down
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import dotty.tools.dotc.transform.sjs.JSSymUtils._

import JSEncoding._
import ScopedVar.withScopedVars
import dotty.tools.dotc.inlines.Inlines

/** Main codegen for Scala.js IR.
*
Expand Down Expand Up @@ -1930,6 +1931,9 @@ class JSCodeGen()(using genCtx: Context) {
case EmptyTree =>
js.Skip()

case inlined @ Inlined(_, _, _) =>
genStatOrExpr(Inlines.dropInlined(inlined), isStat)

case _ =>
throw new FatalError("Unexpected tree in genExpr: " +
tree + "/" + tree.getClass + " at: " + (tree.span: Position))
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ object Erasure {

override def typedInlined(tree: untpd.Inlined, pt: Type)(using Context): Tree =
super.typedInlined(tree, pt) match {
case tree: Inlined => Inlines.dropInlined(tree)
case tree: Inlined => tree //Inlines.dropInlined(tree)
}

override def typedValDef(vdef: untpd.ValDef, sym: Symbol)(using Context): Tree =
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/Mixin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Names._
import NameKinds._
import NameOps._
import ast.Trees._
import dotty.tools.dotc.inlines.Inlines

object Mixin {
val name: String = "mixin"
Expand Down Expand Up @@ -221,6 +222,7 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
case _ =>
}
(scall, stats ::: inits, args)
case inlined @ Inlined(_, _, _) => transformConstructor(Inlines.dropInlined(inlined) )
case _ =>
val Apply(sel @ Select(New(_), nme.CONSTRUCTOR), args) = tree: @unchecked
val (callArgs, initArgs) = if (tree.symbol.owner.is(Trait)) (Nil, args) else (args, Nil)
Expand Down

0 comments on commit 135f6cd

Please sign in to comment.