jextract/jni: Enum case record names can collide with enclosing types

Offen
#944 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
57/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
java, swift

Rechercherichtung

Read the jextract/jni enum extraction code and its generated Java output for the Message example. Trace how Swift case names determine record names, payload accessors, and case dispatch; check the generated output with a case that collides with an enclosing type. Done means the generated record avoids the collision and its accessor and dispatch names stay consistent.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Problem

JNI enum extraction capitalizes each Swift case name to generate a nested Java record. That record can have the same name as its enum, another enclosing type, or the generated Case interface. Java rejects these declarations because a nested type cannot share an enclosing type's name.

Example

public enum Message {
  case message(Int64)
}

The generated Java code contains a record named Message inside Message.Case. This conflicts with the enclosing Message type and causes Java compilation to fail.

The generated record name should avoid collisions with enclosing types. Its payload accessor and case dispatch should use the same name consistently.

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

Vorherrschende Sprache
Swift
Sterne
1.3k
Forks
129
Ø Merge
7 Std. 16 Min.
Gemergte PRs (30 T.)
4

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus swiftlang/swift-java

Alle Issues in swiftlang/swift-java

Ähnliche Issues

Weitere Issues zu Swift

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.