Skip to content

Commit 94662bb

Browse files
committed
Try to git rid of isSuperOf and isSubOf
1 parent e87eb96 commit 94662bb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -2536,35 +2536,35 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25362536
*/
25372537
private def dropIfSuper(tp: Type, sub: Type): Type =
25382538

2539-
def isSuperOf(sub: Type): Boolean = sub match
2540-
case AndType(sub1, sub2) if isSuperOf(sub1) || isSuperOf(sub2) => true
2541-
case sub: TypeVar if sub.isInstantiated => isSuperOf(sub.instanceOpt)
2542-
case _ => isSubTypeWhenFrozen(sub, tp)
2539+
// def isSuperOf(sub: Type): Boolean = sub match
2540+
// case AndType(sub1, sub2) if isSuperOf(sub1) || isSuperOf(sub2) => true
2541+
// case sub: TypeVar if sub.isInstantiated => isSuperOf(sub.instanceOpt)
2542+
// case _ => isSubTypeWhenFrozen(sub, tp)
25432543

25442544
tp match
25452545
case tp @ AndType(tp1, tp2) =>
25462546
recombine(dropIfSuper(tp1, sub), dropIfSuper(tp2, sub), tp)
25472547
case tp: TypeVar if tp.isInstantiated =>
25482548
dropIfSuper(tp.instanceOpt, sub)
25492549
case _ =>
2550-
if isSuperOf(sub) then NoType else tp
2550+
if isSubTypeWhenFrozen(sub, tp) then NoType else tp
25512551
end dropIfSuper
25522552

25532553
/** If some (|-operand of) `tp` is a subtype of `sup` replace it with `NoType`. */
25542554
private def dropIfSub(tp: Type, sup: Type, canConstrain: Boolean): Type =
25552555

2556-
def isSubOf(sup: Type): Boolean = sup match
2557-
case OrType(sup1, sup2) if isSubOf(sup1) || isSubOf(sup2) => true
2558-
case sup: TypeVar if sup.isInstantiated => isSubOf(sup.instanceOpt)
2559-
case _ => isSubType(tp, sup, whenFrozen = !canConstrain)
2556+
// def isSubOf(sup: Type): Boolean = sup match
2557+
// case OrType(sup1, sup2) if isSubOf(sup1) || isSubOf(sup2) => true
2558+
// case sup: TypeVar if sup.isInstantiated => isSubOf(sup.instanceOpt)
2559+
// case _ => isSubType(tp, sup, whenFrozen = !canConstrain)
25602560

25612561
tp match
25622562
case tp @ OrType(tp1, tp2) =>
25632563
recombine(dropIfSub(tp1, sup, canConstrain), dropIfSub(tp2, sup, canConstrain), tp)
25642564
case tp: TypeVar if tp.isInstantiated =>
25652565
dropIfSub(tp.instanceOpt, sup, canConstrain)
25662566
case _ =>
2567-
if isSubOf(sup) then NoType else tp
2567+
if isSubType(tp, sup, whenFrozen = !canConstrain) then NoType else tp
25682568
end dropIfSub
25692569

25702570
/** There's a window of vulnerability between ElimByName and Erasure where some

0 commit comments

Comments
 (0)