hi. the last weeks i played a little bit with kotlin in android. i am really like kotlin but i stuck with a problem writing custom delegates. i use parse (
parse.com) and want to write a delegate for getters and setters of ParseObjects
object ParseDelegates {
fun parseValue<R : ParseObject, T : Any?>(): ReadWriteProperty<R, T> = ParseValue()
}
private class ParseValue<R : ParseObject, T : Any?> : ReadWriteProperty<R, T> {
override fun get(thisRef: R, property: PropertyMetadata): T {
return thisRef.get(property.name) <— PROBLEM
}
override fun set(thisRef: R, property: PropertyMetadata, value: T) {
thisRef.put(property.name, value)
}
}
the problem is in the get function.
Type mismatch: Required: T - Found: kotlin.Any!
can someone explain me why and how to solve this