Skip to content

Commit

Permalink
GROOVY-8164, GROOVY-11268
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jan 6, 2024
1 parent 2c8732b commit e6ea331
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -681,6 +681,19 @@ public void testStaticReference35() {
assertKnown(contents, "getName", "Other", "java.lang.Object");
}

@Test // GROOVY-8164, GROOVY-11268
public void testStaticReference36() {
String contents =
"abstract class A implements Comparator<A> {\n" +
" def c = comparing(this.&getP)\n" + // interface static method
" int p\n" +
"}\n";
assertUnknown(contents, "comparing");

contents = contents.replace("comparing", "Comparator.comparing");
assertKnown(contents, "comparing", "java.util.Comparator", "java.util.Comparator<java.lang.Object>");
}

//

@Test // GRECLIPSE-855: should be able to find the type, but with unknown confidence
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -793,6 +793,7 @@ protected MethodNode findMethodDeclaration(final String name, final ClassNode de
MethodNode innerCandidate = null;
List<MethodNode> candidates = getMethods(name, type);
candidates.removeIf(m -> m.isPrivate() && !m.getDeclaringClass().equals(declaringType)); // GROOVY-8859
if (type.isInterface() && !Traits.isTrait(type) && !type.equals(declaringType)) candidates.removeIf(m -> m.isStatic()); // GROOVY-8164
if (!candidates.isEmpty()) {
innerCandidate = findMethodDeclaration0(candidates, argumentTypes, isStaticExpression);
if (innerCandidate != null && outerCandidate == null) {
Expand Down

0 comments on commit e6ea331

Please sign in to comment.