Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
compareTypeLambda
case OrType(tp21, tp22) =>
if (tp2.atoms.nonEmpty && canCompare(tp2.atoms))
return tp1.atoms.nonEmpty && tp1.atoms.subsetOf(tp2.atoms) ||
tp1.isRef(NothingClass)
return tp1.atoms.nonEmpty && tp1.atoms.subsetOf(tp2.atoms) || isSubType(tp1, NothingType)

// The next clause handles a situation like the one encountered in i2745.scala.
// We have:
Expand Down
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,11 @@ object Types {
}
case _ => tp
}
Set.empty + normalize(tp)
case tp: OrType => tp.atoms
val underlyingAtoms = tp.underlying.atoms
if (underlyingAtoms.isEmpty) Set.empty + normalize(tp)
else underlyingAtoms
case tp: ExprType => tp.resType.atoms
case tp: OrType => tp.atoms // `atoms` overridden in OrType
case tp: AndType => tp.tp1.atoms & tp.tp2.atoms
case _ => Set.empty
}
Expand Down
13 changes: 13 additions & 0 deletions tests/pos/singlesubtypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
object E {
val a: String = ???
val b: String = ???
}

object Test {

val a: E.a.type = E.a
val b: E.b.type = E.b

val c: a.type | b.type = ???
val d: a.type | b.type = c
}