Mercurial > hg > openjdk > lambda > langtools
changeset 2439:5d2d484a1216
8013846: javac fails to reject semantically equivalent generic method declarations
Summary: Cause javac to consider intersection types with the same elements to be equal regardless of order.
Reviewed-by: jjg, vromero
author | emc |
---|---|
date | Thu, 12 Sep 2013 14:52:28 -0400 |
parents | cf37c3775397 |
children | 3ae1814f7c59 |
files | src/share/classes/com/sun/tools/javac/comp/Check.java test/tools/javac/generics/neg/OrderedIntersections.java test/tools/javac/generics/neg/OrderedIntersections.out |
diffstat | 3 files changed, 26 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Sep 11 14:50:11 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Sep 12 14:52:28 2013 -0400 @@ -3340,7 +3340,9 @@ (e.sym.flags() & CLASH) == 0 && sym.kind == e.sym.kind && sym.name != names.error && - (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { + (sym.kind != MTH || + types.hasSameArgs(sym.type, e.sym.type) || + types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) { varargsDuplicateError(pos, sym, e.sym); return true;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/neg/OrderedIntersections.java Thu Sep 12 14:52:28 2013 -0400 @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6962494 + * @summary The order of elements of intersection types shouldn't matter + * @compile/fail/ref=OrderedIntersections.out -XDrawDiagnostics OrderedIntersections.java + */ + +interface i1 {} +interface i2 {} + +public class OrderedIntersections { + static <t1 extends i1 & i2> Object smf(t1 x) { + System.out.println( " smf1 " ); + return null; + } + + static <t2 extends i2 & i1> Object smf(t2 x) { + System.out.println( " smf2 " ); + return null; + } +}