diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index f21abf65b858..711ac60daf90 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -153,7 +153,21 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( /** Is a reference to a class but not `this.type` */ def isClassRef = sym.isClass && !tp.isInstanceOf[ThisType] - if (!sym.exists || levelOK(sym)) + /** Is this a static path or a type porjection with a static prefix */ + def isStaticPathOK(tp1: Type): Boolean = + tp1.stripTypeVar match + case tp1: TypeRef => tp1.symbol.is(Package) || isStaticPathOK(tp1.prefix) + case tp1: TermRef => + def isStaticTermPathOK(sym: Symbol): Boolean = + (sym.is(Module) && sym.isStatic) || + (sym.isStableMember && isStaticTermPathOK(sym.owner)) + isStaticTermPathOK(tp1.symbol) + case tp1: ThisType => tp1.cls.isStaticOwner + case tp1: AppliedType => isStaticPathOK(tp1.tycon) + case tp1: SkolemType => isStaticPathOK(tp1.info) + case _ => false + + if (!sym.exists || levelOK(sym) || isStaticPathOK(tp)) None else if (!sym.isStaticOwner && !isClassRef) tryHeal(sym, tp, pos) @@ -180,7 +194,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( sym.isClass // reference to this in inline methods ) case None => - !sym.is(Param) || levelOK(sym.owner) + sym.is(Package) || sym.owner.isStaticOwner || levelOK(sym.owner) } /** Try to heal phase-inconsistent reference to type `T` using a local type definition. diff --git a/tests/pending/pos/i7048.scala b/tests/pos/i7048.scala similarity index 100% rename from tests/pending/pos/i7048.scala rename to tests/pos/i7048.scala diff --git a/tests/pending/run-macros/i7048/Lib_1.scala b/tests/run-macros/i7048/Lib_1.scala similarity index 100% rename from tests/pending/run-macros/i7048/Lib_1.scala rename to tests/run-macros/i7048/Lib_1.scala diff --git a/tests/pending/run-macros/i7048/Test_2.scala b/tests/run-macros/i7048/Test_2.scala similarity index 100% rename from tests/pending/run-macros/i7048/Test_2.scala rename to tests/run-macros/i7048/Test_2.scala