Skip to content

Commit 4bd77ce

Browse files
committed
Possible fix for issue spring-projects#4798 with @OnlyInputTypes annotation
1 parent a84b3c2 commit 4bd77ce

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

Diff for: spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/CriteriaExtensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fun Criteria.isEqualTo(o: Any?): Criteria = `is`(o)
3232
* @author Sebastien Deleuze
3333
* @since 2.0
3434
*/
35-
fun <T : Any?> Criteria.inValues(c: Collection<T>): Criteria = `in`(c)
35+
fun <@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.OnlyInputTypes T : Any?> Criteria.inValues(c: Collection<T>): Criteria = `in`(c)
3636

3737
/**
3838
* Extension for [Criteria.in] providing an `inValues` alias since `in` is a reserved keyword in Kotlin.

Diff for: spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedCriteriaExtensions.kt

+11-10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
1617
package org.springframework.data.mongodb.core.query
1718

1819
import org.bson.BsonRegularExpression
@@ -31,7 +32,7 @@ import kotlin.reflect.KProperty
3132
* @since 2.2
3233
* @see Criteria.isEqualTo
3334
*/
34-
infix fun <T> KProperty<T>.isEqualTo(value: T) =
35+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.isEqualTo(value: T) =
3536
Criteria(this.toDotPath()).isEqualTo(value)
3637

3738
/**
@@ -42,7 +43,7 @@ infix fun <T> KProperty<T>.isEqualTo(value: T) =
4243
* @since 2.2
4344
* @see Criteria.ne
4445
*/
45-
infix fun <T> KProperty<T>.ne(value: T): Criteria =
46+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.ne(value: T): Criteria =
4647
Criteria(this.toDotPath()).ne(value)
4748

4849
/**
@@ -53,7 +54,7 @@ infix fun <T> KProperty<T>.ne(value: T): Criteria =
5354
* @since 2.2
5455
* @see Criteria.lt
5556
*/
56-
infix fun <T> KProperty<T>.lt(value: Any): Criteria =
57+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.lt(value: Any): Criteria =
5758
Criteria(this.toDotPath()).lt(value)
5859

5960
/**
@@ -64,7 +65,7 @@ infix fun <T> KProperty<T>.lt(value: Any): Criteria =
6465
* @since 2.2
6566
* @see Criteria.lte
6667
*/
67-
infix fun <T> KProperty<T>.lte(value: Any): Criteria =
68+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.lte(value: Any): Criteria =
6869
Criteria(this.toDotPath()).lte(value)
6970

7071
/**
@@ -75,7 +76,7 @@ infix fun <T> KProperty<T>.lte(value: Any): Criteria =
7576
* @since 2.2
7677
* @see Criteria.gt
7778
*/
78-
infix fun <T> KProperty<T>.gt(value: Any): Criteria =
79+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.gt(value: Any): Criteria =
7980
Criteria(this.toDotPath()).gt(value)
8081

8182
/**
@@ -86,7 +87,7 @@ infix fun <T> KProperty<T>.gt(value: Any): Criteria =
8687
* @since 2.2
8788
* @see Criteria.gte
8889
*/
89-
infix fun <T> KProperty<T>.gte(value: Any): Criteria =
90+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.gte(value: Any): Criteria =
9091
Criteria(this.toDotPath()).gte(value)
9192

9293
/**
@@ -97,7 +98,7 @@ infix fun <T> KProperty<T>.gte(value: Any): Criteria =
9798
* @since 2.2
9899
* @see Criteria.inValues
99100
*/
100-
fun <T> KProperty<T>.inValues(vararg o: Any): Criteria =
101+
fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.inValues(vararg o: Any): Criteria =
101102
Criteria(this.toDotPath()).`in`(*o)
102103

103104
/**
@@ -108,7 +109,7 @@ fun <T> KProperty<T>.inValues(vararg o: Any): Criteria =
108109
* @since 2.2
109110
* @see Criteria.inValues
110111
*/
111-
infix fun <T> KProperty<T>.inValues(value: Collection<T>): Criteria =
112+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.inValues(value: Collection<T>): Criteria =
112113
Criteria(this.toDotPath()).`in`(value)
113114

114115
/**
@@ -119,7 +120,7 @@ infix fun <T> KProperty<T>.inValues(value: Collection<T>): Criteria =
119120
* @since 2.2
120121
* @see Criteria.nin
121122
*/
122-
fun <T> KProperty<T>.nin(vararg o: Any): Criteria =
123+
fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.nin(vararg o: Any): Criteria =
123124
Criteria(this.toDotPath()).nin(*o)
124125

125126
/**
@@ -130,7 +131,7 @@ fun <T> KProperty<T>.nin(vararg o: Any): Criteria =
130131
* @since 2.2
131132
* @see Criteria.nin
132133
*/
133-
infix fun <T> KProperty<T>.nin(value: Collection<T>): Criteria =
134+
infix fun <@kotlin.internal.OnlyInputTypes T> KProperty<T>.nin(value: Collection<T>): Criteria =
134135
Criteria(this.toDotPath()).nin(value)
135136

136137
/**

Diff for: spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedUpdateExtensions.kt

+20-19
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
1617
package org.springframework.data.mongodb.core.query
1718

1819
import org.springframework.data.mapping.toDotPath
@@ -26,7 +27,7 @@ import kotlin.reflect.KProperty
2627
* @since 4.4
2728
* @see Update.update
2829
*/
29-
fun <T> update(key: KProperty<T>, value: T?) =
30+
fun <@kotlin.internal.OnlyInputTypes T> update(key: KProperty<T>, value: T?) =
3031
Update.update(key.toDotPath(), value)
3132

3233
/**
@@ -36,7 +37,7 @@ fun <T> update(key: KProperty<T>, value: T?) =
3637
* @since 4.4
3738
* @see Update.set
3839
*/
39-
fun <T> Update.set(key: KProperty<T>, value: T?) =
40+
fun <@kotlin.internal.OnlyInputTypes T> Update.set(key: KProperty<T>, value: T?) =
4041
set(key.toDotPath(), value)
4142

4243
/**
@@ -46,7 +47,7 @@ fun <T> Update.set(key: KProperty<T>, value: T?) =
4647
* @since 4.4
4748
* @see Update.setOnInsert
4849
*/
49-
fun <T> Update.setOnInsert(key: KProperty<T>, value: T?) =
50+
fun <@kotlin.internal.OnlyInputTypes T> Update.setOnInsert(key: KProperty<T>, value: T?) =
5051
setOnInsert(key.toDotPath(), value)
5152

5253
/**
@@ -56,7 +57,7 @@ fun <T> Update.setOnInsert(key: KProperty<T>, value: T?) =
5657
* @since 4.4
5758
* @see Update.unset
5859
*/
59-
fun <T> Update.unset(key: KProperty<T>) =
60+
fun <@kotlin.internal.OnlyInputTypes T> Update.unset(key: KProperty<T>) =
6061
unset(key.toDotPath())
6162

6263
/**
@@ -66,10 +67,10 @@ fun <T> Update.unset(key: KProperty<T>) =
6667
* @since 4.4
6768
* @see Update.inc
6869
*/
69-
fun <T> Update.inc(key: KProperty<T>, inc: Number) =
70+
fun <@kotlin.internal.OnlyInputTypes T> Update.inc(key: KProperty<T>, inc: Number) =
7071
inc(key.toDotPath(), inc)
7172

72-
fun <T> Update.inc(key: KProperty<T>) =
73+
fun <@kotlin.internal.OnlyInputTypes T> Update.inc(key: KProperty<T>) =
7374
inc(key.toDotPath())
7475

7576
/**
@@ -79,7 +80,7 @@ fun <T> Update.inc(key: KProperty<T>) =
7980
* @since 4.4
8081
* @see Update.push
8182
*/
82-
fun <T> Update.push(key: KProperty<Collection<T>>, value: T?) =
83+
fun <@kotlin.internal.OnlyInputTypes T> Update.push(key: KProperty<Collection<T>>, value: T?) =
8384
push(key.toDotPath(), value)
8485

8586
/**
@@ -91,7 +92,7 @@ fun <T> Update.push(key: KProperty<Collection<T>>, value: T?) =
9192
* @since 4.4
9293
* @see Update.push
9394
*/
94-
fun <T> Update.push(key: KProperty<T>) =
95+
fun <@kotlin.internal.OnlyInputTypes T> Update.push(key: KProperty<T>) =
9596
push(key.toDotPath())
9697

9798
/**
@@ -102,7 +103,7 @@ fun <T> Update.push(key: KProperty<T>) =
102103
* @since 4.4
103104
* @see Update.addToSet
104105
*/
105-
fun <T> Update.addToSet(key: KProperty<T>) =
106+
fun <@kotlin.internal.OnlyInputTypes T> Update.addToSet(key: KProperty<T>) =
106107
addToSet(key.toDotPath())
107108

108109
/**
@@ -112,7 +113,7 @@ fun <T> Update.addToSet(key: KProperty<T>) =
112113
* @since 4.4
113114
* @see Update.addToSet
114115
*/
115-
fun <T> Update.addToSet(key: KProperty<Collection<T>>, value: T?) =
116+
fun <@kotlin.internal.OnlyInputTypes T> Update.addToSet(key: KProperty<Collection<T>>, value: T?) =
116117
addToSet(key.toDotPath(), value)
117118

118119
/**
@@ -122,7 +123,7 @@ fun <T> Update.addToSet(key: KProperty<Collection<T>>, value: T?) =
122123
* @since 4.4
123124
* @see Update.pop
124125
*/
125-
fun <T> Update.pop(key: KProperty<T>, pos: Position) =
126+
fun <@kotlin.internal.OnlyInputTypes T> Update.pop(key: KProperty<T>, pos: Position) =
126127
pop(key.toDotPath(), pos)
127128

128129
/**
@@ -132,7 +133,7 @@ fun <T> Update.pop(key: KProperty<T>, pos: Position) =
132133
* @since 4.4
133134
* @see Update.pull
134135
*/
135-
fun <T> Update.pull(key: KProperty<T>, value: Any) =
136+
fun <@kotlin.internal.OnlyInputTypes T> Update.pull(key: KProperty<T>, value: Any) =
136137
pull(key.toDotPath(), value)
137138

138139
/**
@@ -142,7 +143,7 @@ fun <T> Update.pull(key: KProperty<T>, value: Any) =
142143
* @since 4.4
143144
* @see Update.pullAll
144145
*/
145-
fun <T> Update.pullAll(key: KProperty<Collection<T>>, values: Array<T>) =
146+
fun <@kotlin.internal.OnlyInputTypes T> Update.pullAll(key: KProperty<Collection<T>>, values: Array<T>) =
146147
pullAll(key.toDotPath(), values)
147148

148149
/**
@@ -152,7 +153,7 @@ fun <T> Update.pullAll(key: KProperty<Collection<T>>, values: Array<T>) =
152153
* @since 4.4
153154
* @see Update.currentDate
154155
*/
155-
fun <T> Update.currentDate(key: KProperty<T>) =
156+
fun <@kotlin.internal.OnlyInputTypes T> Update.currentDate(key: KProperty<T>) =
156157
currentDate(key.toDotPath())
157158

158159
/**
@@ -162,7 +163,7 @@ fun <T> Update.currentDate(key: KProperty<T>) =
162163
* @since 4.4
163164
* @see Update.currentTimestamp
164165
*/
165-
fun <T> Update.currentTimestamp(key: KProperty<T>) =
166+
fun <@kotlin.internal.OnlyInputTypes T> Update.currentTimestamp(key: KProperty<T>) =
166167
currentTimestamp(key.toDotPath())
167168

168169
/**
@@ -172,7 +173,7 @@ fun <T> Update.currentTimestamp(key: KProperty<T>) =
172173
* @since 4.4
173174
* @see Update.multiply
174175
*/
175-
fun <T> Update.multiply(key: KProperty<T>, multiplier: Number) =
176+
fun <@kotlin.internal.OnlyInputTypes T> Update.multiply(key: KProperty<T>, multiplier: Number) =
176177
multiply(key.toDotPath(), multiplier)
177178

178179
/**
@@ -202,7 +203,7 @@ fun <T : Any> Update.min(key: KProperty<T>, value: T) =
202203
* @since 4.4
203204
* @see Update.bitwise
204205
*/
205-
fun <T> Update.bitwise(key: KProperty<T>) =
206+
fun <@kotlin.internal.OnlyInputTypes T> Update.bitwise(key: KProperty<T>) =
206207
bitwise(key.toDotPath())
207208

208209
/**
@@ -213,7 +214,7 @@ fun <T> Update.bitwise(key: KProperty<T>) =
213214
* @since 4.4
214215
* @see Update.filterArray
215216
*/
216-
fun <T> Update.filterArray(identifier: KProperty<T>, expression: Any) =
217+
fun <@kotlin.internal.OnlyInputTypes T> Update.filterArray(identifier: KProperty<T>, expression: Any) =
217218
filterArray(identifier.toDotPath(), expression)
218219

219220
/**
@@ -223,6 +224,6 @@ fun <T> Update.filterArray(identifier: KProperty<T>, expression: Any) =
223224
* @since 4.4
224225
* @see Update.modifies
225226
*/
226-
fun <T> Update.modifies(key: KProperty<T>) =
227+
fun <@kotlin.internal.OnlyInputTypes T> Update.modifies(key: KProperty<T>) =
227228
modifies(key.toDotPath())
228229

0 commit comments

Comments
 (0)