Open beeender opened 8 years ago
This is a huge limitation. It seems you cannot use delegated properties with ANY Realm properties – making Realm effectively incompatible with Kotlin.
Not only do Realm annotations not work on (Annotation processor error: "This annotation is not applicable to target 'member property with delegate'"), but because Delegated properties are themselves final (the delegated property proxy object does not itself get changed after initial assignment), Realm throws annotation processing error: "Final fields are not allowed. Class: Chat, Field: messages$delegate"
How are you supposed to do custom setters on Realm objects?
As @davidgarciaanton mentioned in https://github.com/realm/realm-java/issues/4185, you can use @delegate:Ignore
like this:
open class EnabledEngine : RealmObject {
@delegate:Ignore
val engine: SearchEngine by lazy {
searchEngines[id]!!
}
}
Check the Kotlin docs on Annotation Use-site Targets
Not working in the latest with "'@delegate:' annotations could be applied only to delegated properties". Any workaround for this?
Without
@Ignore
a build error will occur since final property cannot pass annotation process