Skip to content

Commit 75c612c

Browse files
committed
doc(explicit-nulls): typos
1 parent 2dd1c93 commit 75c612c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/docs/reference/other-new-features/explicit-nulls.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ More details can be found in [safe initialization](./safe-initialization.md).
5151
## Equality
5252

5353
We don't allow the double-equal (`==` and `!=`) and reference (`eq` and `ne`) comparison between
54-
`AnyRef` and `Null` anymore, since a variable with non-nullable type shouldn't have null 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

57-
For some reason, if we really want to compare `null` with non-null values, we can use cast.
57+
For some reason, if we really want to compare `null` with non-null values, we have to provide a type hint (e.g. `: Any`).
5858

5959
```scala
6060
val x: String = ???
6161
val 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

6767
y == null // ok
6868
y == x // ok
@@ -174,7 +174,7 @@ Specifically, we patch
174174
}
175175
```
176176

177-
In this case, since `Box` is Scala-defined, and we will get `Box[T|UncheckedNull]|UncheckedNull`.
177+
In this case, since `Box` is Scala-defined, we will get `Box[T|UncheckedNull]|UncheckedNull`.
178178
This is needed because our nullability function is only applied (modularly) to the Java
179179
classes, but not to the Scala ones, so we need a way to tell `Box` that it contains a
180180
nullable value.
@@ -204,7 +204,7 @@ Specifically, we patch
204204
}
205205
```
206206

207-
* We don't append `UncheckedNull` to a field and the return type of a method which is annotated with a
207+
* We don't append `UncheckedNull` to a field nor to a return type of a method which is annotated with a
208208
`NotNull` annotation.
209209

210210
```java
@@ -288,7 +288,7 @@ val s2 = if (ret != null) {
288288

289289
We added a simple form of flow-sensitive type inference. The idea is that if `p` is a
290290
stable path or a trackable variable, then we can know that `p` is non-null if it's compared
291-
with the `null`. This information can then be propagated to the `then` and `else` branches
291+
with `null`. This information can then be propagated to the `then` and `else` branches
292292
of an if-statement (among other places).
293293

294294
Example:
@@ -401,7 +401,7 @@ When dealing with local mutable variables, there are two questions:
401401
x = null
402402
}
403403
if (x != null) {
404-
// y can be called here, which break the fact
404+
// y can be called here, which would break the fact
405405
val a: String = x // error: x is captured and mutated by the closure, not trackable
406406
}
407407
```

0 commit comments

Comments
 (0)