Skip to content

Commit 7c169f5

Browse files
authored
Merge pull request #143 from scala/backport-lts-3.3-21865
Backport "Do not bring forward symbols created in transform and backend phases" to 3.3 LTS
2 parents fb2c793 + 8f067e0 commit 7c169f5

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,8 @@ object Denotations {
736736
* the old version otherwise.
737737
* - If the symbol did not have a denotation that was defined at the current phase
738738
* return a NoDenotation instead.
739+
* - If the symbol was first defined in one of the transform phases (after pickling), it should not
740+
* be visible in new runs, so also return a NoDenotation.
739741
*/
740742
private def bringForward()(using Context): SingleDenotation = {
741743
this match {
@@ -749,6 +751,7 @@ object Denotations {
749751
}
750752
if (!symbol.exists) return updateValidity()
751753
if (!coveredInterval.containsPhaseId(ctx.phaseId)) return NoDenotation
754+
if (coveredInterval.firstPhaseId >= Phases.firstTransformPhase.id) return NoDenotation
752755
if (ctx.debug) traceInvalid(this)
753756
staleSymbolError
754757
}

tests/pos-macros/i21844/Macro.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.quoted.*
2+
3+
object Macro:
4+
inline def foo = ${ fooImpl }
5+
def fooImpl(using Quotes): Expr[Int] =
6+
'{ 123 }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class SubClass extends SuperClass
2+
object SubClass:
3+
val foo: Int = Macro.foo
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class SuperClass:
2+
lazy val xyz: Int = 123

0 commit comments

Comments
 (0)