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

Aperta
#946 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
53/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, swift

Direzione di ricerca

Start by reading the JNI extraction path that emits protocol-parameter adapters when enableJavaCallbacks is enabled; the issue does not name a file or test, so locate it from that option and the generated adapter name. Reproduce with the two Client initializers in the issue and inspect generated Swift for duplicate class declarations. Done when overloaded initializers, instance methods, and free functions that need the same adapter generate compilable Swift.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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: https://github.com/qoncept/swift-java/pull/9

Lingua principale
Swift
Stelle
1.3k
Fork
127
Merge medio
2g 14h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di swiftlang/swift-java

Tutte le issue di swiftlang/swift-java

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.