From aca8f96d1cf5f645c24eac11f695dadae08ea381 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Fri, 1 May 2015 12:34:51 +1000 Subject: 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 int foo() { return 1; } } } % javac sandbox/Test.java sandbox/Test.java:3: error: name clash: foo() in Test.D and foo() in Test.C have the same erasure, yet neither overrides the other class D extends C { private int foo() { return 1; } } ^ where A is a type-variable: A extends Object declared in method foo() 1 error ``` ``` % cat sandbox/Test.java public abstract class Test { class C { private int foo() { return 0; } } class D extends C { 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`. --- src/compiler/scala/tools/nsc/transform/Erasure.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 9fdc3a9d72..a04625c9c5 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -814,11 +814,10 @@ abstract class Erasure extends AddInterfaces // specialized members have no type history before 'specialize', causing double def errors for curried defs override def exclude(sym: Symbol): Boolean = ( sym.isType - || sym.isPrivate || super.exclude(sym) || !sym.hasTypeAt(currentRun.refchecksPhase.id) ) - override def matches(lo: Symbol, high: Symbol) = true + override def matches(lo: Symbol, high: Symbol) = !high.isPrivate } def isErasureDoubleDef(pair: SymbolPair) = { import pair._ -- cgit v1.2.3