Skip to content

Commit c00e85a

Browse files
noti0na1tgodzik
authored andcommitted
Cleanup the type of UnApply trees in posttyper
[Cherry-picked 170f1ff]
1 parent 7e2aa57 commit c00e85a

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
369369
case UnApply(fun, implicits, patterns) =>
370370
// Reverse transform order for the same reason as in `app1` above.
371371
val patterns1 = transform(patterns)
372-
cpy.UnApply(tree)(transform(fun), transform(implicits), patterns1)
372+
val tree1 = cpy.UnApply(tree)(transform(fun), transform(implicits), patterns1)
373+
// The pickling of UnApply trees uses the tpe of the tree,
374+
// so we need to clean retains from it here
375+
tree1.withType(transformAnnotsIn(CleanupRetains()(tree1.tpe)))
373376
case tree: TypeApply =>
374377
if tree.symbol == defn.QuotedTypeModule_of then
375378
ctx.compilationUnit.needsStaging = true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import language.experimental.captureChecking
2+
3+
class Generator:
4+
private def generateTable(table: Table) =
5+
val (ownRelations, _) = calculateOwnRelations(table)
6+
ownRelations
7+
8+
private def calculateOwnRelations(table: Table) =
9+
val ownRelations = table.relations.filter(_.association.isDefined)
10+
(ownRelations, Nil)
11+
12+
case class Table(relations: Seq[TableRelation])
13+
case class TableRelation(association: Option[Association])
14+
trait Association

tests/pos/i24207.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Generator:
2+
private def generateTable(table: Table) =
3+
val (ownRelations, _) = calculateOwnRelations(table)
4+
ownRelations
5+
6+
private def calculateOwnRelations(table: Table) =
7+
val ownRelations = table.relations.filter(_.association.isDefined)
8+
(ownRelations, Nil)
9+
10+
case class Table(relations: Seq[TableRelation])
11+
case class TableRelation(association: Option[Association])
12+
trait Association

0 commit comments

Comments
 (0)