diff options
author | Till Brychcy | 2019-05-22 19:05:30 +0000 |
---|---|---|
committer | Till Brychcy | 2019-07-23 20:45:22 +0000 |
commit | fcf2ea3ee3babc632c8b89d189855cc579edd175 (patch) | |
tree | 7adf05128ce8ba55a34a4f27876894c901e5313d | |
parent | efd24e7042e7f6e5e796560acd02bd5961efb8a3 (diff) | |
download | eclipse.jdt.core-fcf2ea3ee3babc632c8b89d189855cc579edd175.tar.gz eclipse.jdt.core-fcf2ea3ee3babc632c8b89d189855cc579edd175.tar.xz eclipse.jdt.core-fcf2ea3ee3babc632c8b89d189855cc579edd175.zip |
Bug 539732 - [1.8][compiler] "Illegal reference to super method" when
overriding default method with generic return
Change-Id: Idf9d1d3afce617f499b198da00482ed993618ec0
2 files changed, 31 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InterfaceMethodsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InterfaceMethodsTest.java index 750a0e40a4..711365919b 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InterfaceMethodsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InterfaceMethodsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2017 GK Software AG, IBM Corporation and others. + * Copyright (c) 2013, 2019 GK Software AG, IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -3111,4 +3111,33 @@ public class InterfaceMethodsTest extends AbstractComparableTest { "The default method foo() inherited from JavaTest.D conflicts with another method inherited from JavaTest.C\n" + "----------\n"); } + + public void testBug539743() { + runConformTest( + new String[] { + "Test.java", + "public class Test {\n" + + " static <V> void m(V v) {\n" + + "\n" + + " }\n" + + "\n" + + " interface Foo {\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " default <U> U f() {\n" + + " return (U) new Object();\n" + + " }\n" + + " }\n" + + "\n" + + " static class Bar implements Foo {\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " @Override\n" + + " public Object f() {\n" + + " m(Foo.super.f());\n" + + " return null;\n" + + " }\n" + + " }\n" + + "}", + }, + ""); + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java index 3c24b42869..bf4ea57df6 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java @@ -1231,7 +1231,7 @@ public void checkAppropriateMethodAgainstSupers(char[] selector, MethodBinding c } } private boolean checkAppropriate(MethodBinding compileTimeDeclaration, MethodBinding otherMethod, InvocationSite location) { - if (otherMethod == null || !otherMethod.isValidBinding() || otherMethod == compileTimeDeclaration) + if (otherMethod == null || !otherMethod.isValidBinding() || otherMethod.original() == compileTimeDeclaration.original()) return true; if (MethodVerifier.doesMethodOverride(otherMethod, compileTimeDeclaration, this.environment())) { problemReporter().illegalSuperCallBypassingOverride(location, compileTimeDeclaration, otherMethod.declaringClass); |