Skip to content

Commit cb15a16

Browse files
authored
Merge pull request #488 from scala/backport-lts-3.3-23464
Backport "Fix stale top level synthetic package object being used in later runs" to 3.3 LTS
2 parents f6a1865 + 5917e12 commit cb15a16

File tree

12 files changed

+48
-16
lines changed

12 files changed

+48
-16
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/neg/i19351.check

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/neg/i19351/A.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/neg/i19351a.check

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

tests/pos-macros/i19351/A.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// object A:
2+
val x: Int = 1
3+
inline def myMacro(): x.type = ${myMacroExpr}
4+
def test = myMacro()
5+
6+
@main def main() = ()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import scala.quoted.*
2-
//import A.*
2+
// import A.*
33
def myMacroExpr(using Quotes): Expr[x.type] = '{???}

0 commit comments

Comments
 (0)