Skip to content

Backport "Do not bring forward symbols created in transform and backend phases" to 3.3 LTS #143

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

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
@@ -736,6 +736,8 @@ object Denotations {
* the old version otherwise.
* - If the symbol did not have a denotation that was defined at the current phase
* return a NoDenotation instead.
* - If the symbol was first defined in one of the transform phases (after pickling), it should not
* be visible in new runs, so also return a NoDenotation.
*/
private def bringForward()(using Context): SingleDenotation = {
this match {
@@ -749,6 +751,7 @@ object Denotations {
}
if (!symbol.exists) return updateValidity()
if (!coveredInterval.containsPhaseId(ctx.phaseId)) return NoDenotation
if (coveredInterval.firstPhaseId >= Phases.firstTransformPhase.id) return NoDenotation
if (ctx.debug) traceInvalid(this)
staleSymbolError
}
6 changes: 6 additions & 0 deletions tests/pos-macros/i21844/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import scala.quoted.*

object Macro:
inline def foo = ${ fooImpl }
def fooImpl(using Quotes): Expr[Int] =
'{ 123 }
3 changes: 3 additions & 0 deletions tests/pos-macros/i21844/SubClass.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class SubClass extends SuperClass
object SubClass:
val foo: Int = Macro.foo
2 changes: 2 additions & 0 deletions tests/pos-macros/i21844/SuperClassWithLazyVal.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class SuperClass:
lazy val xyz: Int = 123