Skip to content

SI-9286 Check subclass privates for "same type after erasure"#4477

Merged
adriaanm merged 1 commit intoscala:2.11.xfrom
retronym:ticket/9286
May 21, 2015
Merged

SI-9286 Check subclass privates for "same type after erasure"#4477
adriaanm merged 1 commit intoscala:2.11.xfrom
retronym:ticket/9286

Conversation

@retronym
Copy link
Member

@retronym retronym commented May 1, 2015

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.

Review by @adriaanm

@scala-jenkins scala-jenkins added this to the 2.11.7 milestone May 1, 2015
@lrytz
Copy link
Member

lrytz commented May 4, 2015

/rebuild

1 similar comment
@retronym
Copy link
Member Author

/rebuild

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`.
@adriaanm
Copy link
Contributor

LGTM!

adriaanm added a commit that referenced this pull request May 21, 2015
SI-9286 Check subclass privates for "same type after erasure"
@adriaanm adriaanm merged commit dcf6b0a into scala:2.11.x May 21, 2015
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.

4 participants