Hello, When compiling for mac (using `./gradlew l...
# kotlin-native
t
Hello, When compiling for mac (using
./gradlew linkNative
) I get an error when I return
null
in a function, such as:
Copy code
// commonMain
interface GetManufacturerUseCase {
    operator fun invoke(): String?
}
Copy code
// nativeMain
class GetManufacturerUseCaseImpl : GetManufacturerUseCase {
    override fun invoke() = null
}
It produces this error
Copy code
/var/folders/v4/tsnbm2mj12qcqd5mzx022z0m0000gp/T/konan_temp15915856283221827637/api.cpp:482:21: error: unknown type name 'libNative_kref_kotlin_Nothing'; did you mean 'libNative_kref_kotlin_Long'?
                    libNative_kref_kotlin_Nothing (*invoke)(libNative_kref_com_me_myproject_deviceInfo_domain_usecase_GetManufacturerUseCaseImpl thiz);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    libNative_kref_kotlin_Long
To fix it, I return an empty string đŸ˜• But that’s not really what I want. Is this a bug, or a limitation?
e
have you tried
Copy code
override fun invoke(): String? = null
? the
null
is inferred to be
Nothing?
if not given a narrower type, and it seems that isn't interoperable
t
Thanks @ephemient, that was it. It worked. Since it was working on iOS targets, I assume it would be the case here too. Thanks again!