Skip to content

jextract/jni: Protocol property setters reference an incorrectly named adapter #949

Open

Description

@teamhimeh

Problem

With Java callbacks enabled, JNI bindings for a public protocol-typed property can generate a Swift setter that references a wrapper class under a different name from its declaration. The generated Swift code then fails to compile.

Example

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

public final class Service {
  public var callback: any Callback

  public init(callback: some Callback) {
    self.callback = callback
  }

  public func read() -> Int64 {
    callback.value()
  }
}

The generated wrapper declaration uses the Swift property name, while the setter's argument conversion uses the Java setter name:

// Generated wrapper declaration
final class _Service_callback_newValue_Wrapper: SwiftJavaCallbackWrapper {
  // ...
}

// Generated setter argument conversion references
// _Service_setCallback_newValue_Wrapper instead.

The same kind of mismatch can occur when Java method names differ from Swift names for label-disambiguated overloads or Java keywords.

Related: #946 also concerns protocol-parameter adapters, but reports duplicate declarations for overloads.

Reference workaround implementation: qoncept#16

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