diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt63841.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt63841.fir.kt new file mode 100644 index 00000000000..961c038a65a --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt63841.fir.kt @@ -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>(targetTypeBuildee) + + val differentTypeBuildee = build { + var variable = getTypeVariable() + variable = DifferentType() + 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>(differentTypeBuildee) + + val anyBuildee = build { + var variable = getTypeVariable() + variable = TargetType() + variable.targetTypeMemberFunction() + variable = DifferentType() + variable.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>(anyBuildee) +} + + + + +class Buildee { + fun getTypeVariable(): TV = storage + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt63841.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt63841.kt new file mode 100644 index 00000000000..824af0d60d5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt63841.kt @@ -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"), TYPE_MISMATCH("Buildee; Buildee")!>targetTypeBuildee) + + val differentTypeBuildee = build { + var variable = getTypeVariable() + variable = DifferentType() + 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>(differentTypeBuildee) + + val anyBuildee = build { + var variable = getTypeVariable() + variable = TargetType() + variable.targetTypeMemberFunction() + variable = DifferentType() + variable.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"), TYPE_MISMATCH("Buildee; Buildee")!>anyBuildee) +} + + + + +class Buildee { + fun getTypeVariable(): TV = storage + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +}