Skip to content

Fix stale top level synthetic package object being used in later runs #23464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2720,7 +2720,7 @@ object SymDenotations {
|| owner.isRefinementClass
|| owner.is(Scala2x)
|| owner.unforcedDecls.contains(denot.name, denot.symbol)
|| (denot.is(Synthetic) && denot.is(ModuleClass) && stillValidInOwner(denot.companionClass))
|| (denot.is(Synthetic) && denot.is(ModuleClass) && denot.companionClass.exists && stillValidInOwner(denot.companionClass))
|| denot.isSelfSym
|| denot.isLocalDummy)
catch case ex: StaleSymbol => false
Expand Down
4 changes: 0 additions & 4 deletions tests/neg/i19351.check

This file was deleted.

5 changes: 0 additions & 5 deletions tests/neg/i19351/A.scala

This file was deleted.

4 changes: 0 additions & 4 deletions tests/neg/i19351a.check

This file was deleted.

6 changes: 6 additions & 0 deletions tests/pos-macros/i13821-a/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait Conversions:
given conv(using DFBits.Candidate): Conversion[Int, DFVal] = ???

import scala.quoted.*
transparent inline def f: Short = ${ getWidthMacro }
private def getWidthMacro(using Quotes): Expr[Short] = '{ ??? }
12 changes: 12 additions & 0 deletions tests/pos-macros/i13821-a/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type DFBits = Long
object DFBits:
def a: Unit = f // forces suspension of this compilation unit in typer
def b: DFVal = 2 // uses implicit conversion `DFVal.conv`

trait Candidate
object Candidate:
given candidate: Candidate = ??? // completed in run 3 but created in run 2
end DFBits

trait DFVal
object DFVal extends Conversions
7 changes: 7 additions & 0 deletions tests/pos-macros/i13821-b/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import outer._
trait Conversions:
given conv(using DFBits.Candidate): Conversion[Int, DFVal] = ???

import scala.quoted.*
transparent inline def f: Short = ${ getWidthMacro }
private def getWidthMacro(using Quotes): Expr[Short] = '{ ??? }
14 changes: 14 additions & 0 deletions tests/pos-macros/i13821-b/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type outer = Int
object outer:
type DFBits = Long
object DFBits:
def a: Unit = f // forces suspension of this compilation unit in typer
def b: DFVal = 2 // uses implicit conversion `DFVal.conv`

trait Candidate
object Candidate:
given candidate: Candidate = ??? // completed in run 3 but created in run 2
end DFBits

trait DFVal
object DFVal extends Conversions
6 changes: 6 additions & 0 deletions tests/pos-macros/i19351/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// object A:
val x: Int = 1
inline def myMacro(): x.type = ${myMacroExpr}
def test = myMacro()

@main def main() = ()
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import scala.quoted.*
//import A.*
// import A.*
def myMacroExpr(using Quotes): Expr[x.type] = '{???}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Bool = [R] => (R, R) => R
val True: Bool = [R] => (t: R, _: R) => t
val False: Bool = [R] => (_: R, f: R) => f

inline def not(b: Bool): Bool = ${notMacro('b)} // error
inline def not(b: Bool): Bool = ${notMacro('b)}
inline def show(b: Bool): String = ${showMacro('b)}
//inline def not(b: Bool): Bool = ${foldMacro('b, 'False, 'True)}
//inline def show(b: Bool): String = ${foldMacro('b, '{"TRUE"}, '{"FALSE"})}
Expand Down
Loading