Skip to content

Commit 6a6e336

Browse files
authored
Cleanup: remove the BuilderInference annotation (#4543)
The `BuilderInference` annotation has no effect since Kotlin 2.0 and can be safely removed.
1 parent 5c4a37b commit 6a6e336

File tree

19 files changed

+41
-41
lines changed

19 files changed

+41
-41
lines changed

benchmarks/src/jmh/kotlin/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public fun <T, R> Flow<T>.flatMapConcatIterable(transformer: (T) -> Iterable<R>)
181181
}
182182
}
183183

184-
public inline fun <T> flow(@BuilderInference crossinline block: suspend FlowCollector<T>.() -> Unit): Flow<T> {
184+
public inline fun <T> flow(crossinline block: suspend FlowCollector<T>.() -> Unit): Flow<T> {
185185
return object : Flow<T> {
186186
override suspend fun collect(collector: FlowCollector<T>) {
187187
collector.block()

kotlinx-coroutines-core/common/src/channels/Broadcast.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public fun <E> CoroutineScope.broadcast(
3939
capacity: Int = 1,
4040
start: CoroutineStart = CoroutineStart.LAZY,
4141
onCompletion: CompletionHandler? = null,
42-
@BuilderInference block: suspend ProducerScope<E>.() -> Unit
42+
block: suspend ProducerScope<E>.() -> Unit
4343
): BroadcastChannel<E> {
4444
val newContext = newCoroutineContext(context)
4545
val channel = BroadcastChannel<E>(capacity)

kotlinx-coroutines-core/common/src/channels/Produce.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public suspend fun ProducerScope<*>.awaitClose(block: () -> Unit = {}) {
239239
public fun <E> CoroutineScope.produce(
240240
context: CoroutineContext = EmptyCoroutineContext,
241241
capacity: Int = Channel.RENDEZVOUS,
242-
@BuilderInference block: suspend ProducerScope<E>.() -> Unit
242+
block: suspend ProducerScope<E>.() -> Unit
243243
): ReceiveChannel<E> =
244244
produce(context, capacity, BufferOverflow.SUSPEND, CoroutineStart.DEFAULT, onCompletion = null, block = block)
245245

@@ -261,7 +261,7 @@ public fun <E> CoroutineScope.produce(
261261
capacity: Int = 0,
262262
start: CoroutineStart = CoroutineStart.DEFAULT,
263263
onCompletion: CompletionHandler? = null,
264-
@BuilderInference block: suspend ProducerScope<E>.() -> Unit
264+
block: suspend ProducerScope<E>.() -> Unit
265265
): ReceiveChannel<E> =
266266
produce(context, capacity, BufferOverflow.SUSPEND, start, onCompletion, block)
267267

@@ -273,7 +273,7 @@ internal fun <E> CoroutineScope.produce(
273273
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
274274
start: CoroutineStart = CoroutineStart.DEFAULT,
275275
onCompletion: CompletionHandler? = null,
276-
@BuilderInference block: suspend ProducerScope<E>.() -> Unit
276+
block: suspend ProducerScope<E>.() -> Unit
277277
): ReceiveChannel<E> {
278278
val channel = Channel<E>(capacity, onBufferOverflow)
279279
val newContext = newCoroutineContext(context)

kotlinx-coroutines-core/common/src/flow/Builders.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import kotlinx.coroutines.flow.internal.unsafeFlow as flow
4949
*
5050
* If you want to switch the context of execution of a flow, use the [flowOn] operator.
5151
*/
52-
public fun <T> flow(@BuilderInference block: suspend FlowCollector<T>.() -> Unit): Flow<T> = SafeFlow(block)
52+
public fun <T> flow(block: suspend FlowCollector<T>.() -> Unit): Flow<T> = SafeFlow(block)
5353

5454
// Named anonymous object
5555
private class SafeFlow<T>(private val block: suspend FlowCollector<T>.() -> Unit) : AbstractFlow<T>() {
@@ -236,7 +236,7 @@ public fun LongRange.asFlow(): Flow<Long> = flow {
236236
* }
237237
* ```
238238
*/
239-
public fun <T> channelFlow(@BuilderInference block: suspend ProducerScope<T>.() -> Unit): Flow<T> =
239+
public fun <T> channelFlow(block: suspend ProducerScope<T>.() -> Unit): Flow<T> =
240240
ChannelFlowBuilder(block)
241241

242242
/**
@@ -300,7 +300,7 @@ public fun <T> channelFlow(@BuilderInference block: suspend ProducerScope<T>.()
300300
* > `awaitClose` block can be called at any time due to asynchronous nature of cancellation, even
301301
* > concurrently with the call of the callback.
302302
*/
303-
public fun <T> callbackFlow(@BuilderInference block: suspend ProducerScope<T>.() -> Unit): Flow<T> = CallbackFlowBuilder(block)
303+
public fun <T> callbackFlow(block: suspend ProducerScope<T>.() -> Unit): Flow<T> = CallbackFlowBuilder(block)
304304

305305
// ChannelFlow implementation that is the first in the chain of flow operations and introduces (builds) a flow
306306
private open class ChannelFlowBuilder<T>(

kotlinx-coroutines-core/common/src/flow/Migration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public fun <T> Flow<T>.forEach(action: suspend (value: T) -> Unit): Unit = noImp
269269
message = "Flow has less verbose 'scan' shortcut",
270270
replaceWith = ReplaceWith("scan(initial, operation)")
271271
)
272-
public fun <T, R> Flow<T>.scanFold(initial: R, @BuilderInference operation: suspend (accumulator: R, value: T) -> R): Flow<R> =
272+
public fun <T, R> Flow<T>.scanFold(initial: R, operation: suspend (accumulator: R, value: T) -> R): Flow<R> =
273273
noImpl()
274274

275275
/**

kotlinx-coroutines-core/common/src/flow/internal/FlowCoroutine.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import kotlinx.coroutines.flow.internal.unsafeFlow as flow
2323
* } // <- CE will be rethrown here
2424
* ```
2525
*/
26-
internal suspend fun <R> flowScope(@BuilderInference block: suspend CoroutineScope.() -> R): R =
26+
internal suspend fun <R> flowScope(block: suspend CoroutineScope.() -> R): R =
2727
suspendCoroutineUninterceptedOrReturn { uCont ->
2828
val coroutine = FlowCoroutine(uCont.context, uCont)
2929
coroutine.startUndispatchedOrReturn(coroutine, block)
@@ -42,7 +42,7 @@ internal suspend fun <R> flowScope(@BuilderInference block: suspend CoroutineSco
4242
* with additional constraint on cancellation.
4343
* To cancel child without cancelling itself, `cancel(ChildCancelledException())` should be used.
4444
*/
45-
internal fun <R> scopedFlow(@BuilderInference block: suspend CoroutineScope.(FlowCollector<R>) -> Unit): Flow<R> =
45+
internal fun <R> scopedFlow(block: suspend CoroutineScope.(FlowCollector<R>) -> Unit): Flow<R> =
4646
flow {
4747
flowScope { block(this@flow) }
4848
}

kotlinx-coroutines-core/common/src/flow/internal/SafeCollector.common.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ internal tailrec fun Job?.transitiveCoroutineParent(collectJob: Job?): Job? {
101101
* Used in our own operators where we trust the context of invocations.
102102
*/
103103
@PublishedApi
104-
internal inline fun <T> unsafeFlow(@BuilderInference crossinline block: suspend FlowCollector<T>.() -> Unit): Flow<T> {
104+
internal inline fun <T> unsafeFlow(crossinline block: suspend FlowCollector<T>.() -> Unit): Flow<T> {
105105
return object : Flow<T> {
106106
override suspend fun collect(collector: FlowCollector<T>) {
107107
collector.block()

kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import kotlin.jvm.*
3131
* ```
3232
*/
3333
public inline fun <T, R> Flow<T>.transform(
34-
@BuilderInference crossinline transform: suspend FlowCollector<R>.(value: T) -> Unit
34+
crossinline transform: suspend FlowCollector<R>.(value: T) -> Unit
3535
): Flow<R> = flow { // Note: safe flow is used here, because collector is exposed to transform on each operation
3636
collect { value ->
3737
transform(value)
@@ -41,7 +41,7 @@ public inline fun <T, R> Flow<T>.transform(
4141
// For internal operator implementation
4242
@PublishedApi
4343
internal inline fun <T, R> Flow<T>.unsafeTransform(
44-
@BuilderInference crossinline transform: suspend FlowCollector<R>.(value: T) -> Unit
44+
crossinline transform: suspend FlowCollector<R>.(value: T) -> Unit
4545
): Flow<R> = unsafeFlow { // Note: unsafe flow is used here, because unsafeTransform is only for internal use
4646
collect { value ->
4747
transform(value)

kotlinx-coroutines-core/common/src/flow/operators/Limit.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public fun <T> Flow<T>.takeWhile(predicate: suspend (T) -> Boolean): Flow<T> = f
110110
* ```
111111
*/
112112
public fun <T, R> Flow<T>.transformWhile(
113-
@BuilderInference transform: suspend FlowCollector<R>.(value: T) -> Boolean
113+
transform: suspend FlowCollector<R>.(value: T) -> Boolean
114114
): Flow<R> =
115115
safeFlow { // Note: safe flow is used here, because collector is exposed to transform on each operation
116116
// This return is needed to work around a bug in JS BE: KT-39227

kotlinx-coroutines-core/common/src/flow/operators/Merge.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public fun <T> Flow<Flow<T>>.flattenMerge(concurrency: Int = DEFAULT_CONCURRENCY
159159
* and size of its output buffer can be changed by applying subsequent [buffer] operator.
160160
*/
161161
@ExperimentalCoroutinesApi
162-
public fun <T, R> Flow<T>.transformLatest(@BuilderInference transform: suspend FlowCollector<R>.(value: T) -> Unit): Flow<R> =
162+
public fun <T, R> Flow<T>.transformLatest(transform: suspend FlowCollector<R>.(value: T) -> Unit): Flow<R> =
163163
ChannelFlowTransformLatest(transform, this)
164164

165165
/**
@@ -185,7 +185,7 @@ public fun <T, R> Flow<T>.transformLatest(@BuilderInference transform: suspend F
185185
* This operator is [buffered][buffer] by default and size of its output buffer can be changed by applying subsequent [buffer] operator.
186186
*/
187187
@ExperimentalCoroutinesApi
188-
public inline fun <T, R> Flow<T>.flatMapLatest(@BuilderInference crossinline transform: suspend (value: T) -> Flow<R>): Flow<R> =
188+
public inline fun <T, R> Flow<T>.flatMapLatest(crossinline transform: suspend (value: T) -> Flow<R>): Flow<R> =
189189
transformLatest { emitAll(transform(it)) }
190190

191191
/**
@@ -209,5 +209,5 @@ public inline fun <T, R> Flow<T>.flatMapLatest(@BuilderInference crossinline tra
209209
* This operator is [buffered][buffer] by default and size of its output buffer can be changed by applying subsequent [buffer] operator.
210210
*/
211211
@ExperimentalCoroutinesApi
212-
public fun <T, R> Flow<T>.mapLatest(@BuilderInference transform: suspend (value: T) -> R): Flow<R> =
212+
public fun <T, R> Flow<T>.mapLatest(transform: suspend (value: T) -> R): Flow<R> =
213213
transformLatest { emit(transform(it)) }

0 commit comments

Comments
 (0)