Skip to content

Fix #8084: Fix atoms computation #8126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2020
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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ object Types {
* Overridden and cached in OrType.
*/
def atoms(implicit ctx: Context): Set[Type] = dealias match {
case tp: SingletonType if tp.isStable =>
case tp: SingletonType =>
def normalize(tp: Type): Type = tp match {
case tp: SingletonType =>
tp.underlying.dealias match {
Expand All @@ -1172,7 +1172,7 @@ object Types {
case _ => tp
}
val underlyingAtoms = tp.underlying.atoms
if (underlyingAtoms.isEmpty) Set.empty + normalize(tp)
if (underlyingAtoms.isEmpty && tp.isStable) Set.empty + normalize(tp)
else underlyingAtoms
case tp: ExprType => tp.resType.atoms
case tp: OrType => tp.atoms // `atoms` overridden in OrType
Expand Down
14 changes: 14 additions & 0 deletions tests/pos/i8084.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Z
class O
object Test0 {
def foo(x: Z | O) = ()
def bar: Z | O = O()
foo(bar)
}

object Test {
def foo(x: 0 | 1) = ()
def bar: 0 | 1 = 0
foo(bar)
}