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
0 commit comments