Skip to content

TypeComparer: delay looking up members of AndTypes #979

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
Dec 6, 2015
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
20 changes: 13 additions & 7 deletions src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,23 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
}
comparePolyParam
case tp2: RefinedType =>
def compareRefinedSlow: Boolean = {
val name2 = tp2.refinedName
isSubType(tp1, tp2.parent) &&
(name2 == nme.WILDCARD || hasMatchingMember(name2, tp1, tp2))
}
def compareRefined: Boolean = {
val tp1w = tp1.widen
val skipped2 = skipMatching(tp1w, tp2)
if ((skipped2 eq tp2) || !Config.fastPathForRefinedSubtype) {
val name2 = tp2.refinedName
val normalPath =
isSubType(tp1, tp2.parent) &&
( name2 == nme.WILDCARD
|| hasMatchingMember(name2, tp1, tp2)
|| fourthTry(tp1, tp2)
)
val normalPath = tp1 match {
case tp1: AndType =>
// Delay calling `compareRefinedSlow` because looking up a member
// of an `AndType` can lead to a cascade of subtyping checks
fourthTry(tp1, tp2) || compareRefinedSlow
case _ =>
compareRefinedSlow || fourthTry(tp1, tp2)
}
normalPath ||
needsEtaLift(tp1, tp2) && tp1.testLifted(tp2.typeParams, isSubType(_, tp2), classBounds(tp2))
}
Expand Down
4 changes: 1 addition & 3 deletions test/dotc/scala-collections.whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@
./scala-scala/src/library/scala/collection/generic/SortedMapFactory.scala
./scala-scala/src/library/scala/collection/generic/SortedSetFactory.scala
./scala-scala/src/library/scala/collection/generic/SetFactory.scala

# deep subtype
#./scala-scala/src/library/scala/collection/generic/ParFactory.scala
./scala-scala/src/library/scala/collection/generic/ParFactory.scala

# https://github.com/lampepfl/dotty/issues/974
#./scala-scala/src/library/scala/collection/generic/MutableSortedSetFactory.scala
Expand Down