Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,21 @@ object Types extends TypeUtils {
def isExactlyNothing(using Context): Boolean = this match {
case tp: TypeRef =>
tp.name == tpnme.Nothing && (tp.symbol eq defn.NothingClass)
case AndType(tp1, tp2) =>
tp1.isExactlyNothing || tp2.isExactlyNothing
case OrType(tp1, tp2) =>
tp1.isExactlyNothing && tp2.isExactlyNothing
case _ => false
}

/** Is this type exactly Any (no vars, aliases, refinements etc allowed)? */
def isExactlyAny(using Context): Boolean = this match {
case tp: TypeRef =>
tp.name == tpnme.Any && (tp.symbol eq defn.AnyClass)
case AndType(tp1, tp2) =>
tp1.isExactlyAny && tp2.isExactlyAny
case OrType(tp1, tp2) =>
tp1.isExactlyAny || tp2.isExactlyAny
case _ => false
}

Expand Down
Loading