diff --git a/pom.xml b/pom.xml
index 3fa54424af..3132a77e6e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -166,5 +166,18 @@
https://repo.spring.io/milestone
-
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
+
+
+ -Xallow-kotlin-package
+
+
+
+
+
diff --git a/spring-data-mongodb/src/main/kotlin/kotlin/internal/OnlyInputTypes.kt b/spring-data-mongodb/src/main/kotlin/kotlin/internal/OnlyInputTypes.kt
new file mode 100644
index 0000000000..f9e1223fa8
--- /dev/null
+++ b/spring-data-mongodb/src/main/kotlin/kotlin/internal/OnlyInputTypes.kt
@@ -0,0 +1,5 @@
+package kotlin.internal
+
+@Target(AnnotationTarget.TYPE_PARAMETER)
+@Retention(AnnotationRetention.BINARY)
+internal annotation class OnlyInputTypes
\ No newline at end of file
diff --git a/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/CriteriaExtensions.kt b/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/CriteriaExtensions.kt
index f3e8c5c6b7..822fd23d0d 100644
--- a/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/CriteriaExtensions.kt
+++ b/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/CriteriaExtensions.kt
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package org.springframework.data.mongodb.core.query
import org.springframework.data.mapping.toDotPath
+import kotlin.internal.OnlyInputTypes
import kotlin.reflect.KProperty
/**
@@ -32,7 +34,7 @@ fun Criteria.isEqualTo(o: Any?): Criteria = `is`(o)
* @author Sebastien Deleuze
* @since 2.0
*/
-fun Criteria.inValues(c: Collection): Criteria = `in`(c)
+fun <@OnlyInputTypes T : Any?> Criteria.inValues(c: Collection): Criteria = `in`(c)
/**
* Extension for [Criteria.in] providing an `inValues` alias since `in` is a reserved keyword in Kotlin.
diff --git a/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedCriteriaExtensions.kt b/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedCriteriaExtensions.kt
index ee1c102b6d..f066bf8600 100644
--- a/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedCriteriaExtensions.kt
+++ b/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedCriteriaExtensions.kt
@@ -23,6 +23,8 @@ import org.springframework.data.mapping.toDotPath
import org.springframework.data.mongodb.core.geo.GeoJson
import org.springframework.data.mongodb.core.schema.JsonSchemaObject
import java.util.regex.Pattern
+import kotlin.internal.OnlyInputTypes
+import kotlin.reflect.KMutableProperty
import kotlin.reflect.KProperty
/**
@@ -31,7 +33,7 @@ import kotlin.reflect.KProperty
* @since 2.2
* @see Criteria.isEqualTo
*/
-infix fun KProperty.isEqualTo(value: T) =
+infix fun KMutableProperty.isEqualTo(value: T) =
Criteria(this.toDotPath()).isEqualTo(value)
/**
@@ -42,7 +44,7 @@ infix fun KProperty.isEqualTo(value: T) =
* @since 2.2
* @see Criteria.ne
*/
-infix fun KProperty.ne(value: T): Criteria =
+infix fun <@OnlyInputTypes T> KProperty.ne(value: T): Criteria =
Criteria(this.toDotPath()).ne(value)
/**
@@ -53,7 +55,7 @@ infix fun KProperty.ne(value: T): Criteria =
* @since 2.2
* @see Criteria.lt
*/
-infix fun KProperty.lt(value: Any): Criteria =
+infix fun <@OnlyInputTypes T> KProperty.lt(value: Any): Criteria =
Criteria(this.toDotPath()).lt(value)
/**
@@ -64,7 +66,7 @@ infix fun KProperty.lt(value: Any): Criteria =
* @since 2.2
* @see Criteria.lte
*/
-infix fun KProperty.lte(value: Any): Criteria =
+infix fun <@OnlyInputTypes T> KProperty.lte(value: Any): Criteria =
Criteria(this.toDotPath()).lte(value)
/**
@@ -75,7 +77,7 @@ infix fun KProperty.lte(value: Any): Criteria =
* @since 2.2
* @see Criteria.gt
*/
-infix fun KProperty.gt(value: Any): Criteria =
+infix fun <@OnlyInputTypes T> KProperty.gt(value: Any): Criteria =
Criteria(this.toDotPath()).gt(value)
/**
@@ -86,7 +88,7 @@ infix fun KProperty.gt(value: Any): Criteria =
* @since 2.2
* @see Criteria.gte
*/
-infix fun KProperty.gte(value: Any): Criteria =
+infix fun <@OnlyInputTypes T> KProperty.gte(value: Any): Criteria =
Criteria(this.toDotPath()).gte(value)
/**
@@ -97,7 +99,7 @@ infix fun KProperty.gte(value: Any): Criteria =
* @since 2.2
* @see Criteria.inValues
*/
-fun KProperty.inValues(vararg o: Any): Criteria =
+fun <@OnlyInputTypes T> KProperty.inValues(vararg o: Any): Criteria =
Criteria(this.toDotPath()).`in`(*o)
/**
@@ -108,7 +110,7 @@ fun KProperty.inValues(vararg o: Any): Criteria =
* @since 2.2
* @see Criteria.inValues
*/
-infix fun KProperty.inValues(value: Collection): Criteria =
+infix fun <@OnlyInputTypes T> KProperty.inValues(value: Collection): Criteria =
Criteria(this.toDotPath()).`in`(value)
/**
@@ -119,7 +121,7 @@ infix fun KProperty.inValues(value: Collection): Criteria =
* @since 2.2
* @see Criteria.nin
*/
-fun KProperty.nin(vararg o: Any): Criteria =
+fun <@OnlyInputTypes T> KProperty.nin(vararg o: Any): Criteria =
Criteria(this.toDotPath()).nin(*o)
/**
@@ -130,7 +132,7 @@ fun KProperty.nin(vararg o: Any): Criteria =
* @since 2.2
* @see Criteria.nin
*/
-infix fun KProperty.nin(value: Collection): Criteria =
+infix fun <@OnlyInputTypes T> KProperty.nin(value: Collection): Criteria =
Criteria(this.toDotPath()).nin(value)
/**
diff --git a/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedUpdateExtensions.kt b/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedUpdateExtensions.kt
index e6d06386a1..97990859cc 100644
--- a/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedUpdateExtensions.kt
+++ b/spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedUpdateExtensions.kt
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package org.springframework.data.mongodb.core.query
import org.springframework.data.mapping.toDotPath
import org.springframework.data.mongodb.core.query.Update.Position
+import kotlin.internal.OnlyInputTypes
import kotlin.reflect.KProperty
/**
@@ -26,7 +28,7 @@ import kotlin.reflect.KProperty
* @since 4.4
* @see Update.update
*/
-fun update(key: KProperty, value: T?) =
+fun <@OnlyInputTypes T> update(key: KProperty, value: T?) =
Update.update(key.toDotPath(), value)
/**
@@ -36,7 +38,7 @@ fun update(key: KProperty, value: T?) =
* @since 4.4
* @see Update.set
*/
-fun Update.set(key: KProperty, value: T?) =
+fun <@OnlyInputTypes T> Update.set(key: KProperty, value: T?) =
set(key.toDotPath(), value)
/**
@@ -46,7 +48,7 @@ fun Update.set(key: KProperty, value: T?) =
* @since 4.4
* @see Update.setOnInsert
*/
-fun Update.setOnInsert(key: KProperty, value: T?) =
+fun <@OnlyInputTypes T> Update.setOnInsert(key: KProperty, value: T?) =
setOnInsert(key.toDotPath(), value)
/**
@@ -56,7 +58,7 @@ fun Update.setOnInsert(key: KProperty, value: T?) =
* @since 4.4
* @see Update.unset
*/
-fun Update.unset(key: KProperty) =
+fun <@OnlyInputTypes T> Update.unset(key: KProperty) =
unset(key.toDotPath())
/**
@@ -66,10 +68,10 @@ fun Update.unset(key: KProperty) =
* @since 4.4
* @see Update.inc
*/
-fun Update.inc(key: KProperty, inc: Number) =
+fun <@OnlyInputTypes T> Update.inc(key: KProperty, inc: Number) =
inc(key.toDotPath(), inc)
-fun Update.inc(key: KProperty) =
+fun <@OnlyInputTypes T> Update.inc(key: KProperty) =
inc(key.toDotPath())
/**
@@ -79,7 +81,7 @@ fun Update.inc(key: KProperty) =
* @since 4.4
* @see Update.push
*/
-fun Update.push(key: KProperty>, value: T?) =
+fun <@OnlyInputTypes T> Update.push(key: KProperty>, value: T?) =
push(key.toDotPath(), value)
/**
@@ -91,7 +93,7 @@ fun Update.push(key: KProperty>, value: T?) =
* @since 4.4
* @see Update.push
*/
-fun Update.push(key: KProperty) =
+fun <@OnlyInputTypes T> Update.push(key: KProperty) =
push(key.toDotPath())
/**
@@ -102,7 +104,7 @@ fun Update.push(key: KProperty) =
* @since 4.4
* @see Update.addToSet
*/
-fun Update.addToSet(key: KProperty) =
+fun <@OnlyInputTypes T> Update.addToSet(key: KProperty) =
addToSet(key.toDotPath())
/**
@@ -112,7 +114,7 @@ fun Update.addToSet(key: KProperty) =
* @since 4.4
* @see Update.addToSet
*/
-fun Update.addToSet(key: KProperty>, value: T?) =
+fun <@OnlyInputTypes T> Update.addToSet(key: KProperty>, value: T?) =
addToSet(key.toDotPath(), value)
/**
@@ -122,7 +124,7 @@ fun Update.addToSet(key: KProperty>, value: T?) =
* @since 4.4
* @see Update.pop
*/
-fun Update.pop(key: KProperty, pos: Position) =
+fun <@OnlyInputTypes T> Update.pop(key: KProperty, pos: Position) =
pop(key.toDotPath(), pos)
/**
@@ -132,7 +134,7 @@ fun Update.pop(key: KProperty, pos: Position) =
* @since 4.4
* @see Update.pull
*/
-fun Update.pull(key: KProperty, value: Any) =
+fun <@OnlyInputTypes T> Update.pull(key: KProperty, value: Any) =
pull(key.toDotPath(), value)
/**
@@ -142,7 +144,7 @@ fun Update.pull(key: KProperty, value: Any) =
* @since 4.4
* @see Update.pullAll
*/
-fun Update.pullAll(key: KProperty>, values: Array) =
+fun <@OnlyInputTypes T> Update.pullAll(key: KProperty>, values: Array) =
pullAll(key.toDotPath(), values)
/**
@@ -152,7 +154,7 @@ fun Update.pullAll(key: KProperty>, values: Array) =
* @since 4.4
* @see Update.currentDate
*/
-fun Update.currentDate(key: KProperty) =
+fun <@OnlyInputTypes T> Update.currentDate(key: KProperty) =
currentDate(key.toDotPath())
/**
@@ -162,7 +164,7 @@ fun Update.currentDate(key: KProperty) =
* @since 4.4
* @see Update.currentTimestamp
*/
-fun Update.currentTimestamp(key: KProperty) =
+fun <@OnlyInputTypes T> Update.currentTimestamp(key: KProperty) =
currentTimestamp(key.toDotPath())
/**
@@ -172,7 +174,7 @@ fun Update.currentTimestamp(key: KProperty) =
* @since 4.4
* @see Update.multiply
*/
-fun Update.multiply(key: KProperty, multiplier: Number) =
+fun <@OnlyInputTypes T> Update.multiply(key: KProperty, multiplier: Number) =
multiply(key.toDotPath(), multiplier)
/**
@@ -202,7 +204,7 @@ fun Update.min(key: KProperty, value: T) =
* @since 4.4
* @see Update.bitwise
*/
-fun Update.bitwise(key: KProperty) =
+fun <@OnlyInputTypes T> Update.bitwise(key: KProperty) =
bitwise(key.toDotPath())
/**
@@ -213,7 +215,7 @@ fun Update.bitwise(key: KProperty) =
* @since 4.4
* @see Update.filterArray
*/
-fun Update.filterArray(identifier: KProperty, expression: Any) =
+fun <@OnlyInputTypes T> Update.filterArray(identifier: KProperty, expression: Any) =
filterArray(identifier.toDotPath(), expression)
/**
@@ -223,6 +225,6 @@ fun Update.filterArray(identifier: KProperty, expression: Any) =
* @since 4.4
* @see Update.modifies
*/
-fun Update.modifies(key: KProperty) =
+fun <@OnlyInputTypes T> Update.modifies(key: KProperty) =
modifies(key.toDotPath())