Skip to content

Fix constant conversion to singleton types #12212

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
Apr 26, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 25, 2021

Fixes #12208

else if (target == defn.FloatClass && isFloatRange)
Constant(floatValue)
else if (target == defn.DoubleClass && isNumeric)
Constant(doubleValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

In a series of if p && q then where the ps are mutually exclusive, preferable to

expr match p => if q then res else default

Noticed the similar pattern in constant folding. Maybe nbd for 7 tests. My question would be what should my fingers type automatically for this pattern.

It could optimize eq as exclusive but maybe not ==.

@nicolasstucki nicolasstucki merged commit b65c675 into scala:master Apr 26, 2021
@nicolasstucki nicolasstucki deleted the fix-12208 branch April 26, 2021 12:50
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
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.

Literal singleton type accepting wrong value
4 participants