jextract/jni: Expose Swift protocol requirement defaults to Java callbacks

Aperta
#948 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à
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, swift

Direzione di ricerca

Start by reading #562 and #891, which describe related extension-member and compilation behavior, then inspect the JNI callback generation entry points in the repository. Determine how an unconditional Swift protocol extension implementation can remain the implementation while calls to other requirements dispatch to Java overrides; done means Java callbacks can inherit that default and the example works.

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

Descrizione

Problem

JNI callback interfaces currently leave protocol requirements abstract even when Swift supplies an unconditional implementation in an extension. Java implementors must repeat that implementation instead of inheriting the Swift behavior.

Example

public protocol Greeter {
  func name() -> String
  func greeting() -> String
}

extension Greeter {
  public func greeting() -> String { "Hello, \(name())" }
}

With Java callbacks enabled, it would be useful for a Java implementation to provide only name() and inherit the Swift implementation of greeting():

Greeter greeter = () -> "World";
String message = greeter.greeting(); // "Hello, World"

The Swift body should remain the implementation, and its calls to other requirements should dispatch to the Java receiver, including any Java overrides.

This is related to #562, which discusses exposing extension members as Java default methods, and #891, which reports a compilation error when a protocol requirement has a default implementation.

Reference workaround implementation: https://github.com/qoncept/swift-java/pull/11

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.