diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/InferencingTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/InferencingTests.java index 276a686747..27155722e0 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/InferencingTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/InferencingTests.java @@ -3479,4 +3479,16 @@ public void testMethodOverloadsArgumentMatching9() { assertType(contents, "n", "java.lang.Number"); } + + @Test // https://github.com/groovy/groovy-eclipse/issues/1024 + public void testMethodOverloadsArgumentMatching10() { + String contents = + "byte meth(String s) {\n" + + "}\n" + + "char meth(Map args) {\n" + + "}\n" + + "meth(name:null)\n"; + + assertType(contents, "meth", "java.lang.Character"); + } } diff --git a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java index 1a256f8dbf..5289c8b4ef 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java @@ -2101,9 +2101,18 @@ private MethodNode findLazyMethod(final String fieldName) { private List getMethodCallArgumentTypes(ASTNode node) { if (node instanceof MethodCall) { Expression arguments = ((MethodCall) node).getArguments(); - if (arguments instanceof ArgumentListExpression) { - List expressions = ((ArgumentListExpression) arguments).getExpressions(); + if (arguments instanceof TupleExpression) { + List expressions = ((TupleExpression) arguments).getExpressions(); if (isNotEmpty(expressions)) { + if (expressions.get(0) instanceof NamedArgumentListExpression) { + if (node instanceof ConstructorCallExpression) { + return Collections.emptyList(); // default constructor + } else { + return Collections.singletonList(createParameterizedMap( + VariableScope.STRING_CLASS_NODE, VariableScope.OBJECT_CLASS_NODE)); + } + } + List types = new ArrayList<>(expressions.size()); for (Expression expression : expressions) { ClassNode exprType = expression.getType(); @@ -2150,7 +2159,6 @@ private List getMethodCallArgumentTypes(ASTNode node) { return types; } } - // TODO: Might be useful to look into TupleExpression return Collections.emptyList(); }