There’s something doable in Java with generics I c...
# announcements
d
There’s something doable in Java with generics I cannot seem to find a way to do in Kotlin :
Copy code
class Observable<T> {
  T get() { }
  void subscribe(Subscriber<? super T> s) { }
}

Observable<String> obs = //…
Subscriber<CharSequence> sub = //...

Observable<? extends CharSequence> obsView = obs;
obsView.subscribe(sub);
Any way to write the 2 last lines in Kotlin ? I don’t think it’s unsafe, just that in Kotlin I would try with projections and since they loose the original parameter type (
String
here) the compiler cannot infer the safety of the call to
subscribe()
(and hides it anyway). Am I missing something ??