Provide a non-null type constraint for better interop with swift
See original GitHub issueDue to constraints related to how obj-c and swift handle nullable types, generic type parameters from kotlin get converted into nullable types unless they have a non-null constraint:
Reaktive suffers from the same problem: its value callbacks receive a nullable types:
Will it be possible to make this change in ValueCallback
?
interface ValueCallback<in T : Any> {
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
Interoperability with Swift/Objective-C - Kotlin
Kotlin/Native provides bidirectional interoperability with Objective-C. ... type should never be null, provide a non-null type constraint:.
Read more >Kotlin Native Interop Generics - Medium
As mentioned, however, if your Kotlin code defines a non-null constraint on a type, Objc will have non-null method/property declarations, ...
Read more >Using generic type constraints in Swift | Swift by Sundell
Using generic type constraints, we are able to add new APIs and behaviors to a type only under a certain set of constraints....
Read more >Understanding null safety - Dart
To express that, we give dairy a nullable type by slapping ? at the end of the underlying ... In cases where the...
Read more >Native - Objective-C and Swift Interop - 《Kotlin Language Guide v1 ...
Kotlin/Native interoperability with Swift/Objective-CUsageMappingsName ... if the generic type should never be null, provide a non-null type constraint:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Working on this currently. I still think that one non-null
ObservableWrapper<out T : Any>
will be better than two nullable and non-null. My points:Maybe
that helps a lot)map
they can extend just one classObservableWrapper
and add whatever needed. If there are two classes then the complexity may grow up to 4 times.Optional
may be used insteadsubscribe
methods only for one class instead of twoOverall I believe it is better to have solid and non-confusing API for most of the cases.
@mk-jones @CherryPerry @saket Waiting for your opinions!
@arkivanov Perhaps something like a NonNullObservableWrapper<T: Any>? So the user can choose how we communicate the type to swift.