Skip to content

Conversation

@Xavientois
Copy link
Contributor

Closes #14465

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 ] 

This sets the store after myCtx is set in order to address this error.

Review by @liufengyun

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 ] ``` This sets the store after `myCtx` is set in order to address this error. Review by @liufengyun
if ctx.settings.YexplicitNulls.value && !Feature.enabledBySetting(nme.unsafeNulls) then
start = start.addMode(Mode.SafeNulls)
ctx.initialize()(using start) // re-initialize the base context with start
start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To pursue this approach, the return type needs to be FreshContext.

That would require changing the overriding method as well, which we might want to avoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried doing that, but it would require more changes than I wanted to make for this, since the overridden method does not return a FreshContext

@Xavientois
Copy link
Contributor Author

Closed due to #14465 (comment)

@Xavientois Xavientois closed this Feb 14, 2022
@Xavientois Xavientois deleted the alternate-setRun-init-check-fix branch February 14, 2022 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants