Skip to content

Commit 37aeb3d

Browse files
committed
GADT: Use =:= instead of Any/Nothing
1 parent 86d8937 commit 37aeb3d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,22 @@ class GadtConstraint private (
7575
val self = externalize(param)
7676
constraint.minLower(param).foldLeft(nonParamBounds(param).lo) { (acc, p) =>
7777
externalize(p) match
78-
case tp: TypeRef
79-
// drop any lower param that is a GADT symbol
80-
// and is upper-bounded by a non-Any super-type of the original parameter
81-
// e.g. in pos/i14287.min
82-
// B$1 had info <: X and fullBounds >: B$2 <: X, and
83-
// B$2 had info <: B$1 and fullBounds <: B$1
84-
// We can use the info of B$2 to drop the lower-bound of B$1
85-
// and return non-bidirectional bounds B$1 <: X and B$2 <: B$1.
86-
if tp.symbol.isPatternBound && !tp.info.hiBound.isExactlyAny && self <:< tp.info.hiBound => acc
78+
// drop any lower param that is a GADT symbol
79+
// and is upper-bounded by a non-Any super-type of the original parameter
80+
// e.g. in pos/i14287.min
81+
// B$1 had info <: X and fullBounds >: B$2 <: X, and
82+
// B$2 had info <: B$1 and fullBounds <: B$1
83+
// We can use the info of B$2 to drop the lower-bound of B$1
84+
// and return non-bidirectional bounds B$1 <: X and B$2 <: B$1.
85+
case tp: TypeRef if tp.symbol.isPatternBound && self =:= tp.info.hiBound => acc
8786
case tp => acc | tp
8887
}
8988

9089
def fullUpperBound(param: TypeParamRef)(using Context): Type =
9190
val self = externalize(param)
9291
constraint.minUpper(param).foldLeft(nonParamBounds(param).hi) { (acc, u) =>
9392
externalize(u) match
94-
case tp: TypeRef // same as fullLowerBounds
95-
if tp.symbol.isPatternBound && !tp.info.loBound.isExactlyNothing && tp.info.loBound <:< self => acc
93+
case tp: TypeRef if tp.symbol.isPatternBound && self =:= tp.info.loBound => acc // like fullLowerBound
9694
case tp =>
9795
// Any as the upper bound means "no bound", but if F is higher-kinded,
9896
// Any & F = F[_]; this is wrong for us so we need to short-circuit

0 commit comments

Comments
 (0)