Follow-up CL to the change at aosp/1524200 to add named arguments for better practice.
Test: No new tests needed, re-ran tests in TypeAdapterStoreTest.kt
Bug: 174335952
Change-Id: Ib07d3c63deec9343cbe927bb4e8a0dcb993513e8
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
index 9d0d99b..1201596 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
@@ -60,7 +60,11 @@
ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_ENTITY_FIELDS
)
- val adapter = context.typeAdapterStore.findColumnTypeAdapter(member, affinity, false)
+ val adapter = context.typeAdapterStore.findColumnTypeAdapter(
+ member,
+ affinity,
+ skipEnumConverter = false
+ )
val adapterAffinity = adapter?.typeAffinity ?: affinity
val nonNull = Field.calcNonNull(member, fieldParent)
diff --git a/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt b/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
index 4196bae..85d3d47 100644
--- a/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
@@ -260,7 +260,7 @@
if (output.isError()) {
return null
}
- val adapter = findColumnTypeAdapter(output, affinity, true)
+ val adapter = findColumnTypeAdapter(output, affinity, skipEnumConverter = true)
if (adapter != null) {
// two way is better
return adapter
diff --git a/room/compiler/src/test/kotlin/androidx/room/solver/BasicColumnTypeAdaptersTest.kt b/room/compiler/src/test/kotlin/androidx/room/solver/BasicColumnTypeAdaptersTest.kt
index 704310f..67313ab 100644
--- a/room/compiler/src/test/kotlin/androidx/room/solver/BasicColumnTypeAdaptersTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/solver/BasicColumnTypeAdaptersTest.kt
@@ -105,7 +105,11 @@
fun bind() {
simpleRun { invocation ->
val adapter = TypeAdapterStore.create(Context(invocation.processingEnv))
- .findColumnTypeAdapter(input.getTypeMirror(invocation.processingEnv), null, false)!!
+ .findColumnTypeAdapter(
+ input.getTypeMirror(invocation.processingEnv),
+ null,
+ skipEnumConverter = false
+ )!!
adapter.bindToStmt("st", "6", "inp", scope)
assertThat(scope.generate().toString().trim(), `is`(bindCode))
generateCode(invocation, false)
@@ -120,7 +124,8 @@
simpleRun { invocation ->
val adapter = TypeAdapterStore.create(Context(invocation.processingEnv))
.findColumnTypeAdapter(
- input.getBoxedTypeMirror(invocation.processingEnv), null, false
+ input.getBoxedTypeMirror(invocation.processingEnv), null,
+ skipEnumConverter = false
)!!
adapter.bindToStmt("st", "6", "inp", scope)
assertThat(
@@ -162,7 +167,11 @@
fun read() {
simpleRun { invocation ->
val adapter = TypeAdapterStore.create(Context(invocation.processingEnv))
- .findColumnTypeAdapter(input.getTypeMirror(invocation.processingEnv), null, false)!!
+ .findColumnTypeAdapter(
+ input.getTypeMirror(invocation.processingEnv),
+ null,
+ skipEnumConverter = false
+ )!!
adapter.readFromCursor("out", "crs", "9", scope)
assertThat(scope.generate().toString().trim(), `is`(cursorCode))
generateCode(invocation, false)
@@ -177,7 +186,9 @@
simpleRun { invocation ->
val adapter = TypeAdapterStore.create(Context(invocation.processingEnv))
.findColumnTypeAdapter(
- input.getBoxedTypeMirror(invocation.processingEnv), null, false
+ input.getBoxedTypeMirror(invocation.processingEnv),
+ null,
+ skipEnumConverter = false
)!!
adapter.readFromCursor("out", "crs", "9", scope)
assertThat(
diff --git a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
index 3b8ff54..db5f32a 100644
--- a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
@@ -72,7 +72,11 @@
runProcessorTest { invocation ->
val store = TypeAdapterStore.create(Context(invocation.processingEnv))
val primitiveType = invocation.processingEnv.requireType(TypeName.INT)
- val adapter = store.findColumnTypeAdapter(primitiveType, null, false)
+ val adapter = store.findColumnTypeAdapter(
+ primitiveType,
+ null,
+ skipEnumConverter = false
+ )
assertThat(adapter, notNullValue())
}
}
@@ -87,7 +91,11 @@
.processingEnv
.requireType("java.lang.Boolean")
.makeNullable()
- val adapter = store.findColumnTypeAdapter(boolean, null, false)
+ val adapter = store.findColumnTypeAdapter(
+ boolean,
+ null,
+ skipEnumConverter = false
+ )
assertThat(adapter, notNullValue())
assertThat(adapter, instanceOf(CompositeAdapter::class.java))
val composite = adapter as CompositeAdapter
@@ -121,7 +129,7 @@
val enum = invocation
.processingEnv
.requireType("foo.bar.Fruit")
- val adapter = store.findColumnTypeAdapter(enum, null, false)
+ val adapter = store.findColumnTypeAdapter(enum, null, skipEnumConverter = false)
assertThat(adapter, notNullValue())
assertThat(adapter, instanceOf(EnumColumnTypeAdapter::class.java))
}
@@ -132,7 +140,11 @@
runProcessorTest { invocation ->
val store = TypeAdapterStore.create(Context(invocation.processingEnv))
val booleanType = invocation.processingEnv.requireType(TypeName.BOOLEAN)
- val adapter = store.findColumnTypeAdapter(booleanType, null, false)
+ val adapter = store.findColumnTypeAdapter(
+ booleanType,
+ null,
+ skipEnumConverter = false
+ )
assertThat(adapter, notNullValue())
assertThat(adapter, instanceOf(CompositeAdapter::class.java))
val bindScope = testCodeGenScope()
@@ -194,7 +206,11 @@
pointTypeConverters(invocation.processingEnv)
)
val pointType = invocation.processingEnv.requireType("foo.bar.Point")
- val adapter = store.findColumnTypeAdapter(pointType, null, false)
+ val adapter = store.findColumnTypeAdapter(
+ pointType,
+ null,
+ skipEnumConverter = false
+ )
assertThat(adapter, notNullValue())
assertThat(adapter, instanceOf(CompositeAdapter::class.java))
@@ -269,7 +285,11 @@
binders[1]
)
- val adapter = store.findColumnTypeAdapter(binders[0].from, null, false)
+ val adapter = store.findColumnTypeAdapter(
+ binders[0].from,
+ null,
+ skipEnumConverter = false
+ )
assertThat(adapter, notNullValue())
val bindScope = testCodeGenScope()
@@ -303,7 +323,11 @@
runProcessorTest { invocation ->
val binders = createIntListToStringBinders(invocation)
val store = TypeAdapterStore.create(Context(invocation.processingEnv), binders[0])
- val adapter = store.findColumnTypeAdapter(binders[0].from, null, false)
+ val adapter = store.findColumnTypeAdapter(
+ binders[0].from,
+ null,
+ skipEnumConverter = false
+ )
assertThat(adapter, nullValue())
val stmtBinder = store.findStatementValueBinder(binders[0].from, null)