Skip to content

Commit 6062192

Browse files
Merge pull request #15528 from dotty-staging/refactor-inliner
Refactor inliner
2 parents 65a86ae + c6d297b commit 6062192

23 files changed

+2010
-1953
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

+12
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,18 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
999999
case _ => None
10001000
case _ => None
10011001
end AssertNotNull
1002+
1003+
object ConstantValue {
1004+
def unapply(tree: Tree)(using Context): Option[Any] =
1005+
tree match
1006+
case Typed(expr, _) => unapply(expr)
1007+
case Inlined(_, Nil, expr) => unapply(expr)
1008+
case Block(Nil, expr) => unapply(expr)
1009+
case _ =>
1010+
tree.tpe.widenTermRefExpr.normalized match
1011+
case ConstantType(Constant(x)) => Some(x)
1012+
case _ => None
1013+
}
10021014
}
10031015

10041016
object TreeInfo {

compiler/src/dotty/tools/dotc/core/Contexts.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import Uniques._
1414
import ast.Trees._
1515
import ast.untpd
1616
import util.{NoSource, SimpleIdentityMap, SourceFile, HashSet, ReusableInstance}
17-
import typer.{Implicits, ImportInfo, Inliner, SearchHistory, SearchRoot, TypeAssigner, Typer, Nullables}
17+
import typer.{Implicits, ImportInfo, SearchHistory, SearchRoot, TypeAssigner, Typer, Nullables}
18+
import inlines.Inliner
1819
import Nullables._
1920
import Implicits.ContextualImplicits
2021
import config.Settings._

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ class TreeUnpickler(reader: TastyReader,
830830
else if sym.isInlineMethod && !sym.is(Deferred) then
831831
// The body of an inline method is stored in an annotation, so no need to unpickle it again
832832
new Trees.Lazy[Tree] {
833-
def complete(using Context) = typer.Inliner.bodyToInline(sym)
833+
def complete(using Context) = inlines.Inlines.bodyToInline(sym)
834834
}
835835
else
836836
readLater(end, _.readTerm())

0 commit comments

Comments
 (0)