-
Notifications
You must be signed in to change notification settings - Fork 380
Description
Hi there,
I tried to compile Android project using Room 3 in Alpha release status with KSP 2.3.6, but I get the following errors with ObjectA and ObjectB.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:117:66 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:117:72 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:145:12 Return type mismatch: expected 'PagingSource<Int?, ObjectC?>?', actual 'PagingSource<Int, uninferred ERROR CLASS: Cannot infer argument for type parameter T>'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:145:49 Cannot infer type for this parameter. Specify it explicitly.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:146:7 Return type mismatch: expected 'List<uninferred T (of fun <T : Any> convert)>', actual 'MutableList<ObjectC?>'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:192:52 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:192:58 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:195:12 Return type mismatch: expected 'PagingSource<Int?, ObjectC?>?', actual 'PagingSource<Int, uninferred ERROR CLASS: Cannot infer argument for type parameter T>'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:195:49 Cannot infer type for this parameter. Specify it explicitly.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectCDAO_Impl.kt:196:7 Return type mismatch: expected 'List<uninferred T (of fun <T : Any> convert)>', actual 'MutableList<ObjectC?>'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:151:66 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:151:72 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:179:12 Return type mismatch: expected 'PagingSource<Int?, ObjectB?>?', actual 'PagingSource<Int, uninferred ERROR CLASS: Cannot infer argument for type parameter T>'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:179:49 Cannot infer type for this parameter. Specify it explicitly.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:180:7 Return type mismatch: expected 'List<uninferred T (of fun <T : Any> convert)>', actual 'MutableList<ObjectB?>'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:234:52 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:234:58 Type argument is not within its bounds: must be subtype of 'Any'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:237:12 Return type mismatch: expected 'PagingSource<Int?, ObjectB?>?', actual 'PagingSource<Int, uninferred ERROR CLASS: Cannot infer argument for type parameter T>'.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:237:49 Cannot infer type for this parameter. Specify it explicitly.
e: /computer/example_app/app/build/generated/ksp/debug/kotlin/com/example/world/DAO/ObjectBDAO_Impl.kt:238:7 Return type mismatch: expected 'List<uninferred T (of fun <T : Any> convert)>', actual 'MutableList<ObjectB?>'.
I have DAO written in Java with method returning type of paging source with the referenced objects as value and Integer as key like the following:-
@Query("SELECT * FROM object_as")
PagingSource<Integer, ObjectA> pagingSource();
.....
@Query("SELECT * FROM object_bs")
PagingSource<Integer, ObjectB> pagingSource();
I tried to use " ? " as well as " Object " to annotate the generic type in place to yield " Any " inference but it didn't make difference. It looks like KSP compiler fails in inferring e.g. ObjectB to be Any when compiling Java code, since this is how it should be set in Kotlin?
I tested KSP from 2.3.4 to 2.3.6 and all produced the same error. Room 3 requires KSP compiler in Android and it looks like there is no way to fix this except if KSP handle this condition, and I wonder if there is workaround to this in Java with KSP, can't I set specific rules e.g. in Gradle?, or do I have to rewrite my codebase in Kotlin?
Any hint would be very much appreciated with thanks.
Zakaria.