-
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
When a static function has a varargs parameter, the companion function needs to use the spread ("*") operator to correctly pass the parameter through to its companion object implementation.
E.g., the following Swift:
public class AndroidBridge {
public static func initBridge(context: android.content.Context, _ libraryNames: String...) throws {
}
transpiles to the Kotlin:
open class AndroidBridge {
companion object: CompanionClass() {
override fun initBridge(context: android.content.Context, vararg libraryNames: String) {
}
open class CompanionClass {
open fun initBridge(context: android.content.Context, vararg libraryNames: String) = AndroidBridge.initBridge(context = context, libraryNames)
}
}This results in the compile error:
Argument type mismatch: actual type is 'kotlin.Array<CapturedType(out kotlin.String)>', but 'kotlin.String' was expected.
I think we just need to add the spread operator to the parameter, i.e.:
open fun initBridge(context: android.content.Context, vararg libraryNames: String) = AndroidBridge.initBridge(context = context, *libraryNames)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels