File tree Expand file tree Collapse file tree 3 files changed +4
-5
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ object Types {
248
248
case _ => NoType
249
249
}
250
250
251
- /** Is this type a (possibly aliased or intersected ) singleton type? */
251
+ /** Is this type a (possibly aliased) singleton type? */
252
252
def isSingleton (implicit ctx : Context ) = SingletonType .unapply(this ).isDefined
253
253
254
254
/** Is this type guaranteed not to have `null` as a value? */
@@ -1501,11 +1501,10 @@ object Types {
1501
1501
}
1502
1502
1503
1503
/** An extractor that returns the underlying singleton type of a
1504
- * (possibly annotated, aliased, or intersected ) type
1504
+ * (possibly annotated or aliased ) type
1505
1505
*/
1506
1506
object SingletonType {
1507
1507
def unapply (tp : Type )(implicit ctx : Context ): Option [SingletonType ] = tp.dealias match {
1508
- case AndType (tp1, tp2) => unapply(tp1).orElse(unapply(tp2))
1509
1508
case tp : SingletonType => Some (tp)
1510
1509
case _ => None
1511
1510
}
Original file line number Diff line number Diff line change @@ -2,5 +2,5 @@ object C {
2
2
trait X [T ]
3
3
implicit def u [A , B ]: X [A | B ] = new X [A | B ] {}
4
4
def y [T ](implicit x : X [T ]): T = ???
5
- val x : 1 & 2 | 2 & 3 = y // error: singleton is not allowed in a union type
5
+ val x : 1 & 2 | 2 & 3 = y
6
6
}
Original file line number Diff line number Diff line change @@ -6,5 +6,5 @@ object C {
6
6
trait X [T ]
7
7
implicit def u [A , B ]: X [A | B ] = new X [A | B ] {}
8
8
def y [T ](implicit x : X [T ]): T = ???
9
- // val x: a.type & b.type | b.type & c.type = y // no longer allowed, singletons cannot be in union types
9
+ val x : a.type & b.type | b.type & c.type = y // no longer allowed, singletons cannot be in union types
10
10
}
You can’t perform that action at this time.
0 commit comments