void () { for (Map.Entry<String, String> entry : Map.of( "builder.root()", "java.util.Map", "builder.root {}", "java.util.Map", "builder.root(a:1)", "java.util.Map", "builder.root([a:1])", "java.util.Map", "builder.root([a:1]) {}", "java.util.Map", "builder.root(a:1) {}", "java.util.Map", "builder.root(a:1, {})", "java.util.Map", "builder.root({}, a:1)", "java.util.Map", "builder.root([1,\"\",new Object()], {})", "java.util.Map", "builder.root([1,\"\",new Object()] as Object[], {})", "java.util.Map" ).entrySet()) { String text = entry.getKey(); String returnType = entry.getValue(); var file = (GroovyFile)getFixture().configureByText("a.groovy", "def builder = new groovy.json.JsonBuilder(); " + text); GrTopStatement[] statements = file.getTopStatements(); var call = (GrCallExpression)statements[statements.length - 1]; assert call.resolveMethod() != null; assert call.getType().getCanonicalText().equals(returnType); } }