From 2a257091fbf537f544e70d2053b05bd3432a9f88 Mon Sep 17 00:00:00 2001 From: Stanislav Ruban Date: Thu, 30 Nov 2023 22:03:02 +0100 Subject: [PATCH] [tests] Add test data for KT-49160 --- .../box/builderInference/issues/kt49160a.kt | 33 +++++++++++++++++ .../box/builderInference/issues/kt49160b.kt | 33 +++++++++++++++++ .../box/builderInference/issues/kt49160c.kt | 31 ++++++++++++++++ .../box/builderInference/issues/kt49160d.kt | 29 +++++++++++++++ .../box/builderInference/issues/kt49160e.kt | 32 ++++++++++++++++ .../builderInference/issues/kt49160a.fir.kt | 35 ++++++++++++++++++ .../tests/builderInference/issues/kt49160a.kt | 35 ++++++++++++++++++ .../builderInference/issues/kt49160b.fir.kt | 35 ++++++++++++++++++ .../tests/builderInference/issues/kt49160b.kt | 35 ++++++++++++++++++ .../builderInference/issues/kt49160c.fir.kt | 33 +++++++++++++++++ .../tests/builderInference/issues/kt49160c.kt | 33 +++++++++++++++++ .../builderInference/issues/kt49160d.fir.kt | 31 ++++++++++++++++ .../tests/builderInference/issues/kt49160d.kt | 31 ++++++++++++++++ .../builderInference/issues/kt49160e.fir.kt | 37 +++++++++++++++++++ .../tests/builderInference/issues/kt49160e.kt | 37 +++++++++++++++++++ 15 files changed, 500 insertions(+) create mode 100644 compiler/testData/codegen/box/builderInference/issues/kt49160a.kt create mode 100644 compiler/testData/codegen/box/builderInference/issues/kt49160b.kt create mode 100644 compiler/testData/codegen/box/builderInference/issues/kt49160c.kt create mode 100644 compiler/testData/codegen/box/builderInference/issues/kt49160d.kt create mode 100644 compiler/testData/codegen/box/builderInference/issues/kt49160e.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.fir.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.fir.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.fir.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.fir.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.fir.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.kt diff --git a/compiler/testData/codegen/box/builderInference/issues/kt49160a.kt b/compiler/testData/codegen/box/builderInference/issues/kt49160a.kt new file mode 100644 index 00000000000..a1099e93910 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt49160a.kt @@ -0,0 +1,33 @@ +// ISSUE: KT-49160 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build outerBuild@ { + class LocalClass { + fun localClassMember() { + build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + } + } + } + return "OK" +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + 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/kt49160b.kt b/compiler/testData/codegen/box/builderInference/issues/kt49160b.kt new file mode 100644 index 00000000000..4f2c901977b --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt49160b.kt @@ -0,0 +1,33 @@ +// ISSUE: KT-49160 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build outerBuild@ { + object { + fun anonymousObjectMember() { + build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + } + } + } + return "OK" +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + 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/kt49160c.kt b/compiler/testData/codegen/box/builderInference/issues/kt49160c.kt new file mode 100644 index 00000000000..3fa3a6d498f --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt49160c.kt @@ -0,0 +1,31 @@ +// ISSUE: KT-49160 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build outerBuild@ { + fun localFunction() { + build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + } + } + return "OK" +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + 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/kt49160d.kt b/compiler/testData/codegen/box/builderInference/issues/kt49160d.kt new file mode 100644 index 00000000000..2e3e46c418d --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt49160d.kt @@ -0,0 +1,29 @@ +// ISSUE: KT-49160 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build outerBuild@ { + build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + } + return "OK" +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + 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/kt49160e.kt b/compiler/testData/codegen/box/builderInference/issues/kt49160e.kt new file mode 100644 index 00000000000..fa7521720bc --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt49160e.kt @@ -0,0 +1,32 @@ +// ISSUE: KT-49160 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build outerBuild@ { + build middleBuild@ { + build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@middleBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + } + } + return "OK" +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = TargetType() as TV +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.fir.kt new file mode 100644 index 00000000000..493643a9d47 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.fir.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + class LocalClass { + fun localClassMember() { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + } + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.kt new file mode 100644 index 00000000000..61ea5ea9bfa --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160a.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + class LocalClass { + fun localClassMember() { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + } + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.fir.kt new file mode 100644 index 00000000000..9e45a3d3d77 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.fir.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + object { + fun anonymousObjectMember() { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + } + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.kt new file mode 100644 index 00000000000..53eb05fd787 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160b.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + object { + fun anonymousObjectMember() { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + } + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.fir.kt new file mode 100644 index 00000000000..3e62da8c5f1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.fir.kt @@ -0,0 +1,33 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + fun localFunction() { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.kt new file mode 100644 index 00000000000..8b87fb4de4d --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160c.kt @@ -0,0 +1,33 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + fun localFunction() { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.fir.kt new file mode 100644 index 00000000000..eba034b5d3e --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.fir.kt @@ -0,0 +1,31 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.kt new file mode 100644 index 00000000000..d45e3c79b53 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160d.kt @@ -0,0 +1,31 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.fir.kt new file mode 100644 index 00000000000..bc07e6febb1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.fir.kt @@ -0,0 +1,37 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + val middleBuildee = build middleBuild@ { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@middleBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + // 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>(middleBuildee) + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.kt new file mode 100644 index 00000000000..0d6bbf6bd3b --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt49160e.kt @@ -0,0 +1,37 @@ +// ISSUE: KT-49160 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val outerBuildee = build outerBuild@ { + val middleBuildee = build middleBuild@ { + val innerBuildee = build innerBuild@ { + this@outerBuild.setTypeVariable(TargetType()) + this@middleBuild.setTypeVariable(TargetType()) + this@innerBuild.setTypeVariable(TargetType()) + } + // 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>(innerBuildee) + } + // 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>(middleBuildee) + } + // 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>(outerBuildee) +} + + + + +class TargetType + +class Buildee { + fun setTypeVariable(value: TV) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +}