Skip to content

Refactor inliner #15528

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 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
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