Skip to content

Conversation

@sjrd
Copy link
Member

@sjrd sjrd commented Jan 13, 2025

And then make the whole thing much more generic, so that we will be more robust against further tweaks to nsc's codegen.


Based on #5113, but otherwise ready to review. The last commit is best reviewed with the "Hide whitespace" option.

@sjrd sjrd requested a review from gzm0 January 13, 2025 13:11
sjrd added 3 commits January 15, 2025 19:13
Under 4 cases, some versions of the compiler do not emit a switch
match. That defeats the purpose of that test.
That shape gets produced by Scala 2.13.16+ in some cases.
Previously, we had to recognize specific shapes of case bodies in
order to extract jumps to default labels. This was fragile, as
changes in nsc's codegen could invalidate our assumptions.

We now take a more general approach. We register the default label
in the `enclosingLabelDefInfos`. Jumps to that label can therefore
be handled wherever they appear inside the case bodies.

We still require a specific shape to extract the *definition* of
the default label in the wildcard case. This can't be helped, as
far as I can tell.

Ultimately, the JS code generated for the test suites is unchanged,
both in 2.12 and 2.13.
@sjrd sjrd force-pushed the fix-switch-match-guard-bug-2.13.16 branch from 1ad74c8 to ee3e9a0 Compare January 15, 2025 18:13
Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

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

Nice!

@sjrd sjrd merged commit b8c3f06 into scala-js:main Jan 16, 2025
3 checks passed
@sjrd sjrd deleted the fix-switch-match-guard-bug-2.13.16 branch January 16, 2025 04:36
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.

2 participants