diff --git a/compiler/testData/codegen/box/builderInference/issues/kt49263.kt b/compiler/testData/codegen/box/builderInference/issues/kt49263.kt new file mode 100644 index 00000000000..6fe55aaa79f --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt49263.kt @@ -0,0 +1,23 @@ +// ISSUE: KT-49263 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + buildPostponedTypeVariable { + consumeTargetType(this) + } + return "OK" +} + + + + +class TargetType + +fun consumeTargetType(value: TargetType) {} + +fun buildPostponedTypeVariable(block: PTV.() -> Unit): PTV { + return (TargetType() as PTV).apply(block) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49263.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49263.fir.kt new file mode 100644 index 00000000000..db8006a6d86 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49263.fir.kt @@ -0,0 +1,22 @@ +// ISSUE: KT-49263 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val targetType = buildPostponedTypeVariable { + consumeTargetType(this) + } + // 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(targetType) +} + + + + +class TargetType + +fun consumeTargetType(value: TargetType) {} + +fun buildPostponedTypeVariable(block: PTV.() -> Unit): PTV { + return null!! +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49263.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49263.kt new file mode 100644 index 00000000000..471bd03bb2c --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49263.kt @@ -0,0 +1,22 @@ +// ISSUE: KT-49263 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val targetType = buildPostponedTypeVariable { + consumeTargetType(this) + } + // 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(targetType) +} + + + + +class TargetType + +fun consumeTargetType(value: TargetType) {} + +fun buildPostponedTypeVariable(block: PTV.() -> Unit): PTV { + return null!! +}