Skip to content

jextract/jni: Overloads with protocol parameters generate duplicate adapter classes #946

Open

Description

@teamhimeh

Problem

With enableJavaCallbacks enabled, JNI extraction emits a protocol-parameter adapter for each function declaration. Overloads with the same function name, parameter name, and enclosing type can require the same adapter, so the generated Swift contains duplicate class declarations and fails to compile.

Example

Both initializers below generate an adapter with the same name for store:

public protocol Store {
  func value() -> Int64
}

public struct Client {
  public init(store: some Store) {}
  public init(store: some Store, extra: Int64) {}
}

The duplicate adapter declarations cause the generated Swift to fail compilation. The same problem can occur with overloaded instance methods and free functions.

Reference workaround implementation: qoncept#9

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions