-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
?
-
1638
-
Kotlin Realm
How frequently does the bug occur?
Always
Description
I'm migrating from realm-java to realm-kotlin and I've encountered issue similar to https://github.com/realm/realm-kotlin/issues/981.
I think that issue is that my class have two generics requiring descendants of RealmObject. -I've added example of second class with this issue at the bottom, this one has only one RealmObject generic.
Maybe issue is occuring, because type requirments are listed in "where" clouse?
Error is:
Caused by: java.lang.RuntimeException: Exception while generating code for: FUN name:
In order, for functions: equals, hashCode, toString. When I override those error is following:
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering File being compiled: /Users/zayer/git/DtsMobileApp/mobileapi/src/main/java/pl/dts/driverscenter/mobileapi/queue/requesters/order_media_add/OrderMediaAddRequester.kt ... Caused by: java.lang.RuntimeException: Exception while generating code for: FUN name:io_realm_kotlin_schema visibility:public modality:OPEN <> ($this:pl.dts.driverscenter.mobileapi.queue.requesters.order_media_add.OrderMediaAddRequester.Companion) returnType:kotlin.Any $this: VALUE_PARAMETER name:<this> type:pl.dts.driverscenter.mobileapi.queue.requesters.order_media_add.OrderMediaAddRequester.Companion ... Caused by: java.lang.IllegalStateException: Function has no body: FUN name:io_realm_kotlin_schema visibility:public modality:OPEN <> ($this:pl.dts.driverscenter.mobileapi.queue.requesters.order_media_add.OrderMediaAddRequester.Companion) returnType:kotlin.Any
Class signature is following:
class OrderMediaAddRequester( realm: Realm, mobile2Service: Mobile2Service, context: Context, listener: Listener ) : FileUploadQueueRequester<OrderMediaAddQro, OrderMediaRealmObject, ResponseEnvelope<ArrayList<Void>>>( realm, mobile2Service, context, OrderMediaAddQro::class, OrderMediaRealmObject::class, listener ) It's base class: abstract class FileUploadQueueRequester<QueueObject, MediaObject, R>( realm: Realm, protected var mobile2Service: Mobile2Service, protected var context: Context, clazz: KClass<QueueObject>, private val mediaClazz: KClass<MediaObject>, listener: Listener ) : AbstractQueueRequester<QueueObject, R>( realm, clazz, listener, true ) where QueueObject : RealmObject, QueueObject : QueueRealmObject, QueueObject : FileUploadQueueObject, MediaObject : RealmObject, MediaObject : AbstractMedia And base-base class: abstract class AbstractQueueRequester<Q, in Response>( protected val realm: Realm, protected val clazz: KClass<Q>, private val listener: Listener, val isItUploading: Boolean ) where Q : RealmObject, Q : QueueRealmObject
In FileUploadQueueRequester signature is visible that QueueObject and MediaObject both must implement RealmObject.
Second example class
class CarrierTypesSyncer( realm: Realm, mobile2Service: Mobile2Service, listener: Listener ) : SingleInstanceMobile2ServiceSyncer<CarrierTypesSyncRealmObject, CarrierTypesResponse>( realm, mobile2Service, CarrierTypesSyncRealmObject::class, listener ) Base class: abstract class SingleInstanceMobile2ServiceSyncer<S, R : ResponseEnvelope<*>?>( realm: Realm, mobile2Service: Mobile2Service, clazz: KClass<S>, listener: Listener ) : PrimitiveMobile2ServiceSyncer<S, R>( realm, mobile2Service, clazz, listener ) where S : RealmObject, S : GetterRealmObject abstract class PrimitiveMobile2ServiceSyncer<S, R : ResponseEnvelope<*>?>( realm: Realm, protected var mobile2Service: Mobile2Service, clazz: KClass<S>, listener: Listener ) : PrimitiveSyncer<S>( realm, clazz, listener ) where S : RealmObject, S : GetterRealmObject abstract class PrimitiveSyncer<S> internal constructor( protected var realm: Realm, protected val clazz: KClass<S>, private val listener: Listener ) where S : RealmObject, S : GetterRealmObject
Stacktrace & log output
Stacktrace for last error: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering File being compiled: /Users/zayer/git/DtsMobileApp/mobileapi/src/main/java/pl/dts/driverscenter/mobileapi/queue/requesters/order_media_add/OrderMediaAddRequester.kt The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:51) at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:253) at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:237) at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:65) at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:52) at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:38) at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94) at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29) at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:16) at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94) at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeCodegen(JvmIrCodegenFactory.kt:361) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runCodegen(KotlinToJVMBytecodeCompiler.kt:347) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:122) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:43) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:463) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:62) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:477) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:400) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:281) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:125) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:657) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:105) at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1624) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) at java.base/java.security.AccessController.doPrivileged(AccessController.java:714) at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:598) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:844) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:721) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:720) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583) Caused by: java.lang.RuntimeException: Exception while generating code for: FUN name:io_realm_kotlin_schema visibility:public modality:OPEN <> ($this:pl.dts.driverscenter.mobileapi.queue.requesters.order_media_add.OrderMediaAddRequester.Companion) returnType:kotlin.Any $this: VALUE_PARAMETER name:<this> type:pl.dts.driverscenter.mobileapi.queue.requesters.order_media_add.OrderMediaAddRequester.Companion at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:51) at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:43) at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethodNode(ClassCodegen.kt:390) at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethod(ClassCodegen.kt:407) at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:169) at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:182) at org.jetbrains.kotlin.backend.jvm.FileCodegen.lower(JvmPhases.kt:41) at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:120) at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:116) at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94) at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:62) ... 42 more Caused by: java.lang.IllegalStateException: Function has no body: FUN name:io_realm_kotlin_schema visibility:public modality:OPEN <> ($this:pl.dts.driverscenter.mobileapi.queue.requesters.order_media_add.OrderMediaAddRequester.Companion) returnType:kotlin.Any at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.generate(ExpressionCodegen.kt:224) at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.doGenerate(FunctionCodegen.kt:122) at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:47) ... 53 more
Can you reproduce the bug?
No
Reproduction Steps
No response
Version
1.13.0 (tried 1.11.0)
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
MacOS Sonoma 14.2.1
Build environment
Android Studio version: Hedgehog | 2023.1.1 Patch 1
Realm: 1.13.0 (tried 1.11.0)
compileSdkVersion = 34
kotlin: 1.9.22
minSdkVersion = 25
targetSdkVersion = 33
gradle = 8.2.1