Stephan Schröder
08/23/2023, 11:51 AMinline fun <reified T : Any> RestTemplate.getForObject(path: String): T? {
return this.getForObject(path, T::class.java)
}
but the RestTemplate.getForObject is a nullable Java function:
@Nullable
public <T> T getForObject(String url, Class<T> responseType, Object... uriVariables) throws RestClientException {
Is this a type inference bug/confusion?Sam
08/23/2023, 12:13 PMT, and no warning if I follow the suggestion to change it to T?. What versions of Spring/Kotlin/IntelliJ are you using?Stephan Schröder
08/23/2023, 2:20 PMxoangon
08/23/2023, 2:43 PMT can be nullable in Kotlin. Using T? is redundant, so I can figure that's the reason for the warningMichael de Kaste
08/23/2023, 2:43 PMSam
08/23/2023, 2:45 PMT isn’t specified as non-null, T and T? are still different. Unbounded T is maybe-nullable, and T? is definitely-nullable.xoangon
08/23/2023, 2:46 PMAny boundMichael de Kaste
08/23/2023, 2:52 PMStephan Schröder
08/24/2023, 2:06 PM