Skip to content

Commit 06bd2d4

Browse files
authored
Merge pull request #610 from scala/backport-lts-3.3-24016
Backport "Make isExactlyNothing and isExactlyAny work for And/OrTypes" to 3.3 LTS
2 parents 87e6159 + 51be5b8 commit 06bd2d4

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
@@ -243,13 +243,21 @@ object Types extends TypeUtils {
243243
def isExactlyNothing(using Context): Boolean = this match {
244244
case tp: TypeRef =>
245245
tp.name == tpnme.Nothing && (tp.symbol eq defn.NothingClass)
246+
case AndType(tp1, tp2) =>
247+
tp1.isExactlyNothing || tp2.isExactlyNothing
248+
case OrType(tp1, tp2) =>
249+
tp1.isExactlyNothing && tp2.isExactlyNothing
246250
case _ => false
247251
}
248252

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

0 commit comments

Comments
 (0)