Skip to content

Commit 06066db

Browse files
Inline unapplys in the inlining phase (#19382)
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.
2 parents fa2f7bf + 804294c commit 06066db

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: compiler/src/dotty/tools/dotc/transform/Inlining.scala

+9-4
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ class Inlining extends MacroTransform, IdentityDenotTransformer {
9090
else super.transform(tree)
9191
case _: Typed | _: Block =>
9292
super.transform(tree)
93-
case _ if Inlines.needsInlining(tree) =>
94-
val tree1 = super.transform(tree)
95-
if tree1.tpe.isError then tree1
96-
else Inlines.inlineCall(tree1)
9793
case _: PackageDef =>
9894
super.transform(tree) match
9995
case tree1: PackageDef =>
@@ -106,6 +102,15 @@ class Inlining extends MacroTransform, IdentityDenotTransformer {
106102
case tree1 => tree1
107103
case _ =>
108104
if tree.isType then tree
105+
else if Inlines.needsInlining(tree) then
106+
tree match
107+
case tree: UnApply =>
108+
val fun1 = Inlines.inlinedUnapplyFun(tree.fun)
109+
super.transform(cpy.UnApply(tree)(fun = fun1))
110+
case _ =>
111+
val tree1 = super.transform(tree)
112+
if tree1.tpe.isError then tree1
113+
else Inlines.inlineCall(tree1)
109114
else super.transform(tree)
110115
}
111116
}

Diff for: compiler/src/dotty/tools/dotc/typer/Typer.scala

-3
Original file line numberDiff line numberDiff line change
@@ -1956,9 +1956,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19561956
if (bounds != null) sym.info = bounds
19571957
}
19581958
b
1959-
case t: UnApply if t.symbol.is(Inline) =>
1960-
assert(!t.symbol.is(Transparent))
1961-
cpy.UnApply(t)(fun = Inlines.inlinedUnapplyFun(t.fun)) // TODO inline these in the inlining phase (see #19382)
19621959
case t => t
19631960
}
19641961
}

0 commit comments

Comments
 (0)