Skip to content
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

Handle TupleXXL in match analysis #19212

Merged
merged 3 commits into from
Dec 7, 2023
Merged

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Dec 6, 2023

There's a number of problems with the match analysis of TupleXXL.
Of course, they manifest as (in)exhaustivity and (un)reachability
warnings.

Reachability suffered by the problem that a large generic tuple
scrutinee type wasn't considered extractable by the TupleXXL extractor
that Typer associates the extractor pattern with. That was solved by
special handling in SpaceEngine's isSubType.

Exhaustivity suffered by a variety of problems, again stemming from the
disconnect between the TupleXXL pattern type and the large generic tuple
scrutinee (or component) type. That was solved by special handling in
exhaustivityCheckable to ignore large generic tuple scrutinees.

That then highlighted an irrefutable failure (checkIrrefutable), which
also needed to be taught that extra large generic tuples do conform to
TupleXXL extractors type, after which SpaceEngine isIrrefutable needed
special handling to consider TupleXXL irrefutable.

There's a number of problems with the match analysis of TupleXXL.
Of course, they manifest as (in)exhaustivity and (un)reachability
warnings.

Reachability suffered by the problem that a large generic tuple
scrutinee type wasn't considered extractable by the TupleXXL extractor
that Typer associates the extractor pattern with.  That was solved by
special handling in SpaceEngine's isSubType.

Exhaustivity suffered by a variety of problems, again stemming from the
disconnect between the TupleXXL pattern type and the large generic tuple
scrutinee (or component) type.  That was solved by special handling in
exhaustivityCheckable to ignore large generic tuple scrutinees.

That then highlighted an irrefutable failure (checkIrrefutable), which
also needed to be taught that extra large generic tuples do conform to
TupleXXL extractors type, afterwhich SpaceEngine isIrrefutable needed
special handling to consider TuplXXL irrefutable.
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

If I understand correctly this turns off exhaustivity checking for TupleXXL but keeps reachability checking, right? In that case, could you add a test case where we detect an unreachable case?

@smarter smarter assigned dwijnand and unassigned smarter Dec 6, 2023
@smarter smarter enabled auto-merge December 7, 2023 12:35
@dwijnand
Copy link
Member Author

dwijnand commented Dec 7, 2023

I went back down the rabbit hole trying to get a sense of what changes are required, and there are so many different parts and I can't tell which behaviour needs changing, particularly because I rarely spend time on unapplySeq fixes.

@smarter smarter merged commit ee2b74d into scala:main Dec 7, 2023
16 checks passed
@odersky
Copy link
Contributor

odersky commented Dec 7, 2023

Great that this could be fixed!

@dwijnand dwijnand deleted the match-analyse-tuplexxl branch December 7, 2023 14:36
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
WojciechMazur added a commit that referenced this pull request Jun 26, 2024
Backports #19212 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants