File tree 2 files changed +25
-1
lines changed
src/dotty/tools/dotc/core
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -777,8 +777,13 @@ class TypeComparer(initctx: Context) extends DotClass {
777
777
case TypeBounds (lo1, hi1) =>
778
778
isSubType(hi1, tp2)
779
779
case _ =>
780
+ def isNullable (tp : Type ): Boolean = tp.dealias match {
781
+ case tp : TypeRef => tp.symbol.isNullableClass
782
+ case RefinedType (parent, _) => isNullable(parent)
783
+ case _ => false
784
+ }
780
785
(tp1.symbol eq NothingClass ) && tp2.isInstanceOf [ValueType ] ||
781
- (tp1.symbol eq NullClass ) && tp2.dealias.typeSymbol.isNullableClass
786
+ (tp1.symbol eq NullClass ) && isNullable( tp2)
782
787
}
783
788
case tp1 : SingletonType =>
784
789
isNewSubType(tp1.underlying.widenExpr, tp2) || {
Original file line number Diff line number Diff line change
1
+ object O {
2
+ // This compiles
3
+ val a : { type T } = null ;
4
+ val b : Any { type T } = null ;
5
+
6
+ // This doesn't:
7
+ // found : Null
8
+ // required: AnyRef{T}
9
+ val c : AnyRef { type T } = null ;
10
+
11
+ class A
12
+ class B
13
+
14
+ val d : A & B = null
15
+ val e : A | B = null
16
+
17
+ val f : (A & B ) { def toString : String } = null
18
+ val g : (A | B ) { def toString : String } = null
19
+ }
You can’t perform that action at this time.
0 commit comments