Skip to content

Commit f1d2e56

Browse files
oderskyWojciechMazur
authored andcommitted
Make isExactlyNothing and isExactlyAny work for And/OrTypes
Might fix #24013. [Cherry-picked 2fa9003]
1 parent 1ba2688 commit f1d2e56

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,21 @@ object Types extends TypeUtils {
244244
def isExactlyNothing(using Context): Boolean = this match {
245245
case tp: TypeRef =>
246246
tp.name == tpnme.Nothing && (tp.symbol eq defn.NothingClass)
247+
case AndType(tp1, tp2) =>
248+
tp1.isExactlyNothing || tp2.isExactlyNothing
249+
case OrType(tp1, tp2) =>
250+
tp1.isExactlyNothing && tp2.isExactlyNothing
247251
case _ => false
248252
}
249253

250254
/** Is this type exactly Any (no vars, aliases, refinements etc allowed)? */
251255
def isExactlyAny(using Context): Boolean = this match {
252256
case tp: TypeRef =>
253257
tp.name == tpnme.Any && (tp.symbol eq defn.AnyClass)
258+
case AndType(tp1, tp2) =>
259+
tp1.isExactlyAny && tp2.isExactlyAny
260+
case OrType(tp1, tp2) =>
261+
tp1.isExactlyAny || tp2.isExactlyAny
254262
case _ => false
255263
}
256264

0 commit comments

Comments
 (0)