SI-7936 access protected members in package-protected class#5792
SI-7936 access protected members in package-protected class#5792retronym merged 3 commits intoscala:2.12.xfrom
Conversation
| NoSymbol | ||
| } | ||
| if (phase.erasedTypes && qual.isInstanceOf[Super] && tree.symbol != NoSymbol) | ||
| qual setType tree.symbol.owner.tpe |
There was a problem hiding this comment.
This code is almost 12 years old.. 2a5f62338c#diff-b0ec9c916463796fd7ff1d2ed73d46e2L810
b94ba47 to
e316b65
Compare
| @@ -1,4 +0,0 @@ | |||
|
|
|||
| object Test extends App { | |||
There was a problem hiding this comment.
this test was removed because a more exhaustive version of it exists in https://github.com/scala/scala/tree/2.12.x/test/files/run/t4283
|
this took longer than expected, i hope i covered all cases now.. 🤞 |
|
OK, while I think it's going in the right direction, the kind of errors that are showing while sorting things out ask for not rushing this in 2.12.2 :) currently |
ea76528 to
0495f53
Compare
|
I've got some greens now. A nice side-effect of this fix is that it reduces the cases where one has to manually provide a Java interface as direct parent to allow emitting a super call. For example now compiles using There are still situations where a parent needs to be provided, for example doesn't compile: the super accessor is implemented as |
|
This LGTM on a first pass review. Needs a rebase and I also need to try it out in anger. |
A super access to a protected member in a package-protected class is allowed through an intermediate public class. The fix for scala/bug#5162 actually introduced an error for this case, because the scala compiler would generate an INVOKESPECIAL with the package-protected class as receiver, which is illegal. However, we can use the public intermediate class in the invocation signature. Fixes scala/bug#7936 This is very similar to scala/bug#4283
Also removes the special-case in minimizeParents for Java interfaces, they can now be removed since we know which ones are used for super calls
|
Rebased |
|
Should run this through a community build. |
A super access to a protected member in a package-protected class is allowed through
an intermediate public class. The fix for SI-5162 actually introduced an error for this
case, because the scala compiler would generate an INVOKESPECIAL with the package-protected
class as receiver, which is illegal. However, we can use the public intermediate class in
the invocation signature.
This is very similar to SI-4283.