Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
yea we should probably special case these to find the instance. meanwhile, quick workaround is to mark those methods JVMStatic.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 8dd4a965ebf301007a75fa26ab77dd7c53f0e043
Author: Yigit Boyar <yboyar@google.com>
Date: Tue Jun 02 16:11:22 2020
Support TypeConverters on kotlin objects
This CL adds support for having @TypeConverter annotated methods
on kotlin objects.
I also noticed that KotlinMetadata tests were not running as they dont
trigger the compilation. Fixed them as well.
Bug: 151110764
Test: KotlinTestApp, KotlinMetadataElementTest
Change-Id: I93eb2ff7162706ff7538159a748ecbe62bb1d9fe
M room/compiler/src/main/kotlin/androidx/room/kotlin/KotlinClassMetadataUtils.kt
M room/compiler/src/main/kotlin/androidx/room/kotlin/KotlinMetadataElement.kt
M room/compiler/src/main/kotlin/androidx/room/processor/CustomConverterProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/types/CustomTypeConverterWrapper.kt
M room/compiler/src/main/kotlin/androidx/room/vo/CustomTypeConverter.kt
M room/compiler/src/test/kotlin/androidx/room/kotlin/KotlinMetadataElementTest.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/vo/DateConverter.kt
https://android-review.googlesource.com/1323097
Branch: androidx-master-dev
commit 8dd4a965ebf301007a75fa26ab77dd7c53f0e043
Author: Yigit Boyar <yboyar@google.com>
Date: Tue Jun 02 16:11:22 2020
Support TypeConverters on kotlin objects
This CL adds support for having @TypeConverter annotated methods
on kotlin objects.
I also noticed that KotlinMetadata tests were not running as they dont
trigger the compilation. Fixed them as well.
Bug: 151110764
Test: KotlinTestApp, KotlinMetadataElementTest
Change-Id: I93eb2ff7162706ff7538159a748ecbe62bb1d9fe
M room/compiler/src/main/kotlin/androidx/room/kotlin/KotlinClassMetadataUtils.kt
M room/compiler/src/main/kotlin/androidx/room/kotlin/KotlinMetadataElement.kt
M room/compiler/src/main/kotlin/androidx/room/processor/CustomConverterProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/types/CustomTypeConverterWrapper.kt
M room/compiler/src/main/kotlin/androidx/room/vo/CustomTypeConverter.kt
M room/compiler/src/test/kotlin/androidx/room/kotlin/KotlinMetadataElementTest.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/vo/DateConverter.kt
Description
The output generated by the Room processor for this input won't compile, because the generated Java tries to "new" the object expression type:
```kt
@Database(entities = [FooEntity::class], version = 1, exportSchema = false)
internal abstract class FooDatabase : RoomDatabase() {
abstract fun fooDao(): FooDao
}
@Entity(tableName = "foo")
@TypeConverters(FooTypeConverters::class)
data class FooEntity internal constructor(
@PrimaryKey val id: Int,
val proto: SomeProto
)
object FooTypeConverters {
@TypeConverter
fun toSomeProto(bytes: ByteArray): SomeProto {
return SomeProto.parseFrom(bytes)
}
@TypeConverter
fun toBytes(someProto: SomeProto): ByteArray {
return someProto.toByteArray()
}
}
```