Skip to content

Commit

Permalink
Allow comparisons between TypeRefs and ThisTypes.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DarkDimius committed Jan 4, 2016
1 parent a1a2961 commit f0c6814
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
val cls1 = tp1.cls
cls1.classInfo.selfType.derivesFrom(cls2) &&
cls2.classInfo.selfType.derivesFrom(cls1)
case tp1: TermRef if cls2.is(Module) && cls2.eq(tp1.widen.typeSymbol) =>
case tp1: NamedType if cls2.is(Module) && cls2.eq(tp1.widen.typeSymbol) =>
cls2.isStaticOwner ||
isSubType(tp1.prefix, cls2.owner.thisType) ||
secondTry(tp1, tp2)
Expand Down

0 comments on commit f0c6814

Please sign in to comment.