Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
i think this is because koltin does not generate java stub as List<MyInteface> instead it does List<? extends MyInterface>.
We had to deal w/ this in a couple of places in room, probably just need to do the same for data binding .
We had to deal w/ this in a couple of places in room, probably just need to do the same for data binding .
Description
Version used: CompileSdkVersion / TargetSdkVersion 28, Kotlin Version 1.30, Gradle Plugin Version 3.2.1, Android Studio Version 3.2.1
Devices/Android versions reproduced on: Android Studio IDE
Binding a List of Interfaces with a type parameter is working in Java, but not in Kotlin.
The interface:
public interface MyInterface<T> {
T getValue();
}
The Java ViewModel:
public class MyViewModel {
public ObservableField<List<MyInterface>> interfaces = new ObservableField<>();
}
The Kotlin ViewModel:
class MyKotlinViewModel {
val interfaces = ObservableField<List<MyInterface<*>>>()
}
The error is error: incompatible types: Object cannot be converted to List in ActivityMainBindingImpl.java
Stackoverflow question:
An example project is here:
The branch 'master' has a Java interface - >working; the branch 'kotlin' has a Kotlin interface -> not working