Skip to content

Commit 9714565

Browse files
committed
Allow comparisons between TypeRefs and ThisTypes.
Motivation comes from Linker: List$.canBuildFrom is implemented as ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] static type of field ReusableCBF here is TypeRef(TypeRef(List$), GenericCanBuildFrom[Nothing]) but the ident ReusableCBF gets type TypeRef(ThisType(List$), GenericCanBuildFrom[Nothing]) We already permit comparisons between static TermRefs and ThisTypes, this change additionally allows TypeRefs to static modules to become subtypes of ThisTypes of static modules.
1 parent 5cd5cc9 commit 9714565

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
218218
val cls1 = tp1.cls
219219
cls1.classInfo.selfType.derivesFrom(cls2) &&
220220
cls2.classInfo.selfType.derivesFrom(cls1)
221-
case tp1: TermRef if cls2.is(Module) && cls2.eq(tp1.widen.typeSymbol) =>
221+
case tp1: NamedType if cls2.is(Module) && cls2.eq(tp1.widen.typeSymbol) =>
222222
cls2.isStaticOwner ||
223223
isSubType(tp1.prefix, cls2.owner.thisType) ||
224224
secondTry(tp1, tp2)

0 commit comments

Comments
 (0)