Files
kotlin-fork/compiler/testData/codegen/box/builderInference/issues/kt61310.kt
T
2024-01-10 14:56:30 +00:00

31 lines
601 B
Kotlin
Vendored

// ISSUE: KT-61310
// IGNORE_LIGHT_ANALYSIS
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
build {
if (true) {
setTypeVariable(GenericBox())
} else {
setTypeVariable(GenericBox<TargetType>())
}
}
return "OK"
}
class TargetType
class GenericBox<T>
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
private var storage: TV = GenericBox<TargetType>() as TV
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}