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

Abierto
#948 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java, swift

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Swift
Estrellas
1.3k
Forks
127
Merge medio
2 d 14 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de swiftlang/swift-java

Todos los issues de swiftlang/swift-java

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.