Fixed
Status Update
Comments
el...@google.com <el...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
Description
Component used: room-runtime Version used: 2.5.1 Devices/Android versions reproduced on: N/A
After upgrading a project from Room 2.4.2 to 2.5.1, I noticed a new compilation failure when setting a minimal repro project where the first and second commits compare room 2.4.2 and 2.5.1. My theory is below.
QueryCallback
on our Room database. Since this upgrade moved us to a Room version written in Kotlin for the first time, I have a theory about the cause. I've also added aWe had been using a lambda for our callback, along the lines of:
This worked, presumably, because the compiler performed a single-abstract-method (SAM) conversion and treated the lambda expression as an implementation of
QueryCallback.onQuery
.Following the Room upgrade to Kotlin for its own code, I believe this conversion no longer occurs. Kotlin supports SAM conversions for Kotlin interfaces , but they must be declared as .
fun interface Foo
rather than justinterface Foo
. As of 2.5.2,QueryCallback
is just aninterface
This isn't blocking, strictly. We can instead construct an object implementing
QueryCallback
in place of the lambda:But in addition to being more verbose, I found I had to add a
-Xjvm-default=enable
compiler flag to our project so that the interface implementation would compile. Ideally we'd be able to continue relying on SAM conversion and write a lambda instead.