Skip to content

Commit 97a612e

Browse files
committed
GROOVY-10592
1 parent 0b13c1d commit 97a612e

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

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

+20
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,26 @@ public void testJavaInterfaceWithDefaultMethod3() {
13271327
}
13281328
}
13291329

1330+
@Test // GROOVY-10592
1331+
public void testJavaInterfaceWithStaticMethod() {
1332+
//@formatter:off
1333+
createJavaUnit("I",
1334+
"public interface I {\n" +
1335+
" static C getP() {\n" +
1336+
" }\n" +
1337+
" class C {\n" +
1338+
" }\n" +
1339+
"}");
1340+
1341+
String contents =
1342+
"I.getP();" +
1343+
"I.p"; // XXX
1344+
//@formatter:on
1345+
1346+
assertKnown(contents, "getP", "I", "getP", DeclarationKind.METHOD);
1347+
assertUnknown(contents, "p");
1348+
}
1349+
13301350
@Test // GRECLIPSE-1105
13311351
public void testFluentInterfaceWithFieldNameConflicts() {
13321352
//@formatter:off

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java

+24
Original file line numberDiff line numberDiff line change
@@ -7386,4 +7386,28 @@ public void testCompileStatic10579() {
73867386

73877387
runConformTest(sources, "15");
73887388
}
7389+
7390+
@Test
7391+
public void testCompileStatic10592() {
7392+
//@formatter:off
7393+
String[] sources = {
7394+
"Main.groovy",
7395+
"@groovy.transform.CompileStatic\n" +
7396+
"void test() {\n" +
7397+
" print Face.getValue()\n" +
7398+
" print Face.value\n" +
7399+
"}\n" +
7400+
"test()\n",
7401+
7402+
"Face.java",
7403+
"interface Face {\n" +
7404+
" static String getValue() {\n" +
7405+
" return \"works\";\n" +
7406+
" }\n" +
7407+
"}\n",
7408+
};
7409+
//@formatter:on
7410+
7411+
runConformTest(sources, "worksworks");
7412+
}
73897413
}

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java

+24
Original file line numberDiff line numberDiff line change
@@ -5601,4 +5601,28 @@ public void testTypeChecked10576() {
56015601

56025602
runConformTest(sources, "[foo:bar]");
56035603
}
5604+
5605+
@Test
5606+
public void testTypeChecked10592() {
5607+
//@formatter:off
5608+
String[] sources = {
5609+
"Main.groovy",
5610+
"@groovy.transform.TypeChecked\n" +
5611+
"void test() {\n" +
5612+
" print Face.getValue()\n" +
5613+
" print Face.value\n" +
5614+
"}\n" +
5615+
"test()\n",
5616+
5617+
"Face.java",
5618+
"interface Face {\n" +
5619+
" static String getValue() {\n" +
5620+
" return \"works\";\n" +
5621+
" }\n" +
5622+
"}\n",
5623+
};
5624+
//@formatter:on
5625+
5626+
runConformTest(sources, "works", "groovy.lang.MissingPropertyException: No such property: value for class: Face");
5627+
}
56045628
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,8 @@ private static Stream<MethodNode> findMetaObjectMethods(final ClassNode declarin
888888

889889
private static Optional<MethodNode> findPropertyAccessorMethod(final String propertyName, final ClassNode declaringType, final boolean isLhsExpression, final boolean isStaticExpression, final List<ClassNode> methodCallArgumentTypes) {
890890
Stream<MethodNode> accessors = AccessorSupport.findAccessorMethodsForPropertyName(propertyName, declaringType, false, !isLhsExpression ? READER : WRITER);
891-
accessors = accessors.filter(accessor -> isCompatible(accessor, isStaticExpression) && !isTraitBridge(accessor));
891+
accessors = accessors.filter(accessor -> isCompatible(accessor, isStaticExpression) && !isTraitBridge(accessor) &&
892+
(!accessor.isStatic() || !accessor.getDeclaringClass().isInterface())); // GROOVY-10592
892893
if (isLhsExpression) {
893894
// use methodCallArgumentTypes to select closer match
894895
accessors = accessors.sorted((m1, m2) -> (m1 == closer(m2, m1, methodCallArgumentTypes) ? -1 : +1));

0 commit comments

Comments
 (0)