File tree 2 files changed +18
-2
lines changed
compiler/src/dotty/tools/dotc/core 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -264,9 +264,13 @@ object Types {
264
264
// If the type is `T | Null` or `T | Nothing`, the class is != Nothing,
265
265
// and `T` derivesFrom the class, then the OrType derivesFrom the class.
266
266
// Otherwise, we need to check both sides derivesFrom the class.
267
- if tp.tp1.isBottomType && cls != defn.NothingClass then
267
+ def isLowerBottomType (tp : Type ) =
268
+ tp.isBottomType
269
+ && (tp.hasClassSymbol(defn.NothingClass )
270
+ || cls != defn.NothingClass && ! cls.isValueClass)
271
+ if isLowerBottomType(tp.tp1) then
268
272
loop(tp.tp2)
269
- else if tp.tp2.isBottomType && cls != defn. NothingClass then
273
+ else if isLowerBottomType( tp.tp2) then
270
274
loop(tp.tp1)
271
275
else
272
276
loop(tp.tp1) && loop(tp.tp2)
Original file line number Diff line number Diff line change
1
+ object Test :
2
+ val x : Int = 0
3
+ val y : Int | Null = x // during erasure, x is boxed here, and Int | Null becomes Object
4
+ val z0 : Int = identity(y) // error
5
+ val z1 : Int = identity[Int | Null ](y) // error
6
+ val z2 : Int = y // error
7
+
8
+ class StrWrapper (x : String ) extends AnyVal
9
+ val z3 : StrWrapper = null // error
10
+ val z4 : O .T = null // error
11
+ object O :
12
+ opaque type T = String
You can’t perform that action at this time.
0 commit comments