Skip to content

Fix #7048: PCP heal path dependent types #7386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down
File renamed without changes.