Files
kotlin-fork/compiler/testData/diagnostics/tests/builderInference/issues/kt63733.fir.kt
T
2024-01-10 14:56:30 +00:00

35 lines
1.0 KiB
Kotlin
Vendored

// ISSUE: KT-63733
// CHECK_TYPE_WITH_EXACT
fun BoundedBuildee<TargetType>.setBoundedTypeVariable(arg: DifferentType) {}
fun test() {
boundedBuild<TargetType> {
setBoundedTypeVariable(TargetType())
setBoundedTypeVariable(DifferentType())
}
val buildee = boundedBuild {
setBoundedTypeVariable(TargetType())
setBoundedTypeVariable(DifferentType())
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<BoundedBuildee<TargetType>>(buildee)
}
open class TargetTypeBase
class TargetType: TargetTypeBase()
class DifferentType
class BoundedBuildee<BTV: TargetTypeBase> {
fun setBoundedTypeVariable(value: BTV) { storage = value }
private var storage: BTV = null!!
}
fun <PBTV: TargetTypeBase> boundedBuild(instructions: BoundedBuildee<PBTV>.() -> Unit): BoundedBuildee<PBTV> {
return BoundedBuildee<PBTV>().apply(instructions)
}