Skip to content

Commit

Permalink
Remove warning in task :kotlin:compileKotlin (#4368)
Browse files Browse the repository at this point in the history
Motivation:

Noticed some warnings while building the project:

`> Task :kotlin:compileKotlin
w: Argument -Xopt-in is deprecated. Please use -opt-in instead
w: /Users/wjdalstn/Documents/GitHub/armeria/kotlin/src/main/kotlin/com/linecorp/armeria/client/kotlin/CoroutineRestClient.kt: (33, 12): Type parameter 'T' has nullable upper bounds while non-nullable version is expected. This warning will become an error soon. See https://youtrack.jetbrains.com/issue/KT-36770 for details
w: /Users/wjdalstn/Documents/GitHub/armeria/kotlin/src/main/kotlin/com/linecorp/armeria/client/kotlin/CoroutineRestClient.kt: (33, 20): Type parameter 'T' has nullable upper bounds while non-nullable version is expected. This warning will become an error soon. See https://youtrack.jetbrains.com/issue/KT-36770 for details
w: /Users/wjdalstn/Documents/GitHub/armeria/kotlin/src/main/kotlin/com/linecorp/armeria/client/kotlin/CoroutineRestClient.kt: (41, 12): Type parameter 'T' has nullable upper bounds while non-nullable version is expected. This warning will become an error soon. See https://youtrack.jetbrains.com/issue/KT-36770 for details
w: /Users/wjdalstn/Documents/GitHub/armeria/kotlin/src/main/kotlin/com/linecorp/armeria/client/kotlin/CoroutineRestClient.kt: (41, 20): Type parameter 'T' has nullable upper bounds while non-nullable version is expected. This warning will become an error soon. See https://youtrack.jetbrains.com/issue/KT-36770 for details`

Perhaps something related to the definitly non nullable types feature since kotlin 1.6.20

Modifications:

- Providing upper bound Any removes the warning

Result:

no warnings!
  • Loading branch information
mscheong01 authored Jul 28, 2022
1 parent 7395a2e commit 86922b2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import kotlinx.coroutines.future.await
*
* @see JacksonObjectMapperProvider
*/
suspend inline fun <reified T> RestClientPreparation.execute(): ResponseEntity<T> {
suspend inline fun <reified T : Any> RestClientPreparation.execute(): ResponseEntity<T> {
return execute(object : TypeReference<T>() {}).await()!!
}

/**
* Sends the HTTP request and converts the JSON response body as the `T` object using the specified
* [ObjectMapper].
*/
suspend inline fun <reified T> RestClientPreparation.execute(mapper: ObjectMapper): ResponseEntity<T> {
suspend inline fun <reified T : Any> RestClientPreparation.execute(mapper: ObjectMapper): ResponseEntity<T> {
return execute(object : TypeReference<T>() {}, mapper).await()!!
}

0 comments on commit 86922b2

Please sign in to comment.