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

Compilation error on generated code when using @ObjCName(swiftName = "_") #124

Closed
aoriani opened this issue Aug 7, 2023 · 1 comment
Closed
Assignees

Comments

@aoriani
Copy link

aoriani commented Aug 7, 2023

I used @ObjCName(swiftName = "_") with the goal of not requiring Swift callers to pass the parameter name. But that seems to create a problem for the code generator. It sets an empty string for the Objective-C name for the parameter

Input Code

suspend fun fetchString(@ObjCName(swiftName = "_") param: Int): String {
    println("Starting")
    delay(100)
    withContext(Dispatchers.IO) {
        println("in some IO thread")
        delay(1000)
    }
    println("back on original thread")
    return param.toString()
}

Generated Code

@OptIn(ExperimentalObjCName::class)
@ObjCName(name = "fetchString")
public fun fetchStringNative(@ObjCName(name = "", swiftName = "_") `param`: Int):
    NativeSuspend<String> = nativeSuspend(null) { fetchString(`param`) }

Compiler error

Empty @ObjCName names aren't supported
@rickclephas rickclephas self-assigned this Aug 7, 2023
rickclephas added a commit that referenced this issue Aug 7, 2023
@rickclephas
Copy link
Owner

Thanks for the report! This has been fixed in v1.0.0-ALPHA-14.

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

2 participants