Skip to content

Commit 240d2d3

Browse files
committed
GROOVY-8859
1 parent 653f746 commit 240d2d3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ public void testPrivateMethod1() {
926926
assertExprType(source, "check", "java.lang.Boolean");
927927
}
928928

929-
@Test
929+
@Test // https://issues.apache.org/jira/browse/GROOVY-8859
930930
public void testPrivateMethod2() {
931931
//@formatter:off
932932
String contents =
@@ -943,8 +943,8 @@ public void testPrivateMethod2() {
943943
"}";
944944
//@formatter:on
945945

946-
assertDeclType(contents, "method", "B");
947-
assertExprType(contents, "method", "java.lang.Void");
946+
int offset = contents.lastIndexOf("method");
947+
assertUnknownConfidence(contents, offset, offset + 6);
948948
}
949949

950950
@Test

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ protected MethodNode findMethodDeclaration(final String name, final ClassNode de
789789
for (ClassNode type : types) {
790790
MethodNode innerCandidate = null;
791791
List<MethodNode> candidates = getMethods(name, type);
792+
candidates.removeIf(m -> m.isPrivate() && !m.getDeclaringClass().equals(declaringType)); // GROOVY-8859
792793
if (!candidates.isEmpty()) {
793794
innerCandidate = findMethodDeclaration0(candidates, argumentTypes, isStaticExpression);
794795
if (innerCandidate != null) {
@@ -1179,7 +1180,7 @@ protected static boolean isCompatible(final AnnotatedNode declaration, final boo
11791180
}
11801181

11811182
protected static boolean isNotThisOrOuterClass(final ClassNode thisType, final ClassNode declaringClass) {
1182-
return (!thisType.equals(declaringClass) && !thisType.getOuterClasses().contains(declaringClass) && !(implementsTrait(thisType) && thisType.implementsInterface(declaringClass)));
1183+
return !thisType.equals(declaringClass) && !thisType.getOuterClasses().contains(declaringClass) && !(implementsTrait(thisType) && thisType.implementsInterface(declaringClass));
11831184
}
11841185

11851186
/**

0 commit comments

Comments
 (0)