Tactical fix for Explorer crash issue under Kotlin 1.1.1. Original code compiles, but then throws a typecast expression at runtime when trying to process the lambdas.

Update docs
This commit is contained in:
Matthew Nesbit 2017-03-30 09:44:33 +01:00
parent c7e5cf5079
commit 0695374d72

View File

@ -111,8 +111,14 @@ fun <A> ObservableList<out A>.filter(predicate: ObservableValue<(A) -> Boolean>)
* val owners: ObservableList<Person> = dogs.map(Dog::owner).filterNotNull()
*/
fun <A> ObservableList<out A?>.filterNotNull(): ObservableList<A> {
//TODO This is a tactical work round for an issue with SAM conversion (https://youtrack.jetbrains.com/issue/ALL-1552) so that the M10 explorer works.
@Suppress("UNCHECKED_CAST")
return filtered { it != null } as ObservableList<A>
return (this as ObservableList<A?>).filtered(object : Predicate<A?> {
override fun test(t: A?): Boolean {
return t != null
}
}) as ObservableList<A>
}
/**