https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
n

nrobi

01/22/2020, 2:54 PM
Hey, anyone had an issue with
-Xobjc-generics
? I’m getting
Any?
on iOS when I’m trying to consume some generics
Here’s my setup
k

kpgalligan

01/22/2020, 3:12 PM
What’s the Kotlin side?
n

nrobi

01/22/2020, 3:14 PM
what do you mean exactly?
v

vanniktech

01/22/2020, 3:33 PM
This is desired behavior. Your generic in Kotlin needs to be
T : Any
since just
T
could be
String?
which can be null. I also got bitten by this
Copy code
// T : Any so that Swift understands that T can never be null.
sealed class SuccessFailure<T : Any>
n

nrobi

01/22/2020, 4:08 PM
Yes but my exact problem is, that I have an expected
Observable<T>
. And if I’m trying to
observe
an
Observable<String>
for example it cannot infer the type on iOS only
Any?
k

kpgalligan

01/22/2020, 4:09 PM
By “Kotlin side” I mean what dose your kotlin code look like. Not the gradle config
What type is
Observable
?
If it’s an interface, you can’t use generics on interfaces
That and the nullability thing are a result of Objective-C generics limitations
n

nrobi

01/22/2020, 4:40 PM
I see. Yes it's an interface
Thanks
3 Views