File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -1157,7 +1157,7 @@ object Types {
1157
1157
* these types as a set, otherwise the empty set.
1158
1158
* Overridden and cached in OrType.
1159
1159
* @param widenOK If type proxies that are upperbounded by types with atoms
1160
- * have the same atoms.
1160
+ * have the same atoms.
1161
1161
*/
1162
1162
def atoms (widenOK : Boolean = false )(implicit ctx : Context ): Set [Type ] = dealias match {
1163
1163
case tp : SingletonType =>
@@ -1174,8 +1174,9 @@ object Types {
1174
1174
case _ => tp
1175
1175
}
1176
1176
val underlyingAtoms = tp.underlying.atoms(widenOK)
1177
- if (underlyingAtoms.isEmpty && tp.isStable) Set .empty + normalize(tp)
1178
- else underlyingAtoms
1177
+ if underlyingAtoms.isEmpty && tp.isStable then Set .empty + normalize(tp)
1178
+ else if underlyingAtoms.size == 1 || widenOK then underlyingAtoms
1179
+ else Set .empty
1179
1180
case tp : ExprType => tp.resType.atoms(widenOK)
1180
1181
case tp : OrType => tp.atoms(widenOK) // `atoms` overridden in OrType
1181
1182
case tp : AndType => tp.tp1.atoms(widenOK) & tp.tp2.atoms(widenOK)
Original file line number Diff line number Diff line change 1
1
object Test {
2
- def id : (x : 1 | 0 ) => x.type = x => x
3
- id(0 ): 0 // fails
2
+ def id : (x : 1 | 0 ) => x.type = ???
3
+ id(0 ): 0 // ok
4
4
5
5
def id2 : Function1 [1 | 0 , 1 | 0 ] {
6
6
def apply (x : 1 | 0 ): x.type
7
7
} = ???
8
- id2(0 ): 0 // fails
8
+ id2(0 ): 0 // ok
9
9
10
10
def id3 : Function1 [1 | 0 , Int ] {
11
11
def apply (x : 1 | 0 ): x.type
You can’t perform that action at this time.
0 commit comments