We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d02c7c2 commit c2775b0Copy full SHA for c2775b0
compiler/src/dotty/tools/package.scala
@@ -54,4 +54,16 @@ package object tools {
54
55
def unreachable(x: Any = "<< this case was declared unreachable >>"): Nothing =
56
throw new MatchError(x)
57
+
58
+ /** Marker for `var`s that are initialized to `null`, but cannot be assigned `null` after initialization.
59
+ * @example {{{
60
+ * var cache: String | Uninitialized = initiallyNull
61
+ * def readCache: String =
62
+ * if(cache == null) cache = "hello"
63
+ * cache
64
+ * }}}
65
+ */
66
+ type Uninitialized <: Null
67
+ /** Initializer for `var`s of type `Uninitialized` */
68
+ val initiallyNull = null.asInstanceOf[Uninitialized]
69
}
0 commit comments