diff --git a/compiler/testData/codegen/box/builderInference/issues/kt63733.kt b/compiler/testData/codegen/box/builderInference/issues/kt63733.kt new file mode 100644 index 00000000000..b917c1744fc --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt63733.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-63733 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun BoundedBuildee.setBoundedTypeVariable(arg: DifferentType) {} + +fun box(): String { + boundedBuild { + setBoundedTypeVariable(TargetType()) + setBoundedTypeVariable(DifferentType()) + } + boundedBuild { + setBoundedTypeVariable(TargetType()) + setBoundedTypeVariable(DifferentType()) + } + return "OK" +} + + + + +open class TargetTypeBase +class TargetType: TargetTypeBase() +class DifferentType + +class BoundedBuildee { + fun setBoundedTypeVariable(value: BTV) { storage = value } + private var storage: BTV = TargetType() as BTV +} + +fun boundedBuild(instructions: BoundedBuildee.() -> Unit): BoundedBuildee { + return BoundedBuildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt63733.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt63733.fir.kt new file mode 100644 index 00000000000..7617d95762c --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt63733.fir.kt @@ -0,0 +1,34 @@ +// ISSUE: KT-63733 +// CHECK_TYPE_WITH_EXACT + +fun BoundedBuildee.setBoundedTypeVariable(arg: DifferentType) {} + +fun test() { + boundedBuild { + setBoundedTypeVariable(TargetType()) + setBoundedTypeVariable(DifferentType()) + } + val buildee = boundedBuild { + setBoundedTypeVariable(TargetType()) + setBoundedTypeVariable(DifferentType()) + } + // 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>(; BoundedBuildee")!>buildee) +} + + + + +open class TargetTypeBase +class TargetType: TargetTypeBase() +class DifferentType + +class BoundedBuildee { + fun setBoundedTypeVariable(value: BTV) { storage = value } + private var storage: BTV = null!! +} + +fun boundedBuild(instructions: BoundedBuildee.() -> Unit): BoundedBuildee { + return BoundedBuildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt63733.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt63733.kt new file mode 100644 index 00000000000..e490c2b2dfe --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt63733.kt @@ -0,0 +1,34 @@ +// ISSUE: KT-63733 +// CHECK_TYPE_WITH_EXACT + +fun BoundedBuildee.setBoundedTypeVariable(arg: DifferentType) {} + +fun test() { + boundedBuild { + setBoundedTypeVariable(TargetType()) + setBoundedTypeVariable(DifferentType()) + } + val buildee = boundedBuild { + setBoundedTypeVariable(TargetType()) + setBoundedTypeVariable(DifferentType()) + } + // 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>(; BoundedBuildee"), TYPE_MISMATCH("BoundedBuildee; BoundedBuildee")!>buildee) +} + + + + +open class TargetTypeBase +class TargetType: TargetTypeBase() +class DifferentType + +class BoundedBuildee { + fun setBoundedTypeVariable(value: BTV) { storage = value } + private var storage: BTV = null!! +} + +fun boundedBuild(instructions: BoundedBuildee.() -> Unit): BoundedBuildee { + return BoundedBuildee().apply(instructions) +}