From 7515efc52c59bb1de8d06224d7aca800130faa23 Mon Sep 17 00:00:00 2001 From: Stanislav Ruban Date: Sat, 2 Dec 2023 17:41:55 +0100 Subject: [PATCH] [tests] Change builder inference tests in accordance with new K2 BI diagnostics Related to KT-59369, KT-59390 --- .../box/builderInference/issues/kt53639.kt | 4 +-- .../box/builderInference/issues/kt53740a.kt | 5 +--- .../box/builderInference/issues/kt53740b.kt | 5 +--- .../box/builderInference/issues/kt59798.kt | 2 +- .../box/builderInference/issues/kt60291a.kt | 4 +-- .../box/builderInference/issues/kt60291b.kt | 5 +--- .../box/builderInference/issues/kt60291c.kt | 4 +-- .../box/builderInference/issues/kt63648.kt | 5 +--- .../builderInference/issues/kt43710.fir.kt | 2 +- .../builderInference/issues/kt53422a.fir.kt | 4 +-- .../builderInference/issues/kt53422b.fir.kt | 10 +++---- .../builderInference/issues/kt53553.fir.kt | 8 ++--- .../builderInference/issues/kt53639.fir.kt | 4 +-- .../builderInference/issues/kt53740a.fir.kt | 8 ++--- .../builderInference/issues/kt53740b.fir.kt | 8 ++--- .../builderInference/issues/kt59798.fir.kt | 4 +-- .../builderInference/issues/kt60291a.fir.kt | 29 ------------------- .../tests/builderInference/issues/kt60291a.kt | 1 + .../builderInference/issues/kt60291b.fir.kt | 26 ----------------- .../tests/builderInference/issues/kt60291b.kt | 1 + .../builderInference/issues/kt60291c.fir.kt | 27 ----------------- .../tests/builderInference/issues/kt60291c.kt | 1 + .../builderInference/issues/kt63648.fir.kt | 4 +-- 23 files changed, 37 insertions(+), 134 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt60291a.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.fir.kt diff --git a/compiler/testData/codegen/box/builderInference/issues/kt53639.kt b/compiler/testData/codegen/box/builderInference/issues/kt53639.kt index 9236053eb09..592df4b1438 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt53639.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt53639.kt @@ -2,9 +2,7 @@ // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: ANY -// REASON: red code in K1 (see corresponding diagnostic test) -// REASON: compile-time failure in K2/JVM (java.lang.IllegalStateException: Cannot serialize error type: ERROR CLASS: Cannot infer argument for type parameter PTV) -// REASON: compile-time failure in K2/Native, K2/WASM, K2/JS (org.jetbrains.kotlin.backend.common.linkage.issues.IrDisallowedErrorNode: Class found but error nodes are not allowed) +// REASON: red code (see corresponding diagnostic test) fun box(): String { val buildee = initializeAndBuild( diff --git a/compiler/testData/codegen/box/builderInference/issues/kt53740a.kt b/compiler/testData/codegen/box/builderInference/issues/kt53740a.kt index 121c7d0787a..bc8e33dbb02 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt53740a.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt53740a.kt @@ -1,12 +1,9 @@ // ISSUE: KT-53740 // IGNORE_LIGHT_ANALYSIS -// IGNORE_BACKEND_K1: ANY +// IGNORE_BACKEND: ANY // REASON: red code (see corresponding diagnostic test) -// IGNORE_BACKEND_K2: JVM_IR, WASM -// REASON: run-time failure (java.lang.ClassCastException: TargetType cannot be cast to DifferentType @ Kt53740aKt$box$2.invoke) - fun box(): String { parallelBuild( { diff --git a/compiler/testData/codegen/box/builderInference/issues/kt53740b.kt b/compiler/testData/codegen/box/builderInference/issues/kt53740b.kt index 44bc436d773..5e095919b12 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt53740b.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt53740b.kt @@ -1,12 +1,9 @@ // ISSUE: KT-53740 // IGNORE_LIGHT_ANALYSIS -// IGNORE_BACKEND_K1: ANY +// IGNORE_BACKEND: ANY // REASON: red code (see corresponding diagnostic test) -// IGNORE_BACKEND_K2: JVM_IR, WASM -// REASON: run-time failure (java.lang.ClassCastException: TargetType cannot be cast to DifferentType @ Kt53740bKt$box$2.invoke) - fun box(): String { parallelInOutBuild( { diff --git a/compiler/testData/codegen/box/builderInference/issues/kt59798.kt b/compiler/testData/codegen/box/builderInference/issues/kt59798.kt index 515afde2e07..dd5262b6b3d 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt59798.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt59798.kt @@ -1,7 +1,7 @@ // ISSUE: KT-59798 // IGNORE_LIGHT_ANALYSIS -// IGNORE_BACKEND_K1: ANY +// IGNORE_BACKEND: ANY // REASON: red code (see corresponding diagnostic test) fun box(): String { diff --git a/compiler/testData/codegen/box/builderInference/issues/kt60291a.kt b/compiler/testData/codegen/box/builderInference/issues/kt60291a.kt index 0b31efc5719..a702a190f15 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt60291a.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt60291a.kt @@ -3,9 +3,7 @@ // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: ANY -// REASON: red code in K1 (see corresponding diagnostic test) -// REASON: compile-time failure in K2/JVM (java.lang.IllegalStateException: Cannot serialize error type: ERROR CLASS: Cannot infer argument for type parameter PTV) -// REASON: compile-time failure in K2/Native, K2/WASM, K2/JS (org.jetbrains.kotlin.backend.common.linkage.issues.IrDisallowedErrorNode: Class found but error nodes are not allowed) +// REASON: red code (see corresponding diagnostic test) fun box(): String { selectBuildee( diff --git a/compiler/testData/codegen/box/builderInference/issues/kt60291b.kt b/compiler/testData/codegen/box/builderInference/issues/kt60291b.kt index 6bf3077aa1f..5fb5a661b20 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt60291b.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt60291b.kt @@ -1,12 +1,9 @@ // ISSUE: KT-60291 // IGNORE_LIGHT_ANALYSIS -// IGNORE_BACKEND_K1: ANY +// IGNORE_BACKEND: ANY // REASON: red code (see corresponding diagnostic test) -// IGNORE_BACKEND_K2: NATIVE, WASM, JS_IR, JS_IR_ES6 -// REASON: compile-time failure (org.jetbrains.kotlin.backend.common.linkage.issues.IrDisallowedErrorNode: Class found but error nodes are not allowed) - fun box(): String { if (true) build { setTypeVariable(TargetType()) } diff --git a/compiler/testData/codegen/box/builderInference/issues/kt60291c.kt b/compiler/testData/codegen/box/builderInference/issues/kt60291c.kt index b29a8f401c2..1575e9efe3a 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt60291c.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt60291c.kt @@ -2,9 +2,7 @@ // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: ANY -// REASON: red code in K1 (see corresponding diagnostic test) -// REASON: compile-time failure in K2/JVM (java.lang.IllegalStateException: Cannot serialize error type: ERROR CLASS: Cannot infer argument for type parameter PTV) -// REASON: compile-time failure in K2/Native, K2/WASM, K2/JS (org.jetbrains.kotlin.backend.common.linkage.issues.IrDisallowedErrorNode: Class found but error nodes are not allowed) +// REASON: red code (see corresponding diagnostic test) fun box(): String { when ("") { diff --git a/compiler/testData/codegen/box/builderInference/issues/kt63648.kt b/compiler/testData/codegen/box/builderInference/issues/kt63648.kt index f55e7fcc062..ee919356ed8 100644 --- a/compiler/testData/codegen/box/builderInference/issues/kt63648.kt +++ b/compiler/testData/codegen/box/builderInference/issues/kt63648.kt @@ -1,12 +1,9 @@ // ISSUE: KT-63648 // IGNORE_LIGHT_ANALYSIS -// IGNORE_BACKEND_K1: ANY +// IGNORE_BACKEND: ANY // REASON: red code (see corresponding diagnostic test) -// IGNORE_BACKEND_K2: JVM_IR, WASM -// REASON: run-time failure (java.lang.ClassCastException: TargetType cannot be cast to DifferentType @ Kt63648Kt$box$1.invoke) - fun box(): String { build { setTypeVariable(TargetType()) diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt43710.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt43710.fir.kt index 901b632759a..6dee4794c10 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt43710.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt43710.fir.kt @@ -4,7 +4,7 @@ fun test() { val buildee = build { setTypeVariable(TargetType()) - letForTypeVariable { it.extensionProduceConcreteType() } + letForTypeVariable { it.extensionProduceConcreteType() } } // 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 diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53422a.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53422a.fir.kt index b16da0099f0..6208ac347d9 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt53422a.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53422a.fir.kt @@ -3,8 +3,8 @@ fun test() { val buildee = buildFromValue( - innerBuild { setInnerTypeVariable(TargetType()) }, - { it.placeholderExtensionInvokeOnInnerBuildee() } + innerBuild { setInnerTypeVariable(TargetType()) }, + { it.placeholderExtensionInvokeOnInnerBuildee() } ) // 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 diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53422b.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53422b.fir.kt index 95f06b77c28..554027b0f6c 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt53422b.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53422b.fir.kt @@ -3,17 +3,17 @@ fun test() { val buildee = stepByStepBuild( - { + { it.concreteTypeMemberProperty TargetType() - }, - { + }, + { consumeTargetTypeBase(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) + checkExactType>(; Buildee")!>buildee) } diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.fir.kt index e3039f549d3..c167d393400 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53553.fir.kt @@ -3,12 +3,12 @@ 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 diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53639.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53639.fir.kt index d79f49cd6e3..9ca58ba7da3 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt53639.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53639.fir.kt @@ -3,8 +3,8 @@ fun test() { val buildee = initializeAndBuild( - { build { setTypeVariable(TargetType()) } }, - { placeholderExtensionInvokeOnBuildee() }, + { build { setTypeVariable(TargetType()) } }, + { placeholderExtensionInvokeOnBuildee() }, ) // 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 diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53740a.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53740a.fir.kt index f02069d58d9..6f61986a215 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt53740a.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53740a.fir.kt @@ -3,12 +3,12 @@ fun test() { val buildee = parallelBuild( - { + { setTypeVariable(TargetType()) - }, - { + }, + { consumeDifferentType(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 diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53740b.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53740b.fir.kt index d049158b2ac..46ff0dea365 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt53740b.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53740b.fir.kt @@ -3,12 +3,12 @@ fun test() { val buildee = parallelInOutBuild( - { + { setInProjectedTypeVariable(TargetType()) - }, - { + }, + { consumeDifferentType(getOutProjectedTypeVariable()) - } + } ) // 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 diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt59798.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt59798.fir.kt index 60f4254e103..93d2888f2cd 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt59798.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt59798.fir.kt @@ -4,7 +4,7 @@ fun test() { val buildee = build { setTypeVariable(TargetType()) - getTypeVariable().let {} + getTypeVariable().let {} } // 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 @@ -24,4 +24,4 @@ class Buildee { fun build(instructions: Buildee.() -> Unit): Buildee { return Buildee().apply(instructions) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291a.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291a.fir.kt deleted file mode 100644 index 560e7995c99..00000000000 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291a.fir.kt +++ /dev/null @@ -1,29 +0,0 @@ -// ISSUE: KT-60291 -// CHECK_TYPE_WITH_EXACT -// WITH_STDLIB - -fun test() { - val buildee = selectBuildee( - build { setTypeVariable(TargetType()) }, - 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) -} - - - - -fun selectBuildee(vararg values: Buildee): Buildee = values.first() - -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/kt60291a.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291a.kt index 8477c928387..d03397ece74 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291a.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291a.kt @@ -1,4 +1,5 @@ // ISSUE: KT-60291 +// FIR_IDENTICAL // CHECK_TYPE_WITH_EXACT // WITH_STDLIB diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.fir.kt deleted file mode 100644 index 385a9dd2e7c..00000000000 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.fir.kt +++ /dev/null @@ -1,26 +0,0 @@ -// ISSUE: KT-60291 -// CHECK_TYPE_WITH_EXACT - -fun test() { - val buildee = if (true) - build { setTypeVariable(TargetType()) } - else - 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 - -class Buildee { - fun setTypeVariable(value: TV) { storage = value } - private var storage: TV = null!! -} - -fun build(instructions: Buildee.() -> Unit): Buildee { - return Buildee().apply(instructions) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.kt index 0179a242c2f..6320ac3eabe 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291b.kt @@ -1,4 +1,5 @@ // ISSUE: KT-60291 +// FIR_IDENTICAL // CHECK_TYPE_WITH_EXACT fun test() { diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.fir.kt deleted file mode 100644 index d21082a4410..00000000000 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.fir.kt +++ /dev/null @@ -1,27 +0,0 @@ -// ISSUE: KT-60291 -// CHECK_TYPE_WITH_EXACT - -fun test() { - val buildee = when ("") { - "true" -> build { setTypeVariable(TargetType()) } - "false" -> build {} - else -> Buildee() - } - // 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 - -class Buildee { - fun setTypeVariable(value: TV) { storage = value } - private var storage: TV = null!! -} - -fun build(instructions: Buildee.() -> Unit): Buildee { - return Buildee().apply(instructions) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.kt index 3164082d6cc..16ff6cbe300 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt60291c.kt @@ -1,4 +1,5 @@ // ISSUE: KT-60291 +// FIR_IDENTICAL // CHECK_TYPE_WITH_EXACT fun test() { diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt63648.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt63648.fir.kt index b2c2b7880e3..bcbb7767e3b 100644 --- a/compiler/testData/diagnostics/tests/builderInference/issues/kt63648.fir.kt +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt63648.fir.kt @@ -4,7 +4,7 @@ fun test() { val buildee = build { setTypeVariable(TargetType()) - getTypeVariable().consumeDifferentTypeReceiver() + getTypeVariable().consumeDifferentTypeReceiver() } // 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 @@ -27,4 +27,4 @@ class Buildee { fun build(instructions: Buildee.() -> Unit): Buildee { return Buildee().apply(instructions) -} \ No newline at end of file +}