[tests] Add test data for KT-50453

This commit is contained in:
Stanislav Ruban
2023-11-30 22:03:32 +01:00
committed by Space Team
parent 9de8d020f1
commit de8f0c157e
3 changed files with 97 additions and 0 deletions
@@ -0,0 +1,31 @@
// ISSUE: KT-50453
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = build {
setTypeVariable(TargetType())
consume(getTypeVariable())
}
// 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<Buildee<TargetType>>(buildee)
}
class TargetType
class DifferentType
fun consume(value: Any) {}
fun consume(value: DifferentType) {}
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
fun getTypeVariable(): TV = storage
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}
@@ -0,0 +1,31 @@
// ISSUE: KT-50453
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = build {
setTypeVariable(TargetType())
consume(<!TYPE_MISMATCH("DifferentType; TargetType"), TYPE_MISMATCH("DifferentType; TargetType")!>getTypeVariable()<!>)
}
// 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<Buildee<TargetType>>(buildee)
}
class TargetType
class DifferentType
fun consume(value: Any) {}
fun consume(value: DifferentType) {}
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
fun getTypeVariable(): TV = storage
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}