[tests] Add test data for KT-63841

This commit is contained in:
Stanislav Ruban
2023-12-02 15:29:40 +01:00
committed by Space Team
parent 4f38d77fae
commit c0bf67af22
2 changed files with 100 additions and 0 deletions
@@ -0,0 +1,50 @@
// ISSUE: KT-63841
// CHECK_TYPE_WITH_EXACT
class TargetType { fun targetTypeMemberFunction() {} }
class DifferentType
fun test() {
val targetTypeBuildee = build {
var variable = getTypeVariable()
variable = TargetType()
variable.targetTypeMemberFunction()
}
// 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>>(targetTypeBuildee)
val differentTypeBuildee = build {
var variable = getTypeVariable()
variable = DifferentType()
variable.<!UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
}
// 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<DifferentType>>(differentTypeBuildee)
val anyBuildee = build {
var variable = getTypeVariable()
variable = TargetType()
variable.targetTypeMemberFunction()
variable = DifferentType()
variable.<!UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
variable = TargetType()
variable.targetTypeMemberFunction()
}
// 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<Any>>(anyBuildee)
}
class Buildee<TV> {
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,50 @@
// ISSUE: KT-63841
// CHECK_TYPE_WITH_EXACT
class TargetType { fun targetTypeMemberFunction() {} }
class DifferentType
fun test() {
val targetTypeBuildee = build {
var variable = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>getTypeVariable()<!>
variable = TargetType()
variable.targetTypeMemberFunction()
}
// 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>>(<!TYPE_MISMATCH("Buildee<TargetType>; Buildee<TargetType?>"), TYPE_MISMATCH("Buildee<TargetType?>; Buildee<TargetType>")!>targetTypeBuildee<!>)
val differentTypeBuildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
var variable = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>getTypeVariable()<!>
variable = DifferentType()
variable.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
}
// 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<DifferentType>>(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>differentTypeBuildee<!>)
val anyBuildee = build {
var variable = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>getTypeVariable()<!>
variable = TargetType()
variable.targetTypeMemberFunction()
variable = DifferentType()
variable.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
variable = TargetType()
variable.targetTypeMemberFunction()
}
// 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<Any>>(<!TYPE_MISMATCH("Buildee<Any>; Buildee<TargetType>"), TYPE_MISMATCH("Buildee<TargetType>; Buildee<Any>")!>anyBuildee<!>)
}
class Buildee<TV> {
fun getTypeVariable(): TV = storage
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}