mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
lambda: functional interface can contain multiple default methods
This commit is contained in:
@@ -216,12 +216,12 @@ public class LambdaUtil {
|
||||
private static List<MethodSignature> findFunctionCandidates(PsiClass psiClass) {
|
||||
if (psiClass.isInterface()) {
|
||||
final List<MethodSignature> methods = new ArrayList<MethodSignature>();
|
||||
final PsiMethod[] psiClassMethods = psiClass.getAllMethods();
|
||||
for (PsiMethod psiMethod : psiClassMethods) {
|
||||
final Collection<HierarchicalMethodSignature> visibleSignatures = psiClass.getVisibleSignatures();
|
||||
for (HierarchicalMethodSignature signature : visibleSignatures) {
|
||||
final PsiMethod psiMethod = signature.getMethod();
|
||||
if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue;
|
||||
final PsiClass methodContainingClass = psiMethod.getContainingClass();
|
||||
if (!overridesPublicObjectMethod(psiMethod)) {
|
||||
methods.add(getMethodSignature(psiMethod, psiClass, methodContainingClass));
|
||||
if (!overridesPublicObjectMethod(psiMethod) && !PsiUtil.isExtensionMethod(psiMethod)) {
|
||||
methods.add(signature);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class Test {
|
||||
public static final BinaryOperator<Integer> rPlus = (x, y) -> x + y;
|
||||
interface BinaryOperator<T> extends Combiner<T,T,T> {
|
||||
public T operate(T left, T right);
|
||||
|
||||
@Override
|
||||
T combine(T t1, T t2) default {
|
||||
return operate(t1, t2);
|
||||
}
|
||||
}
|
||||
|
||||
interface Combiner<T, U, V> {
|
||||
V combine(T t, U u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -85,7 +85,9 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testDefaultMethod() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNoInferenceResult() throws Exception {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user