Compilation error for class with sync/async function overloads: method is already defined
Maintainer thường phản hồi trong vòng 1 ngày
@Hokila đang làm issue này rồi.
Từ ngày 3/9/2026.
Đá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
- 68/100
Hướng nghiên cứu
Bắt đầu với JNISwift2JavaGenerator+JavaBindingsPrinting.swift tại printJavaBindingWrapperMethod và JavaTranslation.swift tại render, sau đó tái hiện ví dụ overload remove sync/async đã được báo cáo. Truy vết cách cả hai phương thức Swift trở thành các phương thức Java và đảm bảo lớp được sinh ra biên dịch mà không gặp lỗi phương thức trùng lặp, đồng thời giữ lại cả hai binding.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Commit hash: a736a64e18a85f55f267427a3c9de60ae8377b7a
Context:
While testing swiftly's support of existing Swift code, noticed that a code using a function that is overloaded with both sync and async variants is not compiling, failing with "method is already defined" error.
import Foundation
public class Test {
public func remove(key: String) { /* sync */ }
public func remove(key: String) async { }
}
Results in the following compilation error:
.../.build/plugins/outputs/lib/SwiftTestLib/destination/JExtractSwiftPlugin/src/generated/java/com/example/swiftexamplelib/Test.java:93: error: method removeKey(String) is already defined in class Test
public java.util.concurrent.CompletableFuture<java.lang.Void> removeKey(java.lang.String key) {
Portion of the generated Java file:
// ==== --------------------------------------------------
// Test.remove
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func remove(key: String)
* }
*/
public void removeKey(java.lang.String key) {
Test.$removeKey(key, this.$memoryAddress());
} // printJavaBindingWrapperMethod(_:_:importedFunc:skipMethodBody:) @ JExtractSwiftLib/JNISwift2JavaGenerator+JavaBindingsPrinting.swift:950
private static native void $removeKey(java.lang.String key, long selfPointer);
// ==== --------------------------------------------------
// Test.remove
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func remove(key: String) async
* }
*/
public java.util.concurrent.CompletableFuture<java.lang.Void> removeKey(java.lang.String key) {
java.util.concurrent.CompletableFuture<java.lang.Void> future$ = new java.util.concurrent.CompletableFuture<java.lang.Void>();
Test.$removeKey(key, this.$memoryAddress(), future$);
return future$.thenApply((futureResult$) -> {
return futureResult$;
} // render(_:_:) @ JExtractSwiftLib/JNISwift2JavaGenerator+JavaTranslation.swift:2072
);
} // printJavaBindingWrapperMethod(_:_:importedFunc:skipMethodBody:) @ JExtractSwiftLib/JNISwift2JavaGenerator+JavaBindingsPrinting.swift:950
private static native void $removeKey(java.lang.String key, long selfPointer, java.util.concurrent.CompletableFuture<java.lang.Void> result_future);
Environment: Swift 6.3.3 on macOS.
$ swiftly run swift --version
Apple Swift version 6.3.3 (swift-6.3.3-RELEASE)
Target: arm64-apple-macosx26.0
$ uname -a
Darwin it-C01241 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:18:49 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6000 arm64
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của swiftlang/swift-java
-
wrap-java: Optional convenience methods can fail to compile when a parameter shadows the method nameĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
swiftlang/swift-java#945 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
swiftlang/swift-java#663 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
swiftlang/swift-java#949 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
swiftlang/swift-java#948 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
swiftlang/swift-java#947 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của swiftlang/swift-java
Issue tương tự
-
feat: 앱 정보에 개인정보처리방침과 고객지원 연결Có thể đã có người làm @xrpjwk8 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
DeveloperAcademy-POSTECH/2026-C6-A13-Hear-I-am#120 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[投稿] SSE 接收的三层检查:字节、事件与响应终态Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
jaywcjlove/quick-rss#448 ·
-
Edit Space… → Save overwrites an imported space's SF Symbol icon with 🌱 and stacks both glyphsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
VictorKildahl/cra#205 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Intermittent failure in PathUtilsTests.testNewDirectoryIsExcludedAndExistingChoiceIsKeptĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
apple/container#2474 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mac proof: carets blink and the inspector's thread lands in different places from run to runĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AttilaTheFun/visor#244 ·
Maintainer thường phản hồi trong vòng 1 ngày