Evaluate Expression in Android Studio does not work correctly with Realm Objects
See original GitHub issueTyping this in the Evaluate Expression window in the debugger in Android studio
aRealmObject.someRealmList.first()
throws a NoSuchElementException: List is empty, when the realm list really isn’t empty.
Android Studio Bumblebee | 2021.1.1 Patch 1 Build #AI-211.7628.21.2111.8139111, built on February 2, 2022 Runtime version: 11.0.11+0-b60-7590822 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 12.0.1 GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 16 Registry: external.system.auto.import.disabled=true Non-Bundled Plugins: com.chimerapps.proguard-retrace (1.0.1), com.cmgapps.intellij.proguard-retrace-unscambler (1.3.0), wu.seal.tool.jsontokotlin (3.7.2), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40)
realm version 0.7.0 (we currently can’t upgrade higher than this due to kotlin 1.6 issues.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (2 by maintainers)
Top GitHub Comments
After some more digging. I now suspect it is a problem in our generated code somehow:
In this class, the
ignoreMe
field works as expected when evaluating, while all the managed properties do not.There is a few changes in the generated IR, especially this block is present in our generated accessors
BLOCK type=kotlin.Nothing origin=null
while it isn’t in the default one…but not sure what it does nor if it even makes a difference.The same problem is also in present in Android Studio Dolphin Canary 5.
I did find work-around though. If you switch to Java in the dropdown, you can manually call the getters, which will do the correct thing, e.g.
book.getAuthors()
instead ofbook.authors
.