intellij-scala
intellij-scala copied to clipboard
[annotator] support scala 3.4 irrefutable patterns in for-comprehension #SCL-22274 fixed
This fixes false missing withFilters
error for irrefutable patterns in for comprehensions introduced with Scala 3.4 and Scala 3.0 + -source:future
.
Related #SCL-22468
It doesn't address the case where type narrowing occurs (couldn't figure out how to detect type narrowing):
for y :: ys <- List(List(1), List(2)) do println(y)
IntelliJ will not produce an error for Scala 3.4, but compiler will produce this:
pattern's type ::[Int] is more specialized than the right hand side expression's type List[Int]
If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern,
which will result in a filtering for expression (using `withFilter`).
This patch can be rewritten automatically under -rewrite -source 3.2-migration.
for y :: ys <- List(List(1), List(2)) do println(y)
and Scala 3.0+ will produce the same but as a warning.
Please see this part of our guidelines
Every commit message should reference the YouTrack issue number in format #SCL-XXXXX Place primary issue number in the end of the first message line If you have multiple equally-important related issues place them in the end of the first message line If you have some non-primary, but related issues you can reference them in the commit message body. In the last commit of a series which fixes an issue, append #SCL-XXXXX fixed to the end of the first message line issue which is fixed. This will close the YouTrack issues automatically when the change is merged into main branch.
Right now the commit message doesn't mention YT issues. I see the mention in the PR, we can just copy it in the commit itself
Please see this part of our guidelines
Every commit message should reference the YouTrack issue number in format #SCL-XXXXX Place primary issue number in the end of the first message line If you have multiple equally-important related issues place them in the end of the first message line If you have some non-primary, but related issues you can reference them in the commit message body. In the last commit of a series which fixes an issue, append #SCL-XXXXX fixed to the end of the first message line issue which is fixed. This will close the YouTrack issues automatically when the change is merged into main branch.
Right now the commit message doesn't mention YT issues. I see the mention in the PR, we can just copy it in the commit itself
Want me to force update first commit or just touch up the PR title and description? Also, should I mention the 22468, if it will auto close it? I think that narrowing should be addressed as well, to make intellij highlight the error, but maybe in a separate PR.
Want me to force update first commit or just touch up the PR title and description?
Force push to your branch should be ok
Also, should I mention the 22468, if it will auto close it?
You can omit the "fixed" part and just mention the ticket. This is still used by our automation
I think that narrowing should be addressed as well, to make intellij highlight the error, but maybe in a separate PR.
Sounds like a good plan. This issue is less critical compared to irrefutability
Alright, all comments should be addressed now (including first commit messaging).
I restructured test inheritance a bit. Also, changed the check logic for withFilter
requirement as I realized that bulk of tests are run under Scala 2.10
and was not behaving correctly under 3.3
and 3.4
.
Should I do something about it?
One option could be to add @RunWithScalaVersions(Array(...))
on ForComprehensionHighlightingTest
. If so, I guess with versions 2.13
, 3.3
and 3.4
?
Thanks for the contribution! I will manually cherry-pick the changes and run through our internal CI. We might even include it in 2024.1 EAP/Release
Should I do something about it? One option could be to add @RunWithScalaVersions(Array(...)) on ForComprehensionHighlightingTest. If so, I guess with versions 2.13, 3.3 and 3.4?
No, thanks. I will deal with it.