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

Three fixes to SAM type handling #21596

Merged
merged 3 commits into from
Sep 18, 2024
Merged

Three fixes to SAM type handling #21596

merged 3 commits into from
Sep 18, 2024

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 15, 2024

The first two fixes concern characterization of SAM types. One condition of a SAM type is that it can be instantiated with an empty argument list. This was implemented incorrectly. First, we missed the case where the SAM type is a trait with a parent class that takes arguments. In this case the SAM type cannot be instantiated with an empty argument list. Second, we missed the case where the SAM type constructor has a single vararg parameter. In this case the SAM type can be instantiated with an empty argument list.

The second case was also translated incorrectly which led to illegal bytecodes.

Fixes #15855

The first two fixes concern characterization of SAM types. One condition of a SAM
type is that it can be instantiated with an empty argument list. This was implemented
incorrectly. First, we missed the case where the SAM type is a trait with a parent
class that takes arguments. In this case the SAM type _cannot_ be instantiated with an
empty argument list. Second, we missed the case where the SAM type constructor has a
single vararg parameter. In this case the SAM type _can_ be instantiated with an empty
argument list.

The second case was also translated incorrectly which led to illegal bytecodes.

Fixes scala#15855
Fix SAM test to use the same scheme as SAM expansion to determine whether
a type needs zero arguments for construction.
Copy link
Member

@KacperFKorban KacperFKorban left a comment

Choose a reason for hiding this comment

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

Looks good!

@odersky odersky merged commit 9bf82f9 into scala:main Sep 18, 2024
28 checks passed
@odersky odersky deleted the fix-15855 branch September 18, 2024 07:54
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.

Compiler crashes in ExpandSAMs phase
2 participants