@@ -965,28 +965,29 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
965
965
* Test that the resulting bounds are still satisfiable.
966
966
*/
967
967
private def narrowGADTBounds (tr : NamedType , bound : Type , isUpper : Boolean ): Boolean =
968
- ctx.mode.is(Mode .GADTflexible ) && {
969
- val tparam = tr.symbol
970
- typr.println(i " narrow gadt bound of $tparam: ${tparam.info} from ${if (isUpper) " above" else " below" } to $bound ${bound.isRef(tparam)}" )
971
- if (bound.isRef(tparam)) false
972
- else bound match {
973
- case bound : TypeRef
974
- if bound.symbol.is(BindDefinedType ) && ctx.gadt.bounds.contains(bound.symbol) &&
975
- ! tr.symbol.is(BindDefinedType ) =>
976
- // Avoid having pattern-bound types in gadt bounds,
977
- // as these might be eliminated once the pattern is typechecked.
978
- // Pattern-bound type symbols should be narrowed first, only if that fails
979
- // should symbols in the environment be constrained.
980
- narrowGADTBounds(bound, tr, ! isUpper)
981
- case _ =>
982
- val oldBounds = ctx.gadt.bounds(tparam)
983
- val newBounds =
984
- if (isUpper) TypeBounds (oldBounds.lo, oldBounds.hi & bound)
985
- else TypeBounds (oldBounds.lo | bound, oldBounds.hi)
986
- isSubType(newBounds.lo, newBounds.hi) &&
987
- { ctx.gadt.setBounds(tparam, newBounds); true }
968
+ ctx.mode.is(Mode .GADTflexible ) && ! frozenConstraint && {
969
+ val tparam = tr.symbol
970
+ typr.println(i " narrow gadt bound of $tparam: ${tparam.info} from ${if (isUpper) " above" else " below" } to $bound ${bound.isRef(tparam)}" )
971
+ if (bound.isRef(tparam)) false
972
+ else bound match {
973
+ case bound : TypeRef
974
+ if bound.symbol.is(BindDefinedType ) &&
975
+ ctx.gadt.bounds.contains(bound.symbol) &&
976
+ ! tr.symbol.is(BindDefinedType ) =>
977
+ // Avoid having pattern-bound types in gadt bounds,
978
+ // as these might be eliminated once the pattern is typechecked.
979
+ // Pattern-bound type symbols should be narrowed first, only if that fails
980
+ // should symbols in the environment be constrained.
981
+ narrowGADTBounds(bound, tr, ! isUpper)
982
+ case _ =>
983
+ val oldBounds = ctx.gadt.bounds(tparam)
984
+ val newBounds =
985
+ if (isUpper) TypeBounds (oldBounds.lo, oldBounds.hi & bound)
986
+ else TypeBounds (oldBounds.lo | bound, oldBounds.hi)
987
+ isSubType(newBounds.lo, newBounds.hi) &&
988
+ { ctx.gadt.setBounds(tparam, newBounds); true }
989
+ }
988
990
}
989
- }
990
991
991
992
// Tests around `matches`
992
993
0 commit comments