From 4269729b0a5900234c17c81bc147b078340a3ef3 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Tue, 1 Apr 2014 10:53:39 +0400 Subject: [PATCH] KT-3214: Verify error when get array convention is used with varargs #KT-3214 Can'tReproduce --- .../testData/codegen/box/functions/kt3214.kt | 33 +++++++++++++++++++ .../BlackBoxCodegenTestGenerated.java | 5 +++ 2 files changed, 38 insertions(+) create mode 100644 compiler/testData/codegen/box/functions/kt3214.kt diff --git a/compiler/testData/codegen/box/functions/kt3214.kt b/compiler/testData/codegen/box/functions/kt3214.kt new file mode 100644 index 00000000000..88dbc15f878 --- /dev/null +++ b/compiler/testData/codegen/box/functions/kt3214.kt @@ -0,0 +1,33 @@ +class A { + fun get(vararg x: Int) = x.size +} + +class B { + fun get(vararg x: Unit) = x.size +} + +fun test1(a: A): Int { + return a[1] +} + +fun test2(a: A): Int { + return a[1, 2] +} + +fun test3(b: B): Int { + return b[Unit.VALUE, Unit.VALUE] +} + + +fun box() : String { + var result = test1(A()) + if (result != 1) return "fail1: $result" + + result = test2(A()) + if (result != 2) return "fail2: $result" + + result = test3(B()) + if (result != 2) return "fail3: $result" + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java index d4d84906c89..ad02475af32 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -2817,6 +2817,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest("compiler/testData/codegen/box/functions/kt2929.kt"); } + @TestMetadata("kt3214.kt") + public void testKt3214() throws Exception { + doTest("compiler/testData/codegen/box/functions/kt3214.kt"); + } + @TestMetadata("kt3313.kt") public void testKt3313() throws Exception { doTest("compiler/testData/codegen/box/functions/kt3313.kt");