Skip to content

Commit 169c8dc

Browse files
committed
Cleanup of RefinedType subtype comparison.
1 parent 7f6decf commit 169c8dc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,25 +338,23 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
338338
isSubType(tp1, tp2.parent) &&
339339
(name2 == nme.WILDCARD || hasMatchingMember(name2, tp1, tp2))
340340
}
341+
def etaExpandedSubType(tp1: Type) =
342+
isSubType(tp1.typeConstructor.EtaExpand(tp2.typeParams), tp2)
341343
def compareRefined: Boolean = {
342344
val tp1w = tp1.widen
343345
val skipped2 = skipMatching(tp1w, tp2)
344-
if ((skipped2 eq tp2) || !Config.fastPathForRefinedSubtype) {
345-
val normalPath = tp1 match {
346+
if ((skipped2 eq tp2) || !Config.fastPathForRefinedSubtype)
347+
tp1 match {
346348
case tp1: AndType =>
347349
// Delay calling `compareRefinedSlow` because looking up a member
348350
// of an `AndType` can lead to a cascade of subtyping checks
349351
// This twist is needed to make collection/generic/ParFactory.scala compile
350352
fourthTry(tp1, tp2) || compareRefinedSlow
351353
case _ =>
352-
compareRefinedSlow || fourthTry(tp1, tp2)
354+
compareRefinedSlow ||
355+
fourthTry(tp1, tp2) ||
356+
needsEtaLift(tp1, tp2) && testLifted(tp1, tp2, tp2.typeParams, etaExpandedSubType)
353357
}
354-
def etaExpandedSubType(tp1: Type) =
355-
isSubType(tp1.typeConstructor.EtaExpand(tp2.typeParams), tp2)
356-
normalPath ||
357-
needsEtaLift(tp1, tp2) &&
358-
testLifted(tp1, tp2, tp2.typeParams, etaExpandedSubType)
359-
}
360358
else // fast path, in particular for refinements resulting from parameterization.
361359
isSubType(tp1, skipped2) &&
362360
isSubRefinements(tp1w.asInstanceOf[RefinedType], tp2, skipped2)

0 commit comments

Comments
 (0)