You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/reference/other-new-features/explicit-nulls.md
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -39,15 +39,14 @@ The unsoundness happens because uninitialized fields in a class start out as `nu
39
39
```scala
40
40
classC {
41
41
valf:String= foo(f)
42
-
deffoo(f2: String):String=if (f2 ==null) "field is null"elsef2
42
+
deffoo(f2: String):String= f2
43
43
}
44
44
valc=newC()
45
45
// c.f == "field is null"
46
46
```
47
47
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).
0 commit comments