Skip to content

Partial function synthesis changesOwner of selector #23337

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

Merged
merged 2 commits into from
Jun 12, 2025

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Jun 9, 2025

The selector expression may be non-trivial.

Fixes #23054
Fixes #23025
Fixes #23310

The fix is the small refactor to matchExpr.changeOwner where previously only the cases were included.

Another small refactor addresses an unused var.

There is a mild attempt to remedy the missing spec verbiage via a kind of post-script intended to suggest that it is a mere relaxation of the existing mechanism.

@som-snytt som-snytt force-pushed the issue/23054-pf-crash branch from dd2d3cc to 5d8f123 Compare June 9, 2025 21:38
@som-snytt som-snytt marked this pull request as ready for review June 10, 2025 00:43
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

LGTM. I just had this one nitpick.

@@ -6032,19 +6032,18 @@ object Types extends TypeUtils {
end samParent

def samClass(tp: Type)(using Context): Symbol = tp match
case tp: ClassInfo =>
val cls = tp.cls
case tp @ ClassInfo(_, cls, _, _, _) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I much prefer the previous tp: ClassInfo to this see of underscores.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not disagree. I grepped for similar usages so I conceded.

compiler/src/dotty/tools/dotc/core/TypeComparer.scala:      case ClassInfo(_, cls, _, _, _) => cls.showLocated

I've forgotten whether I'm allowed to case ClassInfo(cls = cls) yet. I guess not. They say the chef is the last to eat, and it's the same with compiler features.

The selector expression may be non-trivial.
One would like to write
```
case tp @ ClassInfo(cls = cls) =>
```
@som-snytt som-snytt force-pushed the issue/23054-pf-crash branch from 5d8f123 to 25af420 Compare June 10, 2025 15:39
@som-snytt som-snytt merged commit 841a676 into scala:main Jun 12, 2025
29 checks passed
@som-snytt som-snytt deleted the issue/23054-pf-crash branch June 12, 2025 15:28
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 crash when chaining two matches Bad owner of anonymous function after expandSAMs IllegalArgumentException: Could not find proxy
2 participants