I am using Realm and it needs an open keyword for model classes.
Following https://blog.jetbrains.com/kotlin/2016/12/kotlin-1-0-6-is-here/ , I tried using a pop-up compiler plugin to remove the open keyword from the classes of the Realm model.
First, I added a compiler popup plugin and set the annotation package name
buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version" } } apply plugin: "kotlin-allopen" allOpen { annotation("com.mycompany.myapp.annotation") }
Secondly, I generated an annotation
package com.mycompany.myapp.annotation annotation class AllOpenAnnotation
Finally, I added an annotation to the Realm model class
@AllOpenAnnotation class Model { var id: Int = -1, var title: String = "", var desc: String? = null }: RealmObject()
But an error occurs error: cannot inherit from final Model .
Is there something I did wrong?
source share