realm-kotlin
realm-kotlin copied to clipboard
Vague "Cannot find Primary Constructor" compile error
Got this error:
e: java.lang.IllegalStateException: Can not find primary constructor
at io.realm.compiler.RealmModelSyntheticPropertiesGeneration$addNewInstanceMethodBody$1.invoke(RealmModelSyntheticPropertiesGeneration.kt:477)
at io.realm.compiler.RealmModelSyntheticPropertiesGeneration$addNewInstanceMethodBody$1.invoke(RealmModelSyntheticPropertiesGeneration.kt:475)
at io.realm.compiler.IrUtilsKt.blockBody(IrUtils.kt:98)
at io.realm.compiler.RealmModelSyntheticPropertiesGeneration.addNewInstanceMethodBody(RealmModelSyntheticPropertiesGeneration.kt:475)
at io.realm.compiler.RealmModelLowering.lower(RealmModelLoweringExtension.kt:77)
at org.jetbrains.kotlin.backend.common.ClassLoweringVisitor.visitClass(Lower.kt:82)
Kinda hard to debug without more information. We should also add the Class being modified to the exception message.
The cause is this code like this:
class Person : RealmObject {
constructor() { }
constructor(input: String) { }
}
We still require a no-op constructor in order to create objects on the user's behalf, but forcing the no-op to be the primary constructor seems a bit odd.... Instead we should probably search all viable constructors and only then report the error?
Verify if this is fixed
Not fully on top of this, but seems like the work that I thought fixed this (#184/#673) was done prior to this issue being reported so assume there is still something to do.