Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e1f2505

Browse files
authored
Make isExactlyNothing and isExactlyAny work for And/OrTypes (#24016)
Might fix #24013.
2 parents 66f8213 + 2fa9003 commit e1f2505

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)

AltStyle によって変換されたページ (->オリジナル) /