Skip to content

Commit c29fa28

Browse files
jchybtgodzik
authored andcommitted
Fix stale top level synthetic package object being used in later runs
[Cherry-picked c3e1443]
1 parent cf6142f commit c29fa28

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2682,7 +2682,7 @@ object SymDenotations {
26822682
|| owner.isRefinementClass
26832683
|| owner.is(Scala2x)
26842684
|| owner.unforcedDecls.contains(denot.name, denot.symbol)
2685-
|| (denot.is(Synthetic) && denot.is(ModuleClass) && stillValidInOwner(denot.companionClass))
2685+
|| (denot.is(Synthetic) && denot.is(ModuleClass) && denot.companionClass.exists && stillValidInOwner(denot.companionClass))
26862686
|| denot.isSelfSym
26872687
|| denot.isLocalDummy)
26882688
catch case ex: StaleSymbol => false

tests/pos-macros/i13821-a/Macro.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait Conversions:
2+
given conv(using DFBits.Candidate): Conversion[Int, DFVal] = ???
3+
4+
import scala.quoted.*
5+
transparent inline def f: Short = ${ getWidthMacro }
6+
private def getWidthMacro(using Quotes): Expr[Short] = '{ ??? }

tests/pos-macros/i13821-a/Test.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type DFBits = Long
2+
object DFBits:
3+
def a: Unit = f // forces suspension of this compilation unit in typer
4+
def b: DFVal = 2 // uses implicit conversion `DFVal.conv`
5+
6+
trait Candidate
7+
object Candidate:
8+
given candidate: Candidate = ??? // completed in run 3 but created in run 2
9+
end DFBits
10+
11+
trait DFVal
12+
object DFVal extends Conversions

tests/pos-macros/i13821-b/Macro.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import outer._
2+
trait Conversions:
3+
given conv(using DFBits.Candidate): Conversion[Int, DFVal] = ???
4+
5+
import scala.quoted.*
6+
transparent inline def f: Short = ${ getWidthMacro }
7+
private def getWidthMacro(using Quotes): Expr[Short] = '{ ??? }

tests/pos-macros/i13821-b/Test.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
type outer = Int
2+
object outer:
3+
type DFBits = Long
4+
object DFBits:
5+
def a: Unit = f // forces suspension of this compilation unit in typer
6+
def b: DFVal = 2 // uses implicit conversion `DFVal.conv`
7+
8+
trait Candidate
9+
object Candidate:
10+
given candidate: Candidate = ??? // completed in run 3 but created in run 2
11+
end DFBits
12+
13+
trait DFVal
14+
object DFVal extends Conversions

0 commit comments

Comments
 (0)