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

Drop incorrect super accessor in trait subclass #17062

Merged
merged 4 commits into from
Mar 23, 2023

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Mar 7, 2023

When a trait extends a class and accesses a protected member (while in a
different package), we would emitted a super accessor and call that
instead. That breaks the semantics because if the protected member is
overridden, that implementation won't be called, as the call is to the
super method instead.

In addition to that, the call to the super accessor was causing a false
positive error as we don't allow super calls to bind to vals.

When a trait extends a class and accesses a protected member (while in a
different package), we would emitted a super accessor and call that
instead.  That breaks the semantics because if the protected member is
overridden, that implementation won't be called, as the call is to the
super method instead.

In addition to that, the call to the super accessor was causing a false
positive error as we don't allow super calls to bind to vals.
@dwijnand dwijnand marked this pull request as ready for review March 8, 2023 14:02
@dwijnand dwijnand requested a review from odersky March 8, 2023 14:02
@odersky odersky assigned dwijnand and unassigned odersky Mar 13, 2023
@dwijnand dwijnand merged commit 42fb202 into scala:main Mar 23, 2023
@dwijnand dwijnand deleted the fix-trait-super-val-protected-accessors branch March 23, 2023 16:12
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
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.

Code using cyclic types dependency fails to compile when using protected val in trait constructor
3 participants