Skip to content

Conversation

@EugeneFlesselle
Copy link
Contributor

@EugeneFlesselle EugeneFlesselle commented Feb 5, 2024

Fixes #19576

val z = Seq(0 -> 1, 2 -> 3).lazyZip(Seq("A", "B"))
for case ((beg, end), c) <- z yield c // Ok: a withFilter is inserted before map
for (range, c) <- z yield c           // Ok: exact shape
for ((beg, end), c) <- z yield c      // Error before changes: Wrong number of parameters, expected 2

The issue did not arise a 3.3.1, as a withFilter was always inserted before map, this is no longer the case as the pattern is irrefutable.
Note that the map method of LazyZip2 expects (El1, El2) => B and not ((El1, El2)) => B. This kind of situation was previously already accounted for in the specific case where the pattern is exactly the shape of the function arguments.
Otherwise we can fallback to a less optimised version, using the untupled version of the lambda and keeping the match with the more refined pattern.

@EugeneFlesselle EugeneFlesselle marked this pull request as ready for review February 5, 2024 22:12
@EugeneFlesselle
Copy link
Contributor Author

Related to #14651

@dwijnand dwijnand merged commit 8e2f92a into scala:main Feb 23, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
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.

for yield with nested pattern does not adapt correctly for lazyZip

3 participants