Status Update
Comments
da...@google.com <da...@google.com> #2
Looks like you don't have Kotlin code generation turned on and when Room is trying to generate Java it fails when trying to generate a function override with an invalid Java identifier. I suggest you either enable Kotlin code generation since you are using KSP or continue using valid Java names in functions, properties, etc related to Room.
ma...@gmail.com <ma...@gmail.com> #3
I think it is a problem with value classes. This sample fails with the mentioned error:
@JvmInline
value class ValueClass(val string: String)
@Entity
data class Model(@PrimaryKey val value: ValueClass)
@Dao
interface ModelDao{
@Query("SELECT * FROM Model WHERE value = :valueClass")
fun find(valueClass: ValueClass): Model?
@Query("SELECT value FROM Model")
suspend fun listValueClasses(): List<ValueClass>
}
@Database(
entities = [Model::class], version = 1
)
abstract class AppDatabase : RoomDatabase() {
abstract fun modelDao(): ModelDao
}
da...@google.com <da...@google.com> #4
Did you enable Kotlin code generation? Room should be giving you a warning / error if you try to use a Value Class without enabling Kotlin codegen because otherwise its not possible to generate the right Java code to use Value / Inline Classes because their name is mangled.
ma...@gmail.com <ma...@gmail.com> #5
I'm using version 2.7.0-alpha12, the docs says it is enabled by default. It is a KMP project.
I've added the following in gradle inside:
ksp {
arg("room.generateKotlin", "true")
}
With same results
da...@google.com <da...@google.com> #6
Thanks for confirming, we'll look into this.
da...@google.com <da...@google.com> #7
Turns out this issue was actually recently fixed (as part of
da...@google.com <da...@google.com> #9
Oh, oh! Thanks for trying it out, will take a deeper look!
ko...@dumps.app <ko...@dumps.app> #10
I started seeing this too, trying to upgrade from 2.7.0-alpha11
to alpha13
(also tried alpha12
)
It looks like it's not handling suspend fun
name mangling correctly when overriding?
da...@google.com <da...@google.com> #11
I think the issue is with internal
functions and not suspend
as those are the ones that are mangled. Sorry a fix for this didn't make it to alpha13, I'll work on a fix soon.
ap...@google.com <ap...@google.com> #12
Project: platform/frameworks/support
Branch: androidx-main
Author: Daniel Santiago Rivera <
Link:
Sanitize DAO Java method names mangled by value classes.
Expand for full commit details
Sanitize DAO Java method names mangled by value classes.
Bug: 384600605
Bug: 388299754
Test: DaoKotlinCodeGenTest.kt
Change-Id: I805ae6828bf45de82f4bcec55af4528ccd16d00a
Files:
- M
room/room-compiler-processing/src/main/java/androidx/room/compiler/processing/util/NamingUtils.kt
- M
room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt
- M
room/room-compiler/src/test/test-data/kotlinCodeGen/dataClassRowAdapter_valueClassConverter.kt
Hash: 93666e398595454b46279c8ea2b8e746363971eb
Date: Wed Jan 29 15:54:02 2025
da...@google.com <da...@google.com>
pr...@google.com <pr...@google.com> #13
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.core:core-viewtree:1.0.0-rc01
androidx.room:room-compiler:2.7.0-beta01
androidx.room:room-compiler-processing:2.7.0-beta01
Description
Version used:
Version used: 2.7.0-alpha12
Ksp error due to invalid name: