Skip to content

Commit 46c2a71

Browse files
committed
also rollback path-dependent GADT constraints on failure
1 parent b779c29 commit 46c2a71

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,13 +2014,16 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
20142014
case TypeRef(q: PathType, _) => (path eq q) && bound.isRef(sym)
20152015
case _ => false
20162016

2017-
isConstrainable && {
2018-
gadts.println(i"narrow gadt bound of pdt $path -> ${sym}: from ${if (isUpper) "above" else "below"} to $bound ${bound.toString} ${isRef}")
2017+
rollbackGadtUnless {
2018+
isConstrainable && {
2019+
gadts.println(i"narrow gadt bound of pdt $path -> ${sym}: from ${if (isUpper) "above" else "below"} to $bound ${bound.toString} ${isRef}")
20192020

2020-
if isRef then false
2021-
else if isUpper then gadtAddUpperBound(path, sym, bound)
2022-
else gadtAddLowerBound(path, sym, bound)
2021+
if isRef then false
2022+
else if isUpper then gadtAddUpperBound(path, sym, bound)
2023+
else gadtAddLowerBound(path, sym, bound)
2024+
}
20232025
}
2026+
20242027
case _ => false
20252028

20262029
narrowTypeParams || narrowPathDepType

0 commit comments

Comments
 (0)