Skip to content

Commit 06a98db

Browse files
onobcmp911de
authored andcommitted
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
1 parent f28a2c2 commit 06a98db

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ package org.springframework.data.repository
2424
* @author Oscar Hernandez
2525
* @since 2.1.4
2626
*/
27-
fun <T, ID: Any> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id).orElse(null)
27+
fun <T: Any, ID: Any> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id).orElse(null)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import reactor.core.publisher.Mono
3737
* @see Flow
3838
*/
3939
@NoRepositoryBean
40-
interface CoroutineCrudRepository<T, ID> : Repository<T, ID> {
40+
interface CoroutineCrudRepository<T: Any, ID: Any> : Repository<T, ID> {
4141

4242
/**
4343
* Saves a given entity. Use the returned instance for further operations as the save operation might have changed the

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import org.springframework.data.repository.Repository
3434
* @see CoroutineCrudRepository
3535
*/
3636
@NoRepositoryBean
37-
interface CoroutineSortingRepository<T, ID> : Repository<T, ID> {
37+
interface CoroutineSortingRepository<T: Any, ID: Any> : Repository<T, ID> {
3838

3939
/**
4040
* Returns all entities sorted by the given options.

0 commit comments

Comments
 (0)