Skip to content

Inline unapplys in the inlining phase #19382

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
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
13 changes: 9 additions & 4 deletions compiler/src/dotty/tools/dotc/transform/Inlining.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ class Inlining extends MacroTransform, IdentityDenotTransformer {
else super.transform(tree)
case _: Typed | _: Block =>
super.transform(tree)
case _ if Inlines.needsInlining(tree) =>
val tree1 = super.transform(tree)
if tree1.tpe.isError then tree1
else Inlines.inlineCall(tree1)
case _: PackageDef =>
super.transform(tree) match
case tree1: PackageDef =>
Expand All @@ -106,6 +102,15 @@ class Inlining extends MacroTransform, IdentityDenotTransformer {
case tree1 => tree1
case _ =>
if tree.isType then tree
else if Inlines.needsInlining(tree) then
tree match
case tree: UnApply =>
val fun1 = Inlines.inlinedUnapplyFun(tree.fun)
super.transform(cpy.UnApply(tree)(fun = fun1))
case _ =>
val tree1 = super.transform(tree)
if tree1.tpe.isError then tree1
else Inlines.inlineCall(tree1)
else super.transform(tree)
}
}
Expand Down
3 changes: 0 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1956,9 +1956,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
if (bounds != null) sym.info = bounds
}
b
case t: UnApply if t.symbol.is(Inline) =>
assert(!t.symbol.is(Transparent))
cpy.UnApply(t)(fun = Inlines.inlinedUnapplyFun(t.fun)) // TODO inline these in the inlining phase (see #19382)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was deleted after I rebased

case t => t
}
}
Expand Down
Loading