-
Notifications
You must be signed in to change notification settings - Fork 18
Description
When using @throws on a Kotlin function with default arguments and enabling DefaultArgumentInterop.Enabled(true), Skie generates overloads for Swift/ObjC interop — however, those generated overloads do not preserve the @throws annotation.
This leads to unsafe Swift interop:
• Swift only requires try on the full-parameter version (which carries @throws).
• The overloads (with fewer parameters) can still throw, but Swift is unaware, so no try is enforced — which may result in runtime crashes.
@throws(MyException::class)
fun riskyOperation(x: Int = 0) {
if (x < 0) throw MyException()
}
With DefaultArgumentInterop.Enabled(true), Skie generates:
• fun riskyOperation() (calls riskyOperation(0))
• fun riskyOperation(x: Int)
Only the latter has @throws. The zero-argument overload is missing the annotation — despite being capable of throwing the same exception.
In Swift:
try? MyModuleKt.riskyOperation(x: -1) // works as expected
MyModuleKt.riskyOperation() // compiles without try, but crashes if exception is thrown
All Skie-generated overloads for functions annotated with @throws should also carry that annotation to ensure Swift/ObjC properly enforce error handling.