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

Fix enclosingClass from returning refinement classes #21411

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Aug 21, 2024

Looking at how i20952 is compiled, the call

ctx.owner.enclosingClass.derivesFrom(sym.owner)

in SuperAccessors (that I moved to ProtectedAccessors) accidentally
fails, because the refinement class returned as the enclosing class of
val prog doesn't derive from SuperClass. But if the enclosing class
of prog returned is trait Child then no super accessor call is
necessary.

Fixes #20952

@dwijnand dwijnand marked this pull request as ready for review August 21, 2024 21:35
@dwijnand dwijnand requested a review from odersky August 21, 2024 21:36
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.

Yes, that was a footgun.

@odersky odersky assigned dwijnand and unassigned dwijnand and odersky Sep 23, 2024
@odersky
Copy link
Contributor

odersky commented Sep 23, 2024

Needs a rebase.

Looking at how i20952 is compiled, the call

    ctx.owner.enclosingClass.derivesFrom(sym.owner)

in SuperAccessors (that I moved to ProtectedAccessors) accidentally
fails, because the refinement class returned as the enclosing class of
`val prog` doesn't derive from SuperClass.  But if the enclosing class
of `prog` returned is `trait Child` then no super accessor call is
necessary.
@dwijnand dwijnand merged commit 31e7359 into scala:main Oct 23, 2024
26 checks passed
@dwijnand dwijnand deleted the super-diff-pkg branch October 25, 2024 09:21
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.

Refinement with parent trait super call is refused when class is in a different package
2 participants