skiptools / skiptools/skip-bridge
Constructor bridging fails when another constructor exists with different arguments
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 6
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
The following type:
public struct DemoItem: Decodable, Sendable {
public let id: Int
public let message: String
let createdAt: String
public init(from decoder: Decoder) throws {
fatalError("whatever")
}
}
incorrectly gets the following bridged constructor created:
@_cdecl("Java_medi_quo_core_DemoItem_Swift_1constructor_10")
func DemoItem_Swift_constructor_0(_ Java_env: JNIEnvPointer, _ Java_target: JavaObjectPointer, _ p_0: Int32, _ p_1: JavaString) -> SwiftObjectPointer {
let p_0_swift = Int(p_0)
let p_1_swift = String.fromJavaObject(p_1, options: [.kotlincompat])
let f_return_swift = SwiftValueTypeBox(DemoItem(id: p_0_swift, message: p_1_swift))
return SwiftObjectPointer.pointer(to: f_return_swift, retain: true)
}
which fails to compile with:
…/destination/skipstone/SkipBridgeGenerated/Demo_Bridge.swift:1579:52: error: extra arguments at positions #1, #2 in call
…/destination/skipstone/SkipBridgeGenerated/Demo_Bridge.swift:1579:53: error: missing argument for parameter 'from' in call
…/destination/skipstone/SkipBridgeGenerated/Demo_Bridge.swift:1580:31: error: generic parameter 'T' could not be inferred
We should just not create the bridged constructor in these cases where there is not a synthesized (or actual) constructor in the type that matches the arguments.
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 from the generated SkipBridgeGenerated/Demo_Bridge.swift constructor shown in the report and trace the bridge-generation entry point that produced it. Compare constructor arguments with the available initializers on DemoItem, including init(from:), and verify that no constructor is emitted when no matching synthesized or actual initializer exists. Reproduce the reported compile errors and confirm the generated bridge compiles without the invalid constructor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- mobile-dev, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100