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
Due to the `this` pointer being passed to `start.setRun` in a function
called during initialization, the initialization checker cannot prove
that `this` is fully initialized.
We would get the following error:
```
[error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/Run.scala:84:17
[error] 84 | start.setRun(this)
[error] | ^^^^
[error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. Calling trace:
[error] | -> val run = new Run(this, initCtx) { [ ReplCompiler.scala:42 ]
[error] | -> class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with ConstraintRunInfo {iler-b[ Run.scala:38 ]
[error] | -> private var myCtx = rootContext(using ictx) [ Run.scala:89 ]
[error] | -> val rootCtx = super.rootContext.fresh [ ReplCompiler.scala:62 ]
```
The call to `start.setRun` stores the reference to `this` in a
store without accessing any of its fields.
The instance of `Run` referrred to by `this` will be fully
initialized immediately after that function call.
Thus, we are able to safely mark `this` as `@unchecked` without worrying
about uninitialized members of the `Run` instance being accessed.
Review by @liufengyun
if ctx.settings.YexplicitNulls.value &&!Feature.enabledBySetting(nme.unsafeNulls) then
362
+
start = start.addMode(Mode.SafeNulls)
363
+
ctx.initialize()(using start) // re-initialize the base context with start
364
+
365
+
// `this` must be unchecked for safe initialization because by being passed to setRun during initialization, it is not yet considered fully initialized by the initialization checker
0 commit comments