Files
kotlin-fork/compiler/testData/codegen/box/builderInference/issues/kt53740a.kt
T
2023-12-05 18:15:53 +00:00

43 lines
855 B
Kotlin
Vendored

// ISSUE: KT-53740
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
parallelBuild(
{
setTypeVariable(TargetType())
},
{
consumeDifferentType(getTypeVariable())
}
)
return "OK"
}
class TargetType
class DifferentType
fun consumeDifferentType(value: DifferentType) {}
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
fun getTypeVariable(): TV = storage
private var storage: TV = TargetType() as TV
}
fun <PTV> parallelBuild(
instructionsA: Buildee<PTV>.(PTV) -> Unit,
instructionsB: Buildee<PTV>.(PTV) -> Unit
): Buildee<PTV> {
val value = TargetType() as PTV
return Buildee<PTV>().apply {
instructionsA(value)
instructionsB(value)
}
}