@@ -1045,10 +1045,18 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1045
1045
}
1046
1046
}
1047
1047
1048
+ var usedGadtOrdering : Boolean = false
1049
+ def byGadtOrdering : Boolean =
1050
+ ctx.gadt.contains(tycon1sym)
1051
+ && ctx.gadt.contains(tycon2sym)
1052
+ && ctx.gadt.isLess(tycon1sym, tycon2sym)
1053
+ && { usedGadtOrdering = true ; true }
1054
+
1048
1055
val res = (
1049
1056
tycon1sym == tycon2sym && isSubPrefix(tycon1.prefix, tycon2.prefix)
1050
1057
|| byGadtBounds(tycon1sym, tycon2, fromAbove = true )
1051
1058
|| byGadtBounds(tycon2sym, tycon1, fromAbove = false )
1059
+ || byGadtOrdering
1052
1060
) && {
1053
1061
// There are two cases in which we can assume injectivity.
1054
1062
// First we check if either sym is a class.
@@ -1058,9 +1066,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1058
1066
// 2) if we touched GADTs, then the _other_ symbol (class syms
1059
1067
// cannot have GADT constraints), the one w/ GADT cstrs,
1060
1068
// 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
1061
1071
val tyconIsInjective =
1062
1072
(tycon1sym.isClass || tycon2sym.isClass)
1063
- && (! touchedGADTs || gadtIsInstantiated)
1073
+ && (! touchedGADTs || gadtIsInstantiated && ! usedGadtOrdering )
1064
1074
1065
1075
inFrozenGadtIf(! tyconIsInjective) {
1066
1076
if tycon1sym == tycon2sym && tycon1sym.isAliasType then
0 commit comments