diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index faa913e718c..20d295d9abc 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -19253,6 +19253,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia public void testTypealiasOnLong() throws Exception { runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/diagnostics/tests/integerLiterals/vararg.kt"); + } } @Nested diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index d937de1db78..2a1d21efac6 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -19253,6 +19253,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated public void testTypealiasOnLong() throws Exception { runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/diagnostics/tests/integerLiterals/vararg.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 7d3033562d8..6102c72bc16 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -19253,6 +19253,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir public void testTypealiasOnLong() throws Exception { runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/diagnostics/tests/integerLiterals/vararg.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index d96699a0572..094abe5e732 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -19259,6 +19259,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia public void testTypealiasOnLong() throws Exception { runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/diagnostics/tests/integerLiterals/vararg.kt"); + } } @Nested diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index ba70a35d54c..35f65fd7c8d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -18572,6 +18572,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr public void testUnqualifiedEnum() throws Exception { runTest("compiler/testData/codegen/box/fir/unqualifiedEnum.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/codegen/box/fir/vararg.kt"); + } } @Nested diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index ccb45f4b4a7..1c987fc8032 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -18572,6 +18572,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo public void testUnqualifiedEnum() throws Exception { runTest("compiler/testData/codegen/box/fir/unqualifiedEnum.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/codegen/box/fir/vararg.kt"); + } } @Nested diff --git a/compiler/testData/codegen/box/fir/vararg.kt b/compiler/testData/codegen/box/fir/vararg.kt new file mode 100644 index 00000000000..70d0a501a8d --- /dev/null +++ b/compiler/testData/codegen/box/fir/vararg.kt @@ -0,0 +1,23 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: JVM_IR +// (type mismatch) +// IGNORE_BACKEND_K2: JVM_IR +// (CCE in select) +// WITH_STDLIB + +fun > arrayData(vararg values: A): A = values.first() + +fun test(b: Byte) = select(arrayData(1), b) + +fun > select(a: S, b: S): S { + if (a.compareTo(b) > 0) return a else return b +} + +fun box(): String { + val res = test(-42) + val res2 = res.dec() + res.doSomething() + if (res == 1.toByte() && res2 == 0.toByte()) return "OK" else return res.toString() +} + +fun Byte.doSomething() {} diff --git a/compiler/testData/diagnostics/tests/integerLiterals/vararg.fir.kt b/compiler/testData/diagnostics/tests/integerLiterals/vararg.fir.kt new file mode 100644 index 00000000000..af312928afa --- /dev/null +++ b/compiler/testData/diagnostics/tests/integerLiterals/vararg.fir.kt @@ -0,0 +1,17 @@ +// FIR_DUMP + +fun > arrayData(vararg values: A): A = null!! + +fun arrayDataNoBound(vararg values: A): A = null!! + +fun test(b: Byte) { + select(arrayData(1), b) + select(id(1), b) + select(id(arrayData(1)), b) + select(arrayDataNoBound(1), b) +} + +fun select(a: S, b: S) = a + +fun > id(arg: I) = arg + diff --git a/compiler/testData/diagnostics/tests/integerLiterals/vararg.fir.txt b/compiler/testData/diagnostics/tests/integerLiterals/vararg.fir.txt new file mode 100644 index 00000000000..c27fc29cce7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/integerLiterals/vararg.fir.txt @@ -0,0 +1,19 @@ +FILE: vararg.fir.kt + public final fun |> arrayData(vararg values: R|kotlin/Array|): R|A| { + ^arrayData Null(null)!! + } + public final fun arrayDataNoBound(vararg values: R|kotlin/Array|): R|A| { + ^arrayDataNoBound Null(null)!! + } + public final fun test(b: R|kotlin/Byte|): R|kotlin/Unit| { + R|/select|(R|/arrayData|(vararg(Int(1))), R|/b|) + R|/select|(R|/id|(Int(1)), R|/b|) + R|/select|(R|/id|(R|/arrayData|(vararg(Int(1)))), R|/b|) + R|/select|(R|/arrayDataNoBound|(vararg(Byte(1))), R|/b|) + } + public final fun select(a: R|S|, b: R|S|): R|S| { + ^select R|/a| + } + public final fun |> id(arg: R|I|): R|I| { + ^id R|/arg| + } diff --git a/compiler/testData/diagnostics/tests/integerLiterals/vararg.kt b/compiler/testData/diagnostics/tests/integerLiterals/vararg.kt new file mode 100644 index 00000000000..d90ce26ce0b --- /dev/null +++ b/compiler/testData/diagnostics/tests/integerLiterals/vararg.kt @@ -0,0 +1,16 @@ +// FIR_DUMP + +fun > arrayData(vararg values: A): A = null!! + +fun arrayDataNoBound(vararg values: A): A = null!! + +fun test(b: Byte) { + select(arrayData(1), b) + select(id(1), b) + select(id(arrayData(1)), b) + select(arrayDataNoBound(1), b) +} + +fun select(a: S, b: S) = a + +fun > id(arg: I) = arg diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 9f15204df44..718f004126d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -19259,6 +19259,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testTypealiasOnLong() throws Exception { runTest("compiler/testData/diagnostics/tests/integerLiterals/typealiasOnLong.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/diagnostics/tests/integerLiterals/vararg.kt"); + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index e0b9e74049e..d83dc25b832 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -18572,6 +18572,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testUnqualifiedEnum() throws Exception { runTest("compiler/testData/codegen/box/fir/unqualifiedEnum.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/codegen/box/fir/vararg.kt"); + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index ff578c43003..9da33147b1f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -18572,6 +18572,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack public void testUnqualifiedEnum() throws Exception { runTest("compiler/testData/codegen/box/fir/unqualifiedEnum.kt"); } + + @Test + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + runTest("compiler/testData/codegen/box/fir/vararg.kt"); + } } @Nested