FIR: implement trivial typing for break & continue
This commit is contained in:
+4
-1
@@ -6,15 +6,18 @@
|
|||||||
package org.jetbrains.kotlin.fir.expressions.impl
|
package org.jetbrains.kotlin.fir.expressions.impl
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.fir.FirAbstractElement
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.FirTarget
|
import org.jetbrains.kotlin.fir.FirTarget
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirJump
|
import org.jetbrains.kotlin.fir.expressions.FirJump
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirLoop
|
import org.jetbrains.kotlin.fir.expressions.FirLoop
|
||||||
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
|
import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef
|
||||||
|
|
||||||
abstract class FirAbstractLoopJump(
|
abstract class FirAbstractLoopJump(
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
psi: PsiElement?
|
psi: PsiElement?
|
||||||
) : FirAbstractExpression(session, psi), FirJump<FirLoop> {
|
) : FirAbstractExpression(session, psi), FirJump<FirLoop> {
|
||||||
override lateinit var target: FirTarget<FirLoop>
|
override lateinit var target: FirTarget<FirLoop>
|
||||||
|
|
||||||
|
override var typeRef: FirTypeRef = FirImplicitNothingTypeRef(session, psi)
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ FILE fqName:<root> fileName:/badBreakContinue.kt
|
|||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
WHILE label=L1 origin=WHILE_LOOP
|
WHILE label=L1 origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
ERROR_EXPR 'Unbound loop: break@@@[ERROR_EXPR(Cannot bind label ERROR to a loop)] ' type=kotlin.Nothing
|
ERROR_EXPR 'Unbound loop: break@@@[ERROR_EXPR(Cannot bind label ERROR to a loop)] ' type=kotlin.Nothing
|
||||||
ERROR_EXPR 'Unbound loop: continue@@@[ERROR_EXPR(Cannot bind label ERROR to a loop)] ' type=kotlin.Nothing
|
ERROR_EXPR 'Unbound loop: continue@@@[ERROR_EXPR(Cannot bind label ERROR to a loop)] ' type=kotlin.Nothing
|
||||||
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||||
@@ -20,7 +20,7 @@ FILE fqName:<root> fileName:/badBreakContinue.kt
|
|||||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:IrErrorType
|
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:IrErrorType
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): IrErrorType declared in <root>.test3'
|
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): IrErrorType declared in <root>.test3'
|
||||||
BLOCK type=IrErrorType origin=null
|
BLOCK type=kotlin.Nothing origin=null
|
||||||
BREAK label=L1 loop.label=L1
|
BREAK label=L1 loop.label=L1
|
||||||
CONTINUE label=L1 loop.label=L1
|
CONTINUE label=L1 loop.label=L1
|
||||||
FUNCTION_REFERENCE 'local final fun <anonymous> (): IrErrorType declared in <root>.test3' type=IrErrorType origin=LAMBDA
|
FUNCTION_REFERENCE 'local final fun <anonymous> (): IrErrorType declared in <root>.test3' type=IrErrorType origin=LAMBDA
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ FILE fqName:<root> fileName:/breakContinue.kt
|
|||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
WHILE label=OUTER origin=WHILE_LOOP
|
WHILE label=OUTER origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
WHILE label=INNER origin=WHILE_LOOP
|
WHILE label=INNER origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
BREAK label=INNER loop.label=INNER
|
BREAK label=INNER loop.label=INNER
|
||||||
BREAK label=OUTER loop.label=OUTER
|
BREAK label=OUTER loop.label=OUTER
|
||||||
BREAK label=OUTER loop.label=OUTER
|
BREAK label=OUTER loop.label=OUTER
|
||||||
WHILE label=OUTER origin=WHILE_LOOP
|
WHILE label=OUTER origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
WHILE label=INNER origin=WHILE_LOOP
|
WHILE label=INNER origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
CONTINUE label=INNER loop.label=INNER
|
CONTINUE label=INNER loop.label=INNER
|
||||||
CONTINUE label=OUTER loop.label=OUTER
|
CONTINUE label=OUTER loop.label=OUTER
|
||||||
CONTINUE label=OUTER loop.label=OUTER
|
CONTINUE label=OUTER loop.label=OUTER
|
||||||
@@ -37,14 +37,14 @@ FILE fqName:<root> fileName:/breakContinue.kt
|
|||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
WHILE label=L origin=WHILE_LOOP
|
WHILE label=L origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
WHILE label=L origin=WHILE_LOOP
|
WHILE label=L origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BREAK label=L loop.label=L
|
body: BREAK label=L loop.label=L
|
||||||
BREAK label=L loop.label=L
|
BREAK label=L loop.label=L
|
||||||
WHILE label=L origin=WHILE_LOOP
|
WHILE label=L origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
WHILE label=L origin=WHILE_LOOP
|
WHILE label=L origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: CONTINUE label=L loop.label=L
|
body: CONTINUE label=L loop.label=L
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
|
|||||||
WHILE label=L origin=WHILE_LOOP
|
WHILE label=L origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=kotlin.Unit origin=null
|
body: BLOCK type=kotlin.Unit origin=null
|
||||||
VAR name:<range> type:IrErrorType [val]
|
VAR name:<range> type:kotlin.Nothing [val]
|
||||||
BLOCK type=IrErrorType origin=ELVIS
|
BLOCK type=kotlin.Nothing origin=ELVIS
|
||||||
VAR name:<elvis> type:kotlin.collections.List<kotlin.String>? [val]
|
VAR name:<elvis> type:kotlin.collections.List<kotlin.String>? [val]
|
||||||
GET_VAR 'ss: kotlin.collections.List<kotlin.String>? declared in <root>.test3' type=kotlin.collections.List<kotlin.String>? origin=null
|
GET_VAR 'ss: kotlin.collections.List<kotlin.String>? declared in <root>.test3' type=kotlin.collections.List<kotlin.String>? origin=null
|
||||||
WHEN type=IrErrorType origin=ELVIS
|
WHEN type=kotlin.Nothing origin=ELVIS
|
||||||
BRANCH
|
BRANCH
|
||||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||||
arg0: GET_VAR 'val <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test3' type=kotlin.collections.List<kotlin.String>? origin=null
|
arg0: GET_VAR 'val <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test3' type=kotlin.collections.List<kotlin.String>? origin=null
|
||||||
@@ -71,11 +71,11 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
|
|||||||
WHILE label=L origin=WHILE_LOOP
|
WHILE label=L origin=WHILE_LOOP
|
||||||
condition: CONST Boolean type=kotlin.Boolean value=true
|
condition: CONST Boolean type=kotlin.Boolean value=true
|
||||||
body: BLOCK type=kotlin.Unit origin=null
|
body: BLOCK type=kotlin.Unit origin=null
|
||||||
VAR name:<range> type:IrErrorType [val]
|
VAR name:<range> type:kotlin.Nothing [val]
|
||||||
BLOCK type=IrErrorType origin=ELVIS
|
BLOCK type=kotlin.Nothing origin=ELVIS
|
||||||
VAR name:<elvis> type:kotlin.collections.List<kotlin.String>? [val]
|
VAR name:<elvis> type:kotlin.collections.List<kotlin.String>? [val]
|
||||||
GET_VAR 'ss: kotlin.collections.List<kotlin.String>? declared in <root>.test4' type=kotlin.collections.List<kotlin.String>? origin=null
|
GET_VAR 'ss: kotlin.collections.List<kotlin.String>? declared in <root>.test4' type=kotlin.collections.List<kotlin.String>? origin=null
|
||||||
WHEN type=IrErrorType origin=ELVIS
|
WHEN type=kotlin.Nothing origin=ELVIS
|
||||||
BRANCH
|
BRANCH
|
||||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||||
arg0: GET_VAR 'val <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test4' type=kotlin.collections.List<kotlin.String>? origin=null
|
arg0: GET_VAR 'val <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test4' type=kotlin.collections.List<kotlin.String>? origin=null
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
|||||||
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
||||||
WHILE label=null origin=FOR_LOOP_INNER_WHILE
|
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
|
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
VAR name:s type:T of <uninitialized parent> [val]
|
VAR name:s type:T of <uninitialized parent> [val]
|
||||||
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
||||||
BREAK label=null loop.label=null
|
BREAK label=null loop.label=null
|
||||||
@@ -21,7 +21,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
|||||||
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
||||||
WHILE label=OUTER origin=FOR_LOOP_INNER_WHILE
|
WHILE label=OUTER origin=FOR_LOOP_INNER_WHILE
|
||||||
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
VAR name:s1 type:T of <uninitialized parent> [val]
|
VAR name:s1 type:T of <uninitialized parent> [val]
|
||||||
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
||||||
VAR name:<range> type:kotlin.collections.List<kotlin.String> [val]
|
VAR name:<range> type:kotlin.collections.List<kotlin.String> [val]
|
||||||
@@ -30,7 +30,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
|||||||
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
||||||
WHILE label=INNER origin=FOR_LOOP_INNER_WHILE
|
WHILE label=INNER origin=FOR_LOOP_INNER_WHILE
|
||||||
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
VAR name:s2 type:T of <uninitialized parent> [val]
|
VAR name:s2 type:T of <uninitialized parent> [val]
|
||||||
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
||||||
BREAK label=OUTER loop.label=OUTER
|
BREAK label=OUTER loop.label=OUTER
|
||||||
@@ -46,7 +46,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
|||||||
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
||||||
WHILE label=null origin=FOR_LOOP_INNER_WHILE
|
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
|
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
VAR name:s type:T of <uninitialized parent> [val]
|
VAR name:s type:T of <uninitialized parent> [val]
|
||||||
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
||||||
CONTINUE label=null loop.label=null
|
CONTINUE label=null loop.label=null
|
||||||
@@ -59,7 +59,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
|||||||
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
||||||
WHILE label=OUTER origin=FOR_LOOP_INNER_WHILE
|
WHILE label=OUTER origin=FOR_LOOP_INNER_WHILE
|
||||||
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
VAR name:s1 type:T of <uninitialized parent> [val]
|
VAR name:s1 type:T of <uninitialized parent> [val]
|
||||||
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
||||||
VAR name:<range> type:kotlin.collections.List<kotlin.String> [val]
|
VAR name:<range> type:kotlin.collections.List<kotlin.String> [val]
|
||||||
@@ -68,7 +68,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
|||||||
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<E of <uninitialized parent>> declared in kotlin.collections.List' type=kotlin.collections.Iterator<E of <uninitialized parent>> origin=null
|
||||||
WHILE label=INNER origin=FOR_LOOP_INNER_WHILE
|
WHILE label=INNER origin=FOR_LOOP_INNER_WHILE
|
||||||
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
|
||||||
body: BLOCK type=IrErrorType origin=null
|
body: BLOCK type=kotlin.Nothing origin=null
|
||||||
VAR name:s2 type:T of <uninitialized parent> [val]
|
VAR name:s2 type:T of <uninitialized parent> [val]
|
||||||
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
CALL 'public abstract fun next (): T of <uninitialized parent> declared in kotlin.collections.Iterator' type=T of <uninitialized parent> origin=null
|
||||||
CONTINUE label=OUTER loop.label=OUTER
|
CONTINUE label=OUTER loop.label=OUTER
|
||||||
|
|||||||
Reference in New Issue
Block a user