Switch MongoOperations.updateMulti Kotlin extension function to accept a more generic UpdateDefinition #4153
Labels
status: ideal-for-contribution
An issue that a contributor can help us with
type: enhancement
A general enhancement
Milestone
Today I was surprised, that I can't express the same update with Kotlin, which I can express with Java's MongoOperations API. My code was
Usually Kotlin extension allows me to write the same code, but without ugly
::class.java
. So I would expect the following to work:but it does not compile.
The reason is that the signature of Kotlin extension for
MongoOperations
is different from the one defined on the originalMongoOperations
interface method:spring-data-mongodb/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/MongoOperationsExtensions.kt
Lines 538 to 540 in 3342c75
spring-data-mongodb/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java
Line 1511 in 3342c75
The Kotlin extension accepts a more narrow type
org.springframework.data.mongodb.core.query.Update
type, while the Java interface accepts a more genericorg.springframework.data.mongodb.core.query.UpdateDefinition
.By looking at the implementation of the Kotlin extension, I see not reasons for it to accept a different type. So, I think the type accepted by Kotlin extension function should be aligned with the one defined on the original interface it extends.
The text was updated successfully, but these errors were encountered: