diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index 3ed682143686..84ef94687b13 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -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 } diff --git a/tests/pos-macros/i21844/Macro.scala b/tests/pos-macros/i21844/Macro.scala new file mode 100644 index 000000000000..31a2c3a5e76f --- /dev/null +++ b/tests/pos-macros/i21844/Macro.scala @@ -0,0 +1,6 @@ +import scala.quoted.* + +object Macro: + inline def foo = ${ fooImpl } + def fooImpl(using Quotes): Expr[Int] = + '{ 123 } diff --git a/tests/pos-macros/i21844/SubClass.scala b/tests/pos-macros/i21844/SubClass.scala new file mode 100644 index 000000000000..54b0d970e515 --- /dev/null +++ b/tests/pos-macros/i21844/SubClass.scala @@ -0,0 +1,3 @@ +class SubClass extends SuperClass +object SubClass: + val foo: Int = Macro.foo diff --git a/tests/pos-macros/i21844/SuperClassWithLazyVal.scala b/tests/pos-macros/i21844/SuperClassWithLazyVal.scala new file mode 100644 index 000000000000..60c270f2b277 --- /dev/null +++ b/tests/pos-macros/i21844/SuperClassWithLazyVal.scala @@ -0,0 +1,2 @@ +class SuperClass: + lazy val xyz: Int = 123