forked from scala/scala
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix access to protected members in package-protected classes
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
- Loading branch information
Showing
28 changed files
with
291 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Test_1.scala:11: error: Unable to emit reference to method m in class A, class A is not accessible in object Test | ||
w.m() | ||
^ | ||
one error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package a; | ||
|
||
class A { | ||
public final int m() { return 1; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package a { | ||
// A is a class, so W does not conform to A in bytecode. an access (w: W).m() requires a cast to A. | ||
// If `A` is not accessible, there's no solution. | ||
trait W extends A | ||
class C extends W | ||
} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val w: a.W = new a.C | ||
w.m() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.