swiftlang / swiftlang/swift-java
Classes with a type parameter fail to compile
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.2k
- Forks
- 123
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 16
Description
I searched through the issues, but couldn't find an explicit issue about the missing support for generics. In particular if you have a public class such as:
public class Foo<T> {
public init() {}
}
in Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/Foo.swift, then the Swift wrappers compilation currently fails with:
error: generic parameter 'T' could not be inferred
26 | @_cdecl("swiftjava_getType_MySwiftLibrary_Foo")
27 | public func swiftjava_getType_MySwiftLibrary_Foo() -> UnsafeMutableRawPointer /* Any.Type */ {
28 | return unsafeBitCast(Foo.self, to: UnsafeMutableRawPointer.self)
| |- error: generic parameter 'T' could not be inferred
| `- note: explicitly specify the generic arguments to fix this issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/Foo.swift and inspect the generated Swift wrapper at the reported swiftjava_getType_MySwiftLibrary_Foo function. Reproduce the compilation failure for Foo and trace how the generic type is represented in the wrapper. Done means the Swift wrappers compile for the generic public class without the generic-parameter inference error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100