Skip to content

Commit 1cb7555

Browse files
committed
Fix #5954: Do not check prefix for non locally defined types
1 parent 60c4bf8 commit 1cb7555

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ class Staging extends MacroTransform {
241241
*/
242242
private def checkSymLevel(sym: Symbol, tp: Type, pos: SourcePosition)(implicit ctx: Context): Option[Tree] = {
243243
val isThis = tp.isInstanceOf[ThisType]
244-
if (!isThis && sym.maybeOwner.isType && !sym.is(Param))
245-
checkSymLevel(sym.owner, sym.owner.thisType, pos)
244+
if (!isThis && !sym.is(Param) && sym.maybeOwner.isType)
245+
None
246246
else if (sym.exists && !sym.isStaticOwner && !levelOK(sym))
247247
tryHeal(sym, tp, pos)
248248
else

tests/neg/i5954.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
abstract class MatcherFactory1 {
2+
class AndNotWord
3+
}
4+
5+
object MatcherFactory1 {
6+
import scala.quoted._
7+
8+
def impl2(a: MatcherFactory1)(self: Expr[a.AndNotWord]) =
9+
'{ ~self } // error: access to value a from wrong staging level
10+
}

tests/pos/i5954.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
abstract class MatcherFactory1 {
2+
class AndNotWord
3+
}
4+
5+
object MatcherFactory1 {
6+
import scala.quoted._
7+
8+
def impl(self: Expr[MatcherFactory1#AndNotWord]) =
9+
'{ ~self }
10+
11+
}

0 commit comments

Comments
 (0)