File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -264,9 +264,13 @@ object Types {
264264 // If the type is `T | Null` or `T | Nothing`, the class is != Nothing,
265265 // and `T` derivesFrom the class, then the OrType derivesFrom the class.
266266 // 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
268272 loop(tp.tp2)
269- else if tp.tp2.isBottomType && cls != defn. NothingClass then
273+ else if isLowerBottomType( tp.tp2) then
270274 loop(tp.tp1)
271275 else
272276 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