File tree 1 file changed +16
-0
lines changed
library/src/scala/runtime/stdLibPatches
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
package scala .runtime .stdLibPatches
2
2
3
+ import scala .annotation .experimental
4
+
3
5
object Predef :
4
6
import compiletime .summonFrom
5
7
@@ -47,4 +49,18 @@ object Predef:
47
49
*/
48
50
extension [T ](x : T | Null ) inline def nn : x.type & T =
49
51
scala.runtime.Scala3RunTime .nn(x)
52
+
53
+ /** Marker for `var`s that are initialized to `null`, but cannot be assigned `null` after initialization.
54
+ * @example {{{
55
+ * var cache: String | Uninitialized = initiallyNull
56
+ * def readCache: String =
57
+ * if(cache == null) cache = "hello"
58
+ * cache
59
+ * }}}
60
+ */
61
+ @ experimental
62
+ type Uninitialized <: Null
63
+ /** Initializer for `var`s of type `Uninitialized` */
64
+ @ experimental
65
+ val initiallyNull = null .asInstanceOf [Uninitialized ]
50
66
end Predef
You can’t perform that action at this time.
0 commit comments