Skip to content

Commit cba7620

Browse files
committed
Remove redundant check for injectivity assumption
The condition check on injectivity related to GADT ordering usage is unnecessary. For any subtyping relation F <:< G here, if the relation relied on GADT ordering, then both F and G are contained in GADTConstraint, which implies that both F and G are type parameters; neither `tycon1sym.isClass` nor `tycon2sym.isClass` will be true.
1 parent e340ffa commit cba7620

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,12 +1045,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
10451045
}
10461046
}
10471047

1048-
var usedGadtOrdering: Boolean = false
10491048
def byGadtOrdering: Boolean =
10501049
ctx.gadt.contains(tycon1sym)
10511050
&& ctx.gadt.contains(tycon2sym)
10521051
&& ctx.gadt.isLess(tycon1sym, tycon2sym)
1053-
&& { usedGadtOrdering = true; true }
10541052

10551053
val res = (
10561054
tycon1sym == tycon2sym && isSubPrefix(tycon1.prefix, tycon2.prefix)
@@ -1066,11 +1064,9 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
10661064
// 2) if we touched GADTs, then the _other_ symbol (class syms
10671065
// cannot have GADT constraints), the one w/ GADT cstrs,
10681066
// must be instantiated, making the two tycons equal
1069-
// 3) if we used GADT ordering, which means that neither symbol
1070-
// has been instantiated, we should not assume injectivity
10711067
val tyconIsInjective =
10721068
(tycon1sym.isClass || tycon2sym.isClass)
1073-
&& (!touchedGADTs || gadtIsInstantiated && !usedGadtOrdering)
1069+
&& (!touchedGADTs || gadtIsInstantiated)
10741070

10751071
inFrozenGadtIf(!tyconIsInjective) {
10761072
if tycon1sym == tycon2sym && tycon1sym.isAliasType then

0 commit comments

Comments
 (0)