diff --git a/compiler/testData/codegen/box/builderInference/issues/kt47989a.kt b/compiler/testData/codegen/box/builderInference/issues/kt47989a.kt new file mode 100644 index 00000000000..c4650b3fb71 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt47989a.kt @@ -0,0 +1,32 @@ +// ISSUE: KT-47989 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build { + object: TypeSourceInterface { + override fun produceTargetType() = getTypeVariable() + } + } + return "OK" +} + + + + +class TargetType + +interface TypeSourceInterface { + fun produceTargetType(): TargetType +} + +class Buildee { + fun getTypeVariable(): TV = storage + private var storage: TV = TargetType() as TV +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/codegen/box/builderInference/issues/kt47989b.kt b/compiler/testData/codegen/box/builderInference/issues/kt47989b.kt new file mode 100644 index 00000000000..1378ff24463 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt47989b.kt @@ -0,0 +1,29 @@ +// ISSUE: KT-47989 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build { + object: TypeSourceInterface { + override fun produceTargetTypeBuildee() = this@build + } + } + return "OK" +} + + + + +class TargetType + +interface TypeSourceInterface { + fun produceTargetTypeBuildee(): Buildee +} + +class Buildee + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt47989a.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989a.fir.kt new file mode 100644 index 00000000000..1a8490741a7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989a.fir.kt @@ -0,0 +1,31 @@ +// ISSUE: KT-47989 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + object: TypeSourceInterface { + override fun produceTargetType() = getTypeVariable() + } + } + // 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) +} + + + + +class TargetType + +interface TypeSourceInterface { + fun produceTargetType(): TargetType +} + +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/kt47989a.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989a.kt new file mode 100644 index 00000000000..b143b6f562c --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989a.kt @@ -0,0 +1,31 @@ +// ISSUE: KT-47989 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + object: TypeSourceInterface { + override fun produceTargetType() = getTypeVariable() + } + } + // 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) +} + + + + +class TargetType + +interface TypeSourceInterface { + fun produceTargetType(): TargetType +} + +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/kt47989b.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989b.fir.kt new file mode 100644 index 00000000000..d295ffdee9b --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989b.fir.kt @@ -0,0 +1,28 @@ +// ISSUE: KT-47989 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + object: TypeSourceInterface { + override fun produceTargetTypeBuildee() = this@build + } + } + // 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) +} + + + + +class TargetType + +interface TypeSourceInterface { + fun produceTargetTypeBuildee(): Buildee +} + +class Buildee + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt47989b.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989b.kt new file mode 100644 index 00000000000..907c9a3795d --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt47989b.kt @@ -0,0 +1,28 @@ +// ISSUE: KT-47989 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + object: TypeSourceInterface { + override fun produceTargetTypeBuildee() = this@build + } + } + // 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) +} + + + + +class TargetType + +interface TypeSourceInterface { + fun produceTargetTypeBuildee(): Buildee +} + +class Buildee + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +}