You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixscala#9392: Allow overriding a Java method when a same-named field is present
In scala#9126, Java fields were marked effectively finals to prevent false
overrides. This poses a problem when a Java field and method of the same
name are present, because a Scala val or def will match both of these
according to Denotation#matches. We could tweak `matches` further to not
consider the Java field to match any Scala definition, but that might
introduce new problems (we couldn't trust `FullMatch` anymore and would
need to check the info of any Java symbol which might cause cycles, we
would also probably need to tweak overloading resolution to avoid
ambiguity when trying to decide whether to select the Java field or the
Scala override of the Java method).
This commit takes a different approach: we allow a val or def to match a
Java field, but we tweak the logic that checks whether the `override`
modifier is correctly used to disallow definitions that _only_ match a
Java field (thus preventing tests/neg/i9115 from compiling), while
letting through definitions that both match a Java field and something
else (thus making tests/pos/i9392 compile).
This is all a bit messy but I can't think of a better solution which
wouldn't be significantly more complicated.
0 commit comments