Fixed
Status Update
Comments
el...@google.com <el...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit e1b4be5ef6f009bd83740cdb2be1877511475c46
Author: pingxuanli <pingxuanli@google.com>
Date: Mon Aug 15 13:45:21 2022
Removed the restriction for Upsert annotation
Bug: 241964353
Test: Tests for @Upsert Annotation are in `UpsertTest.kt` file
Relnote: Adding @Upsert Annotation, which attempt to insert an entity when there is no conflict and update the entity if there is a conflict.
Change-Id: I7aaab5416551ed70e0130a60b6b629a531757a16
M room/room-common/api/current.txt
M room/room-common/src/main/java/androidx/room/Upsert.kt
M room/room-common/api/public_plus_experimental_current.txt
M room/room-common/api/restricted_current.txt
https://android-review.googlesource.com/2184904
Branch: androidx-main
commit e1b4be5ef6f009bd83740cdb2be1877511475c46
Author: pingxuanli <pingxuanli@google.com>
Date: Mon Aug 15 13:45:21 2022
Removed the restriction for Upsert annotation
Bug: 241964353
Test: Tests for @Upsert Annotation are in `UpsertTest.kt` file
Relnote: Adding @Upsert Annotation, which attempt to insert an entity when there is no conflict and update the entity if there is a conflict.
Change-Id: I7aaab5416551ed70e0130a60b6b629a531757a16
M room/room-common/api/current.txt
M room/room-common/src/main/java/androidx/room/Upsert.kt
M room/room-common/api/public_plus_experimental_current.txt
M room/room-common/api/restricted_current.txt
da...@google.com <da...@google.com>
pr...@google.com <pr...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 40e15ece328da2b94a516610ecda8541ad776086
Author: pingxuanli <pingxuanli@google.com>
Date: Tue Aug 16 16:56:06 2022
Adding SuspendingQueryTest for @Upsert including upsert without returns and upsert with Long and List<Long> as return types
Bug: 241964353
Test: The tests for upsert with suspend is inside file `SuspendingQueryTest`
Change-Id: I4996de64884651c245ab144e3481d027382c86e3
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/dao/BooksDao.kt
https://android-review.googlesource.com/2188580
Branch: androidx-main
commit 40e15ece328da2b94a516610ecda8541ad776086
Author: pingxuanli <pingxuanli@google.com>
Date: Tue Aug 16 16:56:06 2022
Adding SuspendingQueryTest for @Upsert including upsert without returns and upsert with Long and List<Long> as return types
Bug: 241964353
Test: The tests for upsert with suspend is inside file `SuspendingQueryTest`
Change-Id: I4996de64884651c245ab144e3481d027382c86e3
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/dao/BooksDao.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.