diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-05-01 12:34:51 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-05-18 11:17:09 +1000 |
commit | aca8f96d1cf5f645c24eac11f695dadae08ea381 (patch) | |
tree | 46badacf236a24013536acee469a898aa979e9c8 /test/files/neg/t9286a.scala | |
parent | 2f1b5259188698501dbc8430f63972bf7bc68154 (diff) | |
download | scala-aca8f96d1cf5f645c24eac11f695dadae08ea381.tar.gz scala-aca8f96d1cf5f645c24eac11f695dadae08ea381.tar.bz2 scala-aca8f96d1cf5f645c24eac11f695dadae08ea381.zip |
SI-9286 Check subclass privates for "same type after erasure"
The overriding pairs cursor used to detect erased signature clashes
was turning a blind eye to any pair that contained a private method.
However, this could lead to a `VerifyError` or `IllegalAccessError`.
Checking against javac's behaviour in both directions:
```
% cat sandbox/Test.java
public abstract class Test {
class C { int foo() { return 0; } }
class D extends C { private <A> int foo() { return 1; } }
}
% javac sandbox/Test.java
sandbox/Test.java:3: error: name clash: <A>foo() in Test.D and foo() in Test.C have the same erasure, yet neither overrides the other
class D extends C { private <A> int foo() { return 1; } }
^
where A is a type-variable:
A extends Object declared in method <A>foo()
1 error
```
```
% cat sandbox/Test.java
public abstract class Test {
class C { private int foo() { return 0; } }
class D extends C { <A> int foo() { return 1; } }
}
% javac sandbox/Test.java
%
```
This commit only the exludes private symbols from the superclass
from the checks by moving the test from `excludes` to `matches`.
Diffstat (limited to 'test/files/neg/t9286a.scala')
-rw-r--r-- | test/files/neg/t9286a.scala | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/files/neg/t9286a.scala b/test/files/neg/t9286a.scala new file mode 100644 index 0000000000..0375ac591f --- /dev/null +++ b/test/files/neg/t9286a.scala @@ -0,0 +1,13 @@ +class T { + def foo(o: Tuple1[String]) = () +} + +class U extends T { + private def foo(o: Tuple1[Any]) = () +} + +object Test { + def main(args: Array[String]): Unit = { + new U().foo(null) // IllegalAccessError: tried to access method U.foo(Lscala/Tuple1;)V from class Test$ + } +} |