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 9910fe80634b9a4c78cdbd4d1b2c2f13caa75571
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed May 17 13:58:46 2023
Define QueryCallback as a functional interface
Bug: 281008549
Test: Existing
Relnote: Define RoomDatabase.QueryCallback as a functional interface to allow SAM conversion usages.
Change-Id: Iab8eafa11bf7f6fde9d6c0a7ce7e2933cd248841
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/QueryInterceptorTest.kt
M room/room-runtime/api/current.txt
M room/room-runtime/api/restricted_current.txt
M room/room-runtime/src/main/java/androidx/room/RoomDatabase.kt
https://android-review.googlesource.com/2594891
Branch: androidx-main
commit 9910fe80634b9a4c78cdbd4d1b2c2f13caa75571
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed May 17 13:58:46 2023
Define QueryCallback as a functional interface
Bug: 281008549
Test: Existing
Relnote: Define RoomDatabase.QueryCallback as a functional interface to allow SAM conversion usages.
Change-Id: Iab8eafa11bf7f6fde9d6c0a7ce7e2933cd248841
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/QueryInterceptorTest.kt
M room/room-runtime/api/current.txt
M room/room-runtime/api/restricted_current.txt
M room/room-runtime/src/main/java/androidx/room/RoomDatabase.kt
da...@google.com <da...@google.com>
pr...@google.com <pr...@google.com> #3
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-runtime:2.6.0-alpha02
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.