Skip to content

Commit

Permalink
Merge pull request #15528 from dotty-staging/refactor-inliner
Browse files Browse the repository at this point in the history
Refactor inliner
  • Loading branch information
nicolasstucki authored Jun 29, 2022
2 parents 65a86ae + c6d297b commit 6062192
Show file tree
Hide file tree
Showing 23 changed files with 2,010 additions and 1,953 deletions.
12 changes: 12 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,18 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
case _ => None
case _ => None
end AssertNotNull

object ConstantValue {
def unapply(tree: Tree)(using Context): Option[Any] =
tree match
case Typed(expr, _) => unapply(expr)
case Inlined(_, Nil, expr) => unapply(expr)
case Block(Nil, expr) => unapply(expr)
case _ =>
tree.tpe.widenTermRefExpr.normalized match
case ConstantType(Constant(x)) => Some(x)
case _ => None
}
}

object TreeInfo {
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import Uniques._
import ast.Trees._
import ast.untpd
import util.{NoSource, SimpleIdentityMap, SourceFile, HashSet, ReusableInstance}
import typer.{Implicits, ImportInfo, Inliner, SearchHistory, SearchRoot, TypeAssigner, Typer, Nullables}
import typer.{Implicits, ImportInfo, SearchHistory, SearchRoot, TypeAssigner, Typer, Nullables}
import inlines.Inliner
import Nullables._
import Implicits.ContextualImplicits
import config.Settings._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ class TreeUnpickler(reader: TastyReader,
else if sym.isInlineMethod && !sym.is(Deferred) then
// The body of an inline method is stored in an annotation, so no need to unpickle it again
new Trees.Lazy[Tree] {
def complete(using Context) = typer.Inliner.bodyToInline(sym)
def complete(using Context) = inlines.Inlines.bodyToInline(sym)
}
else
readLater(end, _.readTerm())
Expand Down
Loading

0 comments on commit 6062192

Please sign in to comment.