diff --git a/compiler/testData/codegen/box/builderInference/issues/kt53553.kt b/compiler/testData/codegen/box/builderInference/issues/kt53553.kt new file mode 100644 index 00000000000..fe249a09090 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt53553.kt @@ -0,0 +1,42 @@ +// ISSUE: KT-53553 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + val buildee = parallelBuild( + { + consumeTargetTypeBase(it) + }, + { + consumeTargetType(it) + } + ) + consumeTargetTypeBuildee(buildee) + return "OK" +} + + + + +open class TargetTypeBase +class TargetType: TargetTypeBase() + +fun consumeTargetTypeBase(value: TargetTypeBase) {} + +fun consumeTargetType(value: TargetType) {} +fun consumeTargetTypeBuildee(value: Buildee) {} + +class Buildee + +fun parallelBuild( + instructionsA: Buildee.(PTV) -> Unit, + instructionsB: Buildee.(PTV) -> Unit +): Buildee { + val value = TargetType() as PTV + return Buildee().apply { + instructionsA(value) + instructionsB(value) + } +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.fir.kt new file mode 100644 index 00000000000..e3039f549d3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.fir.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-53553 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = parallelBuild( + { + consumeTargetTypeBase(it) + }, + { + consumeTargetType(it) + } + ) + // 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")!>buildee) +} + + + + +open class TargetTypeBase +class TargetType: TargetTypeBase() + +fun consumeTargetTypeBase(value: TargetTypeBase) {} + +fun consumeTargetType(value: TargetType) {} + +class Buildee + +fun parallelBuild( + instructionsA: Buildee.(PTV) -> Unit, + instructionsB: Buildee.(PTV) -> Unit +): Buildee { + return null!! +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.kt new file mode 100644 index 00000000000..fa461230a7b --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-53553 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = parallelBuild( + { + consumeTargetTypeBase(it) + }, + { + consumeTargetType(it) + } + ) + // 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")!>buildee) +} + + + + +open class TargetTypeBase +class TargetType: TargetTypeBase() + +fun consumeTargetTypeBase(value: TargetTypeBase) {} + +fun consumeTargetType(value: TargetType) {} + +class Buildee + +fun parallelBuild( + instructionsA: Buildee.(PTV) -> Unit, + instructionsB: Buildee.(PTV) -> Unit +): Buildee { + return null!! +}