@@ -11,7 +11,7 @@ This means the following code will no longer typecheck:
1111val x: String = null // error: found `Null`, but required `String`
1212```
1313
14- Instead, to mark a type as nullable we use a [ type union] ( https://dotty.epfl.ch/docs/reference/new-types/union-types.html )
14+ Instead, to mark a type as nullable we use a [ union type ] ( https://dotty.epfl.ch/docs/reference/new-types/union-types.html )
1515
1616```
1717val x: String|Null = null // ok
@@ -51,7 +51,7 @@ More details can be found in [safe initialization](./safe-initialization.md).
5151## Equality
5252
5353We don't allow the double-equal (` == ` and ` != ` ) and reference (` eq ` and ` ne ` ) comparison between
54- ` AnyRef ` and ` Null ` anymore, since a variable with a non-nullable type cannot have null as value.
54+ ` AnyRef ` and ` Null ` anymore, since a variable with a non-nullable type cannot have ` null ` as value.
5555` null ` can only be compared with ` Null ` , nullable union (` T | Null ` ), or ` Any ` type.
5656
5757For some reason, if we really want to compare ` null ` with non-null values, we have to provide a type hint (e.g. ` : Any ` ).
@@ -60,9 +60,9 @@ For some reason, if we really want to compare `null` with non-null values, we ha
6060val x : String = ???
6161val y : String | Null = ???
6262
63- x == null // error: Values of types String and Null cannot be compared with == or !=
64- x eq null // error
65- " hello" == null // error
63+ x == null // error: Values of types String and Null cannot be compared with == or !=
64+ x eq null // error
65+ " hello" == null // error
6666
6767y == null // ok
6868y == x // ok
@@ -87,7 +87,7 @@ So far, we have found the following useful:
8787 This means that given `x: String|Null` , `x.nn` has type `String` , so we can call all the
8888 usual methods on it. Of course, `x.nn` will throw a NPE if `x` is `null`.
8989
90- Don ' t use `.nn` on mutable variables directly, which may introduce unknown value into the type .
90+ Don ' t use `.nn` on mutable variables directly, because it may introduce an unknown type into the type of the variable .
9191
9292## Java Interop
9393
@@ -99,7 +99,7 @@ Specifically, we patch
9999* the type of fields
100100* the argument type and return type of methods
101101
102- `UncheckedNull` is an alias for `Null` with magic properties (see below). We illustrate the rules with following examples :
102+ `UncheckedNull` is an alias for `Null` with magic properties (see [ below]( # uncheckednull) ). We illustrate the rules with following examples :
103103
104104 * The first two rules are easy : we nullify reference types but not value types.
105105
@@ -376,7 +376,7 @@ We are able to detect the nullability of some local mutable variables. A simple
376376class C (val x : Int , val next : C | Null )
377377
378378var xs : C | Null = C (1 , C (2 , null ))
379- // xs is trackable, since all assignments are in the same mathod
379+ // xs is trackable, since all assignments are in the same method
380380while (xs != null ) {
381381 // xs: C
382382 val xsx : Int = xs.x
0 commit comments