File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -48,22 +48,21 @@ object DottyPredef {
48
48
*
49
49
* Note that `.nn` performs a checked cast, so if invoked on a null value it'll throw an NPE.
50
50
*/
51
- def [T ] (x : T | Null ) nn : T =
51
+ def [T ] (x : T | Null ) nn : x. type & T =
52
52
if (x == null ) throw new NullPointerException (" tried to cast away nullability, but value is null" )
53
- else x.asInstanceOf [T ]
53
+ else x.asInstanceOf [x. type & T ]
54
54
55
55
/** Reference equality where the receiver is a nullable union.
56
56
* Note that if the receiver `r` is a reference type (e.g. `String`), then `r.eq` will invoke the
57
57
* `eq` method in `AnyRef`.
58
58
*/
59
59
def (x : AnyRef | Null ) eq(y : AnyRef | Null ): Boolean =
60
- (x == null && y == null ) || (x != null && x.eq(y))
60
+ x. asInstanceOf [ AnyRef ] eq y. asInstanceOf [ AnyRef ]
61
61
62
62
/** Reference disequality where the receiver is a nullable union.
63
63
* Note that if the receiver `r` is a reference type (e.g. `String`), then `r.ne` will invoke the
64
64
* `ne` method in `AnyRef`.
65
65
*/
66
66
def (x : AnyRef | Null ) ne(y : AnyRef | Null ): Boolean =
67
- (x == null && y != null ) || (x != null && x.ne(y))
68
-
67
+ x.asInstanceOf [AnyRef ] ne y.asInstanceOf [AnyRef ]
69
68
}
You can’t perform that action at this time.
0 commit comments