Skip to content

Preserve pattern, use tuple type when optimizing#25566

Merged
som-snytt merged 2 commits into
scala:mainfrom
som-snytt:issue/25547-flattened-tuple
Mar 20, 2026
Merged

Preserve pattern, use tuple type when optimizing#25566
som-snytt merged 2 commits into
scala:mainfrom
som-snytt:issue/25547-flattened-tuple

Conversation

@som-snytt

Copy link
Copy Markdown
Contributor

Fixes #25547

Supply the tuple type for the temp val only if optimizing.

Always use the pattern for the MatchableTuple optimization, for the correct tuple type.

@som-snytt
som-snytt force-pushed the issue/25547-flattened-tuple branch from 1c1ed7b to 00e2ab5 Compare March 19, 2026 03:19
@som-snytt
som-snytt force-pushed the issue/25547-flattened-tuple branch from 00e2ab5 to e4f8ca7 Compare March 19, 2026 14:22
@som-snytt
som-snytt marked this pull request as ready for review March 19, 2026 21:14
@som-snytt
som-snytt requested a review from SolalPirelli March 19, 2026 21:14

@SolalPirelli SolalPirelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. I'm not really sure why the wildcard stuff was there in the first place.

@som-snytt
som-snytt merged commit e81f069 into scala:main Mar 20, 2026
64 checks passed
@som-snytt
som-snytt deleted the issue/25547-flattened-tuple branch March 20, 2026 15:07
@WojciechMazur WojciechMazur added this to the 3.8.4 milestone Mar 31, 2026
SolalPirelli pushed a commit that referenced this pull request Apr 5, 2026
Fixes #25700 

## How much have you relied on LLM-based tools in this contribution?

But can one _rely_ on LLM-based tools?

## How was the solution tested?

Apparently, there was not a test for val def with stable identifier
pattern. The ticket minimization supplies it. Edit: a previous test was
erroring incorrectly but flew under the radar. Its correct error is
restored.

## Additional notes

Follow-up to #25566 that tweaked
#24972.

Obviously, a pattern variable must be `isVarPattern`, but the degrees of
freedom are lowercase, underscore, and backquoted.

The code comment, that "royal we" want wildcards, suggests our bases are
not covered. `IdPattern` is for parsing and would not be useful here.
But how do I ask whether I'm looking at a patvar? There is an
attachment. Are we too early or late for it?

"One does not simply ask if an identifier is a pattern variable."
WojciechMazur pushed a commit that referenced this pull request Apr 18, 2026
Fixes #25700 

## How much have you relied on LLM-based tools in this contribution?

But can one _rely_ on LLM-based tools?

## How was the solution tested?

Apparently, there was not a test for val def with stable identifier
pattern. The ticket minimization supplies it. Edit: a previous test was
erroring incorrectly but flew under the radar. Its correct error is
restored.

## Additional notes

Follow-up to #25566 that tweaked
#24972.

Obviously, a pattern variable must be `isVarPattern`, but the degrees of
freedom are lowercase, underscore, and backquoted.

The code comment, that "royal we" want wildcards, suggests our bases are
not covered. `IdPattern` is for parsing and would not be useful here.
But how do I ask whether I'm looking at a patvar? There is an
attachment. Are we too early or late for it?

"One does not simply ask if an identifier is a pattern variable."
[Cherry-picked 2c668b5]
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.

Typer regression: Accidental flattening of the tuple type

4 participants