Skip to content

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