8007535: Compiler crashes on @FunctionalInterface used on interface with two inherited methods with same signatures
Bad check in Types.interfaceCandidates Reviewed-by: jjg
This commit is contained in:
parent
b496912ee1
commit
f5df2a2562
@ -2606,16 +2606,17 @@ public class Types {
|
|||||||
candidates = candidates.prepend((MethodSymbol)s);
|
candidates = candidates.prepend((MethodSymbol)s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return prune(candidates, ownerComparator);
|
return prune(candidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MethodSymbol> prune(List<MethodSymbol> methods, Comparator<MethodSymbol> cmp) {
|
public List<MethodSymbol> prune(List<MethodSymbol> methods) {
|
||||||
ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
|
ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
|
||||||
for (MethodSymbol m1 : methods) {
|
for (MethodSymbol m1 : methods) {
|
||||||
boolean isMin_m1 = true;
|
boolean isMin_m1 = true;
|
||||||
for (MethodSymbol m2 : methods) {
|
for (MethodSymbol m2 : methods) {
|
||||||
if (m1 == m2) continue;
|
if (m1 == m2) continue;
|
||||||
if (cmp.compare(m2, m1) < 0) {
|
if (m2.owner != m1.owner &&
|
||||||
|
asSuper(m2.owner.type, m1.owner) != null) {
|
||||||
isMin_m1 = false;
|
isMin_m1 = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2625,12 +2626,6 @@ public class Types {
|
|||||||
}
|
}
|
||||||
return methodsMin.toList();
|
return methodsMin.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Comparator<MethodSymbol> ownerComparator = new Comparator<MethodSymbol>() {
|
|
||||||
public int compare(MethodSymbol s1, MethodSymbol s2) {
|
|
||||||
return s1.owner.isSubClass(s2.owner, Types.this) ? -1 : 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// where
|
// where
|
||||||
private class MethodFilter implements Filter<Symbol> {
|
private class MethodFilter implements Filter<Symbol> {
|
||||||
|
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8007535
|
||||||
|
* @summary Compiler crashes on FunctionalInterface used on interface with two inherited methods with same signatures
|
||||||
|
* @compile FunctionalInterfaceAnno02.java
|
||||||
|
*/
|
||||||
|
class FunctionalInterfaceAnno02 {
|
||||||
|
interface Foo<T, N extends Number> {
|
||||||
|
void m(T arg);
|
||||||
|
void m(N arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
interface Baz extends Foo<Integer, Integer> { }
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user