Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor bridging fails when another constructor exists with different arguments #47

Open
marcprux opened this issue Jan 15, 2025 · 0 comments

Comments

@marcprux
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant