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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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

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 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.

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