-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Irrefutable for generators don't require withFilter
under -source:future
#15593
Conversation
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.
Edit: ignore
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.
Approving, then the future
behaviour should become the standard in 3.3
.
I was a bit confused originally due to the warning messages for refutable patterns, for example, in 3.2.0-RC1
(and source 3.2
) the warning for a refutable pattern suggests that withFilter
is going to be added only with case
, which implies that for a irrefutable pattern there would be no withFilter
:
scala> for (x, y) <- List(('a', 23): Tuple) yield (y, x)
1 warning found
-- Warning: --------------------------------------------------------------------
1 |for (x, y) <- List(('a', 23): Tuple) yield (y, x)
| ^^^^^^
|pattern's type (Any, Any) is more specialized than the right hand side expression's type Tuple
|
|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`).
val res0: List[(Any, Any)] = List((23,a))
perhaps the warning message should be slightly different for 3.2
to make it clear it is always filtering.
@griggt and @bishabosha , will this become the standard in 3.3? Currently on 3.3.0-RC2, tuple decomposition is still failing when using cats effect. So the below would fail with a val someIOOp: IO[(Int, String)] = ???
for {
(num, str) <- someIOOp
} yield () |
Not currently, the PR for that was stuck in porting the community build. Is there an issue for this tuple decomposition bug? |
@bishabosha , see here |
Fixes #15579