jextract/jni: Inherited protocol requirements can be renamed inconsistently when a child adds an overload

オープン
#941 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, swift

調査の方向性

Start by reading the jextract/jni code that generates Java interfaces, box methods, and JNI thunks for protocol requirements; the issue does not name specific files or tests. Trace how the parent and child overloads in the NamingParent/NamingChild example get their Java names, then check whether both operations dispatch to the correct Swift requirement and the child box implements the parent interface. Done means Java compilation succeeds and both overloads call the intended Swift method.

索引モデルが issue の本文から書いたものです。

説明

Problem

When a child protocol adds an overload of an inherited requirement, the generated Java box can rename the inherited method based on the child's overload set. The parent Java interface still declares the method under its original name, so the child box does not implement the parent interface and Java compilation fails.

Example

public protocol NamingParent {
  var id: Int64 { get }
  func value(number: Int64) -> Int64
}

public protocol NamingChild: NamingParent {
  var tag: Int64 { get }
  func value(text: Int64) -> Int64
}

struct NamingValue: NamingChild {
  var id: Int64 { 1 }
  var tag: Int64 { 2 }

  func value(number: Int64) -> Int64 { number + 10 }
  func value(text: Int64) -> Int64 { text + 20 }
}

public func makeNamingChild() -> any NamingChild {
  NamingValue()
}

Swift argument labels distinguish the two requirements, but Java cannot represent both as value(long) on the child interface.

The parent interface exposes value(number:) as value(long). However, the generated child box can emit valueNumber(long) for that inherited requirement after considering the child's overload. This does not implement the parent's value(long) method.

The inherited requirement should keep the name declared by the parent interface. For example, the generated bindings could use value(long) for value(number:) and valueText(long) for value(text:). The Java interfaces, box methods, and JNI thunks should use consistent names so that both operations dispatch to the correct Swift requirement.

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

主要言語
Swift
スター
1.3k
フォーク
127
平均マージ
2日 14時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

swiftlang/swift-java のほかの issue

swiftlang/swift-java の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。