Skip to content

Commit 2a18bf2

Browse files
oderskycswinter
authored andcommitted
Fix computation of parent types of a classinfo.
The previously used `rebase` did not rewrire outer this references. The right thing to do here is an asSeenFrom.
1 parent ed05cba commit 2a18bf2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,10 +2995,6 @@ object Types {
29952995
/** The class type with all type parameters */
29962996
def fullyAppliedRef(implicit ctx: Context): Type = fullyAppliedRef(cls.typeRef, cls.typeParams)
29972997

2998-
def rebase(tp: Type)(implicit ctx: Context): Type =
2999-
if ((prefix eq cls.owner.thisType) || !cls.owner.isClass || ctx.erasedTypes) tp
3000-
else tp.substThis(cls.owner.asClass, prefix)
3001-
30022998
private var typeRefCache: TypeRef = null
30032999

30043000
def typeRef(implicit ctx: Context): TypeRef = {
@@ -3018,7 +3014,7 @@ object Types {
30183014
/** The parent type refs as seen from the given prefix */
30193015
override def parents(implicit ctx: Context): List[TypeRef] = {
30203016
if (parentsCache == null)
3021-
parentsCache = cls.classParents.mapConserve(rebase(_).asInstanceOf[TypeRef])
3017+
parentsCache = cls.classParents.mapConserve(_.asSeenFrom(prefix, cls.owner).asInstanceOf[TypeRef])
30223018
parentsCache
30233019
}
30243020

0 commit comments

Comments
 (0)