Skip to content

Commit 435397f

Browse files
Merge pull request #8481 from dotty-staging/fix-7881
Fix #7881: fix example and add link to -Ycheck-init
2 parents 0b4871d + e7ea787 commit 435397f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ The unsoundness happens because uninitialized fields in a class start out as `nu
3939
```scala
4040
class C {
4141
val f: String = foo(f)
42-
def foo(f2: String): String = if (f2 == null) "field is null" else f2
42+
def foo(f2: String): String = f2
4343
}
4444
val c = new C()
4545
// c.f == "field is null"
4646
```
4747

48-
Enforcing sound initialization is a non-goal of this proposal. However, once we have a type
49-
system where nullability is explicit, we can use a sound initialization scheme like the one
50-
proposed by @liufengyun and @biboudis in [https://github.com/lampepfl/dotty/pull/4543](https://github.com/lampepfl/dotty/pull/4543) to eliminate this particular source of unsoundness.
48+
The unsoundness above can be caught by the compiler with the option `-Ycheck-init`.
49+
More details can be found in [safe initialization](./safe-initializaion.md).
5150

5251
## Equality
5352

0 commit comments

Comments
 (0)