From cb13dd3cdd762c2f1730a2dbcd5f154ffaba6600 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 10 Sep 2019 16:03:50 +0300 Subject: [PATCH] Add psi2ir tests for 'break' and 'continue' inside 'when' --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 5 + .../expressions/breakContinueInWhen.fir.txt | 139 ++++++++++++++++ .../irText/expressions/breakContinueInWhen.kt | 61 ++++++++ .../expressions/breakContinueInWhen.txt | 148 ++++++++++++++++++ .../kotlin/ir/IrTextTestCaseGenerated.java | 5 + 5 files changed, 358 insertions(+) create mode 100644 compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/breakContinueInWhen.kt create mode 100644 compiler/testData/ir/irText/expressions/breakContinueInWhen.txt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index e78a9ec55b2..b11a9e46928 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -747,6 +747,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.kt"); } + @TestMetadata("breakContinueInWhen.kt") + public void testBreakContinueInWhen() throws Exception { + runTest("compiler/testData/ir/irText/expressions/breakContinueInWhen.kt"); + } + @TestMetadata("callWithReorderedArguments.kt") public void testCallWithReorderedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callWithReorderedArguments.kt"); diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt new file mode 100644 index 00000000000..6f9d9a0c93f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt @@ -0,0 +1,139 @@ +FILE fqName: fileName:/breakContinueInWhen.kt + FUN name:testBreakFor visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:xs type:kotlin.IntArray [val] + CONSTRUCTOR_CALL 'public constructor (size: kotlin.Int, init: kotlin.Function1) declared in kotlin.IntArray' type=kotlin.IntArray origin=null + size: CONST Int type=kotlin.Int value=10 + init: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name:i index:0 type:kotlin.Int + BLOCK_BODY + GET_VAR 'i: kotlin.Int declared in .testBreakFor.' type=kotlin.Int origin=null + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + VAR name: type:kotlin.IntArray [val] + GET_VAR 'val xs: kotlin.IntArray [val] declared in .testBreakFor' type=kotlin.IntArray origin=null + VAR name: type:kotlin.collections.IntIterator [val] + CALL 'public final fun iterator (): kotlin.collections.IntIterator declared in kotlin.IntArray' type=kotlin.collections.IntIterator origin=null + $this: GET_VAR 'val : kotlin.IntArray [val] declared in .testBreakFor' type=kotlin.IntArray origin=null + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null + $this: GET_VAR 'val : kotlin.collections.IntIterator [val] declared in .testBreakFor' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=null + VAR name:x type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=null + $this: GET_VAR 'val : kotlin.collections.IntIterator [val] declared in .testBreakFor' type=kotlin.collections.IntIterator origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakFor' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null + FUN name:testBreakWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + WHILE label=null origin=WHILE_LOOP + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + body: WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null + FUN name:testBreakDoWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + DO_WHILE label=null origin=DO_WHILE_LOOP + body: WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + FUN name:testContinueFor visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:xs type:kotlin.IntArray [val] + CONSTRUCTOR_CALL 'public constructor (size: kotlin.Int, init: kotlin.Function1) declared in kotlin.IntArray' type=kotlin.IntArray origin=null + size: CONST Int type=kotlin.Int value=10 + init: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name:i index:0 type:kotlin.Int + BLOCK_BODY + GET_VAR 'i: kotlin.Int declared in .testContinueFor.' type=kotlin.Int origin=null + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + VAR name: type:kotlin.IntArray [val] + GET_VAR 'val xs: kotlin.IntArray [val] declared in .testContinueFor' type=kotlin.IntArray origin=null + VAR name: type:kotlin.collections.IntIterator [val] + CALL 'public final fun iterator (): kotlin.collections.IntIterator declared in kotlin.IntArray' type=kotlin.collections.IntIterator origin=null + $this: GET_VAR 'val : kotlin.IntArray [val] declared in .testContinueFor' type=kotlin.IntArray origin=null + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null + $this: GET_VAR 'val : kotlin.collections.IntIterator [val] declared in .testContinueFor' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=null + VAR name:x type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=null + $this: GET_VAR 'val : kotlin.collections.IntIterator [val] declared in .testContinueFor' type=kotlin.collections.IntIterator origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueFor' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null + FUN name:testContinueWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + WHILE label=null origin=WHILE_LOOP + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + body: WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null + FUN name:testContinueDoWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + VAR name:s type:kotlin.String [var] + CONST String type=kotlin.String value="" + DO_WHILE label=null origin=DO_WHILE_LOOP + body: BLOCK type=kotlin.Unit origin=null + VAR name: type:kotlin.Int [val] + GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + SET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val : kotlin.Int [val] declared in .testContinueDoWhile' type=kotlin.Int origin=null + GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null + SET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=null + STRING_CONCATENATION type=kotlin.String + GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + CONST String type=kotlin.String value=";" + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=null + arg1: CONST String type=kotlin.String value="1;2;" + then: THROW type=kotlin.Nothing + CONSTRUCTOR_CALL 'public constructor (detailMessage: kotlin.Any?) declared in java.lang.AssertionError' type=java.lang.AssertionError origin=null + detailMessage: GET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.kt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.kt new file mode 100644 index 00000000000..add8594d562 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.kt @@ -0,0 +1,61 @@ +// !LANGUAGE: +AllowBreakAndContinueInsideWhen + +fun testBreakFor() { + val xs = IntArray(10) { i -> i } + var k = 0 + for (x in xs) { + when { + k > 2 -> break + } + } +} + +fun testBreakWhile() { + var k = 0 + while (k < 10) { + when { + k > 2 -> break + } + } +} + +fun testBreakDoWhile() { + var k = 0 + do { + when { + k > 2 -> break + } + } while (k < 10) +} + +fun testContinueFor() { + val xs = IntArray(10) { i -> i } + var k = 0 + for (x in xs) { + when { + k > 2 -> continue + } + } +} + +fun testContinueWhile() { + var k = 0 + while (k < 10) { + when { + k > 2 -> continue + } + } +} + +fun testContinueDoWhile() { + var k = 0 + var s = "" + do { + ++k + when { + k > 2 -> continue + } + s += "$k;" + } while (k < 10) + if (s != "1;2;") throw AssertionError(s) +} diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.txt new file mode 100644 index 00000000000..1f2d1d91c27 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.txt @@ -0,0 +1,148 @@ +FILE fqName: fileName:/breakContinueInWhen.kt + FUN name:testBreakFor visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:xs type:kotlin.IntArray [val] + CONSTRUCTOR_CALL 'public constructor (size: kotlin.Int, init: kotlin.Function1) declared in kotlin.IntArray' type=kotlin.IntArray origin=null + size: CONST Int type=kotlin.Int value=10 + init: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name:i index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (i: kotlin.Int): kotlin.Int declared in .testBreakFor' + GET_VAR 'i: kotlin.Int declared in .testBreakFor.' type=kotlin.Int origin=null + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp0_iterator type:kotlin.collections.IntIterator [val] + CALL 'public final fun iterator (): kotlin.collections.IntIterator declared in kotlin.IntArray' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: GET_VAR 'val xs: kotlin.IntArray [val] declared in .testBreakFor' type=kotlin.IntArray origin=null + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .testBreakFor' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:x type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .testBreakFor' type=kotlin.collections.IntIterator origin=null + BLOCK type=kotlin.Nothing origin=null + WHEN type=kotlin.Nothing origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakFor' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null + FUN name:testBreakWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + WHILE label=null origin=WHILE_LOOP + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + body: BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Nothing origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null + FUN name:testBreakDoWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + WHEN type=kotlin.Nothing origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + FUN name:testContinueFor visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:xs type:kotlin.IntArray [val] + CONSTRUCTOR_CALL 'public constructor (size: kotlin.Int, init: kotlin.Function1) declared in kotlin.IntArray' type=kotlin.IntArray origin=null + size: CONST Int type=kotlin.Int value=10 + init: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name:i index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (i: kotlin.Int): kotlin.Int declared in .testContinueFor' + GET_VAR 'i: kotlin.Int declared in .testContinueFor.' type=kotlin.Int origin=null + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp0_iterator type:kotlin.collections.IntIterator [val] + CALL 'public final fun iterator (): kotlin.collections.IntIterator declared in kotlin.IntArray' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: GET_VAR 'val xs: kotlin.IntArray [val] declared in .testContinueFor' type=kotlin.IntArray origin=null + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .testContinueFor' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:x type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .testContinueFor' type=kotlin.collections.IntIterator origin=null + BLOCK type=kotlin.Nothing origin=null + WHEN type=kotlin.Nothing origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueFor' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null + FUN name:testContinueWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + WHILE label=null origin=WHILE_LOOP + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + body: BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Nothing origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null + FUN name:testContinueDoWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:k type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + VAR name:s type:kotlin.String [var] + CONST String type=kotlin.String value="" + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + BLOCK type=kotlin.Int origin=PREFIX_INCR + SET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=PREFIX_INCR + CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PREFIX_INCR + $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=PREFIX_INCR + GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=PREFIX_INCR + WHEN type=kotlin.Nothing origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null + SET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: GET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=PLUSEQ + other: STRING_CONCATENATION type=kotlin.String + GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + CONST String type=kotlin.String value=";" + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=null + arg1: CONST String type=kotlin.String value="1;2;" + then: THROW type=kotlin.Nothing + CONSTRUCTOR_CALL 'public constructor (detailMessage: kotlin.Any?) declared in java.lang.AssertionError' type=java.lang.AssertionError origin=null + detailMessage: GET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 5892384d248..298a9f08036 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -747,6 +747,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.kt"); } + @TestMetadata("breakContinueInWhen.kt") + public void testBreakContinueInWhen() throws Exception { + runTest("compiler/testData/ir/irText/expressions/breakContinueInWhen.kt"); + } + @TestMetadata("callWithReorderedArguments.kt") public void testCallWithReorderedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callWithReorderedArguments.kt");