Skip to content

Commit 0bbef02

Browse files
committed
Suppress some staging level errors
Don't issue errors in imports or inline methods. Also, improve the way objects are referred to in error messages.
1 parent 0b9d791 commit 0bbef02

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@ class ReifyQuotes extends MacroTransform {
6262
def checkLevel(tree: Tree)(implicit ctx: Context): Unit = {
6363

6464
def check(sym: Symbol, show: Symbol => String): Unit =
65-
if (levelOf.getOrElse(sym, currentLevel) != currentLevel)
65+
if (!sym.isStaticOwner &&
66+
!ctx.owner.ownersIterator.exists(_.isInlineMethod) &&
67+
levelOf.getOrElse(sym, currentLevel) != currentLevel)
6668
ctx.error(em"""access to ${show(sym)} from wrong staging level:
6769
| - the definition is at level ${levelOf(sym)},
6870
| - but the access is at level $currentLevel.""", tree.pos)
6971

70-
def showThis(sym: Symbol) = i"${sym.name}.this"
72+
def showThis(sym: Symbol) =
73+
if (sym.is(ModuleClass)) sym.sourceModule.show
74+
else i"${sym.name}.this"
7175

7276
val sym = tree.symbol
7377
if (sym.exists)
@@ -136,6 +140,8 @@ class ReifyQuotes extends MacroTransform {
136140
levelOf -= enteredSyms.head
137141
enteredSyms = enteredSyms.tail
138142
}
143+
case _: Import =>
144+
tree
139145
case _ =>
140146
super.transform(tree)
141147
}

0 commit comments

Comments
 (0)