Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix constToLiteral #14853

Merged
merged 2 commits into from
Apr 6, 2022
Merged

Fix constToLiteral #14853

merged 2 commits into from
Apr 6, 2022

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 5, 2022

We previously converted an expression with constant type to a literal if
the expression was idempotent. This can hide side effects in the case where
the expression is a selection from an object or lazy val. Demanding purity
instead prodcues tons of errors involving inline vals on objects.

We now demand idempotency if the expression refers to an inline val (or
an operation over an inline val), and purity elsewhere.

Fixes #2266

odersky added 2 commits April 5, 2022 14:52
We previously converted an expression with constant type to a literal if
the expression was idempotent. This can hide side effects in the case where
the expression is a selection from an object or lazy val. Demanding purity
instead prodcues tons of errors involving inline vals on objects.

We now demand idempotency if the expression refers to an inline val (or
an operation over an inline val), and purity elsewhere.

Fixes scala#2266
@bishabosha bishabosha merged commit 8d3083b into scala:main Apr 6, 2022
@bishabosha bishabosha deleted the fix-2266 branch April 6, 2022 10:26
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 1, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lazy val with constant type loses side effects.
3 participants