Skip to content

Commit

Permalink
Fix for issue #539: no category methods in static imports
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 19, 2018
1 parent 674a8b6 commit 5ade982
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,12 @@ public void testStaticImport9() throws Exception {
String contents = "import static p.Other.*\nFOO";
assertKnown(contents, "p.Other", "p.Other", "p.Other");
}

@Test // https://github.com/groovy/groovy-eclipse/issues/539
public void testStaticImport10() throws Exception {
createUnit("p", "Other", "package p\nclass Other { static void dump(Object o) { } }");

String contents = "import static p.Other.dump\n";
assertKnown(contents, "dump", "p.Other", "java.lang.Void");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public TypeLookupResult lookupType(Expression node, VariableScope scope, ClassNo
}

protected static boolean isCompatibleConstantExpression(Expression node, VariableScope scope) {
if (node instanceof ConstantExpression) {
if (node instanceof ConstantExpression && !scope.isTopLevel()) {
org.codehaus.groovy.ast.ASTNode enclosingNode = scope.getEnclosingNode();
if (!(enclosingNode instanceof AttributeExpression || enclosingNode instanceof MethodPointerExpression)) {
return (VariableScope.STRING_CLASS_NODE.equals(node.getType()) && node.getLength() <= node.getText().length());
Expand Down

0 comments on commit 5ade982

Please sign in to comment.