void () { for (Map.Entry<String, String> entry : Map.of( "noArg()", "java.util.List", "singleArg(1)", "java.lang.Integer", "singleArg(\"\")", "java.lang.String", "singleArg(new Object())", "java.lang.Object", "doubleArgs([1,2,3], {})", "java.util.List<java.lang.Integer>", "doubleArgs([] as Number[], {})", "java.util.List<java.lang.Number>", "varArgs(1,2,3)", "java.util.List<java.lang.Integer>", "varArgs(1,2l,3d)", "java.util.List<java.lang.Number>", "varArgs(1,2l,3d, new Object())", "java.util.List<java.lang.Object>" ).entrySet()) { String callText = entry.getKey(); String returnType = entry.getValue(); for (String text : List.of( "builder.root {<caret>" + callText + "}", "builder.root([a:1]) {<caret>" + callText + "}", "builder.root({<caret>" + callText + "}, a:1)" )) { getFixture().configureByText("a.groovy", "def builder = new groovy.json.JsonBuilder(); " + text); var reference = (GrReferenceExpression)getFixture().getReferenceAtCaretPosition(); assert reference.resolve() instanceof PsiMethod; assert reference.getType().getCanonicalText().equals(returnType); } } }