Skip to content

Commit 94b8a7d

Browse files
committed
Fix #8084: Fix atoms computation
The `isStable` test was at the wrong place.
1 parent 51b1f2c commit 94b8a7d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ object Types {
11581158
* Overridden and cached in OrType.
11591159
*/
11601160
def atoms(implicit ctx: Context): Set[Type] = dealias match {
1161-
case tp: SingletonType if tp.isStable =>
1161+
case tp: SingletonType =>
11621162
def normalize(tp: Type): Type = tp match {
11631163
case tp: SingletonType =>
11641164
tp.underlying.dealias match {
@@ -1172,7 +1172,7 @@ object Types {
11721172
case _ => tp
11731173
}
11741174
val underlyingAtoms = tp.underlying.atoms
1175-
if (underlyingAtoms.isEmpty) Set.empty + normalize(tp)
1175+
if (underlyingAtoms.isEmpty && tp.isStable) Set.empty + normalize(tp)
11761176
else underlyingAtoms
11771177
case tp: ExprType => tp.resType.atoms
11781178
case tp: OrType => tp.atoms // `atoms` overridden in OrType

tests/pos/i8084.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Z
2+
class O
3+
object Test0 {
4+
def foo(x: Z | O) = ()
5+
def bar: Z | O = O()
6+
foo(bar)
7+
}
8+
9+
object Test {
10+
def foo(x: 0 | 1) = ()
11+
def bar: 0 | 1 = 0
12+
foo(bar)
13+
}
14+

0 commit comments

Comments
 (0)