Skip to content

Commit ce94491

Browse files
authored
Fix #24456: Cleanup the info of a Bind symbol in posttyper (#24490)
Fix #24456 Cleanup the info of a Bind symbol in posttyper
2 parents b69e7ee + c0abb05 commit ce94491

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,11 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
624624
case _ =>
625625
processMemberDef(super.transform(scala2LibPatch(tree)))
626626
case tree: Bind =>
627-
if tree.symbol.isType && !tree.symbol.name.is(WildcardParamName) then
628-
Checking.checkGoodBounds(tree.symbol)
627+
val sym = tree.symbol
628+
if sym.isType && !sym.name.is(WildcardParamName) then
629+
Checking.checkGoodBounds(sym)
630+
// Cleanup retains from the info of the Bind symbol
631+
sym.copySymDenotation(info = transformAnnotsIn(CleanupRetains()(sym.info))).installAfter(thisPhase)
629632
super.transform(tree)
630633
case tree: New if isCheckable(tree) =>
631634
Checking.checkInstantiable(tree.tpe, tree.tpe, tree.srcPos)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Similar to i24207
2+
3+
class Generator:
4+
private def generateTable(table: Table) =
5+
val (ownRelations, unusedTerm) = calculateOwnRelations(table)
6+
None
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/i24456.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Similar to i24207
2+
3+
class Generator:
4+
private def generateTable(table: Table) =
5+
val (ownRelations, unusedTerm) = calculateOwnRelations(table)
6+
None
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

0 commit comments

Comments
 (0)