Skip to content

calls_out (java/kotlin/groovy): generic constructor and function calls Name<T>( / new X<>() missed #4124

Closed

Description

@squid-protocol

What

calls_out misses JVM constructor and generic-function calls written with a type-argument list between the name and (. Java, Kotlin and Groovy use CALLS_OUT_C_STYLE_NO_ANNOTATION ((?<!@)\b(name)\s*\(), so the <...> stops the match:

  • Java new HashMap<String, Object>(), new ArrayList<>(list) (diamond), new Action<Project>() { ... } (anonymous class)
  • Kotlin ArrayDeque<AsyncCall>(), mutableListOf<AsyncCall>(), tasks.register<Copy>("x")
  • Groovy new HashSet<Object>(), new ArrayList<>()

By calls_out contract C3, a constructor is a call to the name written. #3644 fixed the same gap for cpp/typescript/csharp with CALLS_OUT_C_STYLE_GENERIC. That pattern does not fit here as is: it has no @ annotation guard (C1), and it needs at least one character between the brackets, so a Java diamond <> still fails.

Evidence

Graph comparison ledger shape java/call/object_creation_expression/generic_type+generic/agree[tree_sitter]_vs[gitgalaxy] (#3799): 35 of 35 occurrences are generic constructor calls. It is Java's only open Level-1 shape (raw recall 98.2%, FN 35, FP 0). Examples:

  • groovy/gradle/DefaultProject.java:922 new HashSet<Task>()
  • groovy/gradle/DefaultPluginManager.java:258 new Action<PluginWithId>() {
  • java/springboot/SpringApplication.java:1481 new LinkedHashSet<>(list)

A standalone run of an annotation-guarded generic pattern that accepts the diamond, over every crucible .java/.kt/.kts/.groovy/.gradle file, gained 53 Java, 7 Kotlin and 8 Groovy captures. All 68 are real constructor or generic-function calls, and no existing capture was lost.

Not in scope

Swift and Dart use the same pattern but write generic declarations as func map<T>(. Their gains would include declaration headers, so they need their own check. Scala writes [T].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:frontier

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions