Skip to content

Commit e6ea331

Browse files
committed
GROOVY-8164, GROOVY-11268
1 parent 2c8732b commit e6ea331

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/StaticInferencingTests.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -681,6 +681,19 @@ public void testStaticReference35() {
681681
assertKnown(contents, "getName", "Other", "java.lang.Object");
682682
}
683683

684+
@Test // GROOVY-8164, GROOVY-11268
685+
public void testStaticReference36() {
686+
String contents =
687+
"abstract class A implements Comparator<A> {\n" +
688+
" def c = comparing(this.&getP)\n" + // interface static method
689+
" int p\n" +
690+
"}\n";
691+
assertUnknown(contents, "comparing");
692+
693+
contents = contents.replace("comparing", "Comparator.comparing");
694+
assertKnown(contents, "comparing", "java.util.Comparator", "java.util.Comparator<java.lang.Object>");
695+
}
696+
684697
//
685698

686699
@Test // GRECLIPSE-855: should be able to find the type, but with unknown confidence

base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/SimpleTypeLookup.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -793,6 +793,7 @@ protected MethodNode findMethodDeclaration(final String name, final ClassNode de
793793
MethodNode innerCandidate = null;
794794
List<MethodNode> candidates = getMethods(name, type);
795795
candidates.removeIf(m -> m.isPrivate() && !m.getDeclaringClass().equals(declaringType)); // GROOVY-8859
796+
if (type.isInterface() && !Traits.isTrait(type) && !type.equals(declaringType)) candidates.removeIf(m -> m.isStatic()); // GROOVY-8164
796797
if (!candidates.isEmpty()) {
797798
innerCandidate = findMethodDeclaration0(candidates, argumentTypes, isStaticExpression);
798799
if (innerCandidate != null && outerCandidate == null) {

0 commit comments

Comments
 (0)