diff --git a/compiler/testData/codegen/box/builderInference/issues/kt54400a.kt b/compiler/testData/codegen/box/builderInference/issues/kt54400a.kt new file mode 100644 index 00000000000..4bba0b0b267 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt54400a.kt @@ -0,0 +1,26 @@ +// ISSUE: KT-54400 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build { + typeVariableMutableProperty = "" + } + return "OK" +} + + + + +class Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { storage = value } + private var storage: TV = "" as TV +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/codegen/box/builderInference/issues/kt54400b.kt b/compiler/testData/codegen/box/builderInference/issues/kt54400b.kt new file mode 100644 index 00000000000..8ded81226e7 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt54400b.kt @@ -0,0 +1,26 @@ +// ISSUE: KT-54400 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build { + typeVariableMutableProperty = 42 + } + return "OK" +} + + + + +class Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { storage = value } + private var storage: TV = 42 as TV +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/codegen/box/builderInference/issues/kt54400c.kt b/compiler/testData/codegen/box/builderInference/issues/kt54400c.kt new file mode 100644 index 00000000000..fdd3ceca765 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt54400c.kt @@ -0,0 +1,26 @@ +// ISSUE: KT-54400 + +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: ANY +// REASON: red code (see corresponding diagnostic test) + +fun box(): String { + build { + typeVariableMutableProperty = {} + } + return "OK" +} + + + + +class Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { storage = value } + private var storage: TV = {} as TV +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt54400a.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400a.fir.kt new file mode 100644 index 00000000000..5e4816d6194 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400a.fir.kt @@ -0,0 +1,25 @@ +// ISSUE: KT-54400 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + typeVariableMutableProperty = "" + } + // 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 Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { 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/kt54400a.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400a.kt new file mode 100644 index 00000000000..8923678043a --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400a.kt @@ -0,0 +1,25 @@ +// ISSUE: KT-54400 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + typeVariableMutableProperty = "" + } + // 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 Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { 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/kt54400b.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400b.fir.kt new file mode 100644 index 00000000000..9e37b8906ad --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400b.fir.kt @@ -0,0 +1,25 @@ +// ISSUE: KT-54400 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + typeVariableMutableProperty = 42 + } + // 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 Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { 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/kt54400b.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400b.kt new file mode 100644 index 00000000000..c9b68318ed0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400b.kt @@ -0,0 +1,25 @@ +// ISSUE: KT-54400 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + typeVariableMutableProperty = 42 + } + // 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 Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { 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/kt54400c.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400c.fir.kt new file mode 100644 index 00000000000..f725c076192 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400c.fir.kt @@ -0,0 +1,25 @@ +// ISSUE: KT-54400 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + typeVariableMutableProperty = {} + } + // 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<() -> Unit>>(buildee) +} + + + + +class Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { 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/kt54400c.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400c.kt new file mode 100644 index 00000000000..117d0b4592d --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt54400c.kt @@ -0,0 +1,25 @@ +// ISSUE: KT-54400 +// CHECK_TYPE_WITH_EXACT + +fun test() { + val buildee = build { + typeVariableMutableProperty = Unit")!>{} + } + // 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 Unit>>(buildee) +} + + + + +class Buildee { + var typeVariableMutableProperty: TV + get() = storage + set(value) { storage = value } + private var storage: TV = null!! +} + +fun build(instructions: Buildee.() -> Unit): Buildee { + return Buildee().apply(instructions) +}