[FIR] Reproduce KT-65584

The diagnostic target source element
type was changed to prevent crash due
to `checkPsiTypeConsistency()` in
`duplicateParameterNameSimplified.fir.kt`

^KT-65584
This commit is contained in:
Nikolay Lunyak
2024-02-07 15:55:59 +02:00
committed by Space Team
parent ef29879740
commit 8ec248131d
13 changed files with 174 additions and 4 deletions
@@ -0,0 +1,41 @@
// ISSUE: KT-65584
// WITH_STDLIB
fun interface Flow<out T> {
suspend fun collect(collector: FlowCollector<T>)
}
fun interface FlowCollector<in T> {
suspend fun emit(value: T)
}
inline fun <T, R> Flow<T>.flatMapLatest(crossinline transform: suspend (value: T) -> Flow<R>) = Flow { collector ->
collect { it1 -> transform(it1).collect { it2 -> collector.emit(it2) } }
}
fun <T> flowOf(value: T): Flow<T> = Flow { collector -> collector.emit(value) }
inline fun <T, R> Flow<T>.map(crossinline transform: suspend (value: T) -> R): Flow<R> = Flow { collector ->
collect { collector.emit(transform(it)) }
}
// ------
class StationId
class Playable
class Entity(val stationId: StationId)
class State(val playbackEntity: Entity)
internal suspend fun init(
queueState: State,
state: Flow<Playable>
) {
state
.flatMapLatest { playable ->
flowOf(playable).map { Triple(it, playable, queueState.playbackEntity.stationId) }
}
.collect { <!DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE!>(likeState, playable, stationId)<!> ->
}
}
@@ -0,0 +1,41 @@
// ISSUE: KT-65584
// WITH_STDLIB
fun interface Flow<out T> {
suspend fun collect(collector: FlowCollector<T>)
}
fun interface FlowCollector<in T> {
suspend fun emit(value: T)
}
inline fun <T, R> Flow<T>.flatMapLatest(crossinline transform: suspend (value: T) -> Flow<R>) = Flow { collector ->
collect { it1 -> transform(it1).collect { it2 -> collector.emit(it2) } }
}
fun <T> flowOf(value: T): Flow<T> = Flow { collector -> collector.emit(value) }
inline fun <T, R> Flow<T>.map(crossinline transform: suspend (value: T) -> R): Flow<R> = Flow { collector ->
collect { collector.emit(transform(it)) }
}
// ------
class StationId
class Playable
class Entity(val stationId: StationId)
class State(val playbackEntity: Entity)
internal suspend fun init(
queueState: State,
state: Flow<Playable>
) {
state
.flatMapLatest { playable ->
flowOf(playable).map { Triple(it, playable, queueState.playbackEntity.stationId) }
}
.collect { (likeState, playable, stationId) ->
}
}
@@ -0,0 +1,14 @@
// ISSUE: KT-65584
fun <T> giveItName(it: T, block: (myName: T) -> Unit) = block(it)
fun <T> duplicateIt(it: T, block: (T, T) -> Unit) = block
class MyTriple<T, K, M>(val a: T, val b: K, val c: M)
fun test() {
giveItName(10) {
MyTriple(it, it, it).also { <!DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE!>self<!> -> }
(duplicateIt(it) { a, b -> }).also { <!DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE!>function<!> -> }
}
}
@@ -0,0 +1,14 @@
// ISSUE: KT-65584
fun <T> giveItName(it: T, block: (myName: T) -> Unit) = block(it)
fun <T> duplicateIt(it: T, block: (T, T) -> Unit) = block
class MyTriple<T, K, M>(val a: T, val b: K, val c: M)
fun test() {
giveItName(10) {
MyTriple(it, it, it).also { self -> }
(duplicateIt(it) { a, b -> }).also { function -> }
}
}