Browse Source

Let Kotlin repository generics extend `Any`.

The move to Kotlin 2.x introduces warnings in the Kotlin extensions for type arguments tha are not within their bounds (i.e. `Thing<T>` should be `Thing<T : Any>`). This commit fixes these cases and removes the warnings.

Signed-off-by: Chris Bono <chris.bono@broadcom.com>
Closes #3309
pull/3314/head
Chris Bono 6 months ago committed by Mark Paluch
parent
commit
06a98db984
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 2
      src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt
  2. 2
      src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepository.kt
  3. 2
      src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineSortingRepository.kt

2
src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt

@ -24,4 +24,4 @@ package org.springframework.data.repository @@ -24,4 +24,4 @@ package org.springframework.data.repository
* @author Oscar Hernandez
* @since 2.1.4
*/
fun <T, ID: Any> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id).orElse(null)
fun <T: Any, ID: Any> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id).orElse(null)

2
src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepository.kt

@ -37,7 +37,7 @@ import reactor.core.publisher.Mono @@ -37,7 +37,7 @@ import reactor.core.publisher.Mono
* @see Flow
*/
@NoRepositoryBean
interface CoroutineCrudRepository<T, ID> : Repository<T, ID> {
interface CoroutineCrudRepository<T: Any, ID: Any> : Repository<T, ID> {
/**
* Saves a given entity. Use the returned instance for further operations as the save operation might have changed the

2
src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineSortingRepository.kt

@ -34,7 +34,7 @@ import org.springframework.data.repository.Repository @@ -34,7 +34,7 @@ import org.springframework.data.repository.Repository
* @see CoroutineCrudRepository
*/
@NoRepositoryBean
interface CoroutineSortingRepository<T, ID> : Repository<T, ID> {
interface CoroutineSortingRepository<T: Any, ID: Any> : Repository<T, ID> {
/**
* Returns all entities sorted by the given options.

Loading…
Cancel
Save