-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refine the type of inline vals with literal rhs #24472
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
base: main
Are you sure you want to change the base?
Conversation
6713020 to
1de787a
Compare
1de787a to
d7fcea3
Compare
|
@sjrd do you think that would require a SIP? |
At least a minor release. |
|
It definitely needs a minor release. In theory this is SIP material ... but IMO the SIP process is way too heavy for this. Let's add it to the next agenda, and hopefully there will be quick consensus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we have just reused the tracked system?
Nevermind, but I think it's worth checking the interactions between the two.
I added a test that checks that: https://github.com/dotty-staging/dotty/blob/345fcba592e8e9e276fc0cbcd4396682cb8739e7/tests/neg/inline-tracked-val.scala ✅ |
|
Not sure we have tests for these:
|
|
Possible alternative: add the inline val x = 4.toBytewould thus be |
|
The problem is that |
There is a test in inline val a = 1 : Int // errorShould it pass? I guess it comes back to how powerful the constant-folding of the right-hand side should be. In #24431, I improved constant-folding for Note: this mechanism works on typed trees only, and we would need to adapt the untyped version for when there is an explicit ascription (#24321 (comment)), such as in: inline val a: Int = 1 : Int
It is, I added a test. |
|
Half of the time I want wrapping to be able to write |
83ff0ff to
f6cd021
Compare
|
Note from core meeting of 26.11.2025:
|
Closes #24321.
This PR changes the type of
inline vals to be the exact type of the right-hand side if it is a literal, such that in following snippet,xwould have type(4: Int):Previously, it would not compile: