Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Sources/JExtractSwiftLib/SwiftTypes/SwiftType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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` | ❌ | ❌ |
Expand Down
16 changes: 16 additions & 0 deletions Tests/JExtractSwiftTests/MethodImportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ final class MethodImportTests {
)

public func globalReturnClass() -> MySwiftClass

public func globalReturnAny() -> Any

public func swapRawBufferPointer(buffer: UnsafeRawBufferPointer) -> UnsafeMutableRawBufferPointer

Expand Down Expand Up @@ -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")
}
}
Loading