From 5b99525168132c10c5d4068aeb4c18e958c5961e Mon Sep 17 00:00:00 2001 From: Iceman Date: Tue, 20 Jan 2026 17:49:09 +0900 Subject: [PATCH 1/2] Fix crash when `Any` type parsing --- .../JExtractSwiftLib/SwiftTypes/SwiftType.swift | 5 ++++- Tests/JExtractSwiftTests/MethodImportTests.swift | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Sources/JExtractSwiftLib/SwiftTypes/SwiftType.swift b/Sources/JExtractSwiftLib/SwiftTypes/SwiftType.swift index a9815554..1b7269f4 100644 --- a/Sources/JExtractSwiftLib/SwiftTypes/SwiftType.swift +++ b/Sources/JExtractSwiftLib/SwiftTypes/SwiftType.swift @@ -365,7 +365,10 @@ extension SwiftType { } typeDecl = lookupContext.symbolTable.lookupNestedType(name.text, parent: parentDecl) } else { - typeDecl = try lookupContext.unqualifiedLookup(name: Identifier(name)!, from: name) + guard let ident = Identifier(name) else { + throw TypeTranslationError.unknown(originalType) + } + typeDecl = try lookupContext.unqualifiedLookup(name: ident, from: name) } guard let typeDecl else { throw TypeTranslationError.unknown(originalType) diff --git a/Tests/JExtractSwiftTests/MethodImportTests.swift b/Tests/JExtractSwiftTests/MethodImportTests.swift index 9fed3fc3..32f60746 100644 --- a/Tests/JExtractSwiftTests/MethodImportTests.swift +++ b/Tests/JExtractSwiftTests/MethodImportTests.swift @@ -41,6 +41,8 @@ final class MethodImportTests { ) public func globalReturnClass() -> MySwiftClass + + public func globalReturnAny() -> Any public func swapRawBufferPointer(buffer: UnsafeRawBufferPointer) -> UnsafeMutableRawBufferPointer @@ -456,4 +458,18 @@ final class MethodImportTests { """ ) } + + @Test("Import: public func globalReturnAny() -> Any") + func func_globalReturnAny() throws { + var config = Configuration() + config.swiftModule = "__FakeModule" + let st = Swift2JavaTranslator(config: config) + st.log.logLevel = .error + + try st.analyze(path: "Fake.swift", text: class_interfaceFile) + + #expect(!st.importedGlobalFuncs.contains { + $0.name == "globalReturnAny" + }, "'Any' return type is not supported yet") + } } From 2d9700f79702ab77c18f9e959124b8f68a0e5e14 Mon Sep 17 00:00:00 2001 From: Iceman Date: Tue, 20 Jan 2026 18:20:52 +0900 Subject: [PATCH 2/2] Doc: Any is excluded --- .../Documentation.docc/SupportedFeatures.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md b/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md index 370f3392..89c51b2f 100644 --- a/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md +++ b/Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md @@ -65,9 +65,9 @@ SwiftJava's `swift-java jextract` tool automates generating Java bindings from S | Tuples: `(Int, String)`, `(A, B, C)` | ❌ | ❌ | | Protocols: `protocol` | ❌ | ✅ | | Protocols: `protocol` with associated types | ❌ | ❌ | -| Existential parameters `f(x: any SomeProtocol) ` | ❌ | ✅ | +| Existential parameters `f(x: any SomeProtocol)` (excepts `Any`) | ❌ | ✅ | | Existential parameters `f(x: any (A & B)) ` | ❌ | ✅ | -| Existential return types `f() -> any Collection ` | ❌ | ❌ | +| Existential return types `f() -> any Collection` | ❌ | ❌ | | Foundation Data and DataProtocol: `f(x: any DataProtocol) -> Data` | ✅ | ❌ | | Opaque parameters: `func take(worker: some Builder) -> some Builder` | ❌ | ✅ | | Opaque return types: `func get() -> some Builder` | ❌ | ❌ |