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

Đang mở
#946 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
53/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, swift
Lĩnh vực
backend-api-design

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Swift
Star
1.3k
Fork
127
Merge trung bình
2 ngày 14 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của swiftlang/swift-java

Tất cả issue của swiftlang/swift-java

Issue tương tự

Thêm issue về Swift

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.