Skip to content

Commit 77081ec

Browse files
committed
Fix #7048: PCP heal path dependent types
1 parent 754fa51 commit 77081ec

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,17 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
144144
/** Is a reference to a class but not `this.type` */
145145
def isClassRef = sym.isClass && !tp.isInstanceOf[ThisType]
146146

147-
if (!sym.exists || levelOK(sym))
147+
/** Is this a static path or a type porjection with a static prefix */
148+
def isStaticPathOK(tp1: Type): Boolean = tp1 match {
149+
case tp1: TypeRef => tp1.symbol.is(Package) || isStaticPathOK(tp1.prefix)
150+
case tp1: TermRef => tp1.symbol.isStaticOwner || isStaticPathOK(tp1.prefix)
151+
case tp1: ThisType => tp1.tref.symbol.is(Package) || tp1.tref.symbol.is(Module)
152+
case tp1: AppliedType => isStaticPathOK(tp1.tycon)
153+
case _: SkolemType => true
154+
case _ => false
155+
}
156+
157+
if (!sym.exists || levelOK(sym) || isStaticPathOK(tp))
148158
None
149159
else if (!sym.isStaticOwner && !isClassRef)
150160
tryHeal(sym, tp, pos)
@@ -171,7 +181,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
171181
sym.isClass // reference to this in inline methods
172182
)
173183
case None =>
174-
!sym.is(Param) || levelOK(sym.owner)
184+
sym.is(Package)|| sym.owner.isStaticOwner || levelOK(sym.owner)
175185
}
176186

177187
/** Try to heal phase-inconsistent reference to type `T` using a local type definition.
File renamed without changes.

0 commit comments

Comments
 (0)