Skip to content

Reposition assertion to respect safe initialization #14466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2022

Conversation

Xavientois
Copy link
Contributor

Passing this to assert before object members are fully initialized
does not pass safe init check:

[error] -- Error: library/src/scala/runtime/stdLibPatches/Predef.scala:7:64 ------------
[error] 7 |    if !assertion then scala.runtime.Scala3RunTime.assertFailed(message)
[error]   |                                                                ^^^^^^^
[error]   |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments.

This change fixes the above error.

Review by @liufengyun

Passing `this` to `assert` before object members are fully initialized
does not pass safe init check:
```
[error] -- Error: library/src/scala/runtime/stdLibPatches/Predef.scala:7:64 ------------
[error] 7 |    if !assertion then scala.runtime.Scala3RunTime.assertFailed(message)
[error]   |                                                                ^^^^^^^
[error]   |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments.
```

This change fixes the above error.

Review by @liufengyun
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@dwijnand dwijnand merged commit bbe74ce into scala:main Feb 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants