Skip to content

Commit

Permalink
Inline unapplys in the inlining phase (#19382)
Browse files Browse the repository at this point in the history
These currently got inlined while typing. Therefore they used to
generate code that should not be pickled. The non-transparent inline
methods should be inlined in the inlining phase.

This was found while working on #19380.
  • Loading branch information
nicolasstucki authored Apr 4, 2024
2 parents fa2f7bf + 804294c commit 06066db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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)
case t => t
}
}
Expand Down

0 comments on commit 06066db

Please sign in to comment.