Kotlin 2: Accept a test change

With:

    open class Root {}
    class Subclass1: Root() {}

    fun typeTests(x: Root, y: Subclass1) {
        val y1: Subclass1 = if (x is Subclass1) { x } else { y }
    }

we now get a slightly different AST, which means we no longer need to
insert a StmtExpr:

     BRANCH
       if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.Subclass1
         GET_VAR 'x: <root>.Root declared in <root>.typeTests' type=<root>.Root origin=null
-      then: TYPE_OP type=<root>.Subclass1 origin=IMPLICIT_CAST typeOperand=<root>.Subclass1
-        BLOCK type=<root>.Root origin=null
+      then: BLOCK type=<root>.Subclass1 origin=null
+        TYPE_OP type=<root>.Subclass1 origin=IMPLICIT_CAST typeOperand=<root>.Subclass1
           GET_VAR 'x: <root>.Root declared in <root>.typeTests' type=<root>.Root origin=null
This commit is contained in:
Ian Lynagh
2024-03-28 15:07:30 +00:00
parent 3d8ac1441a
commit 24c4c3e068

View File

@@ -1423,7 +1423,6 @@
| exprs.kt:160:29:160:29 | x | exprs.kt:156:1:163:1 | typeTests | VarAccess |
| exprs.kt:160:29:160:42 | ...instanceof... | exprs.kt:156:1:163:1 | typeTests | InstanceOfExpr |
| exprs.kt:160:29:160:42 | Subclass1 | exprs.kt:156:1:163:1 | typeTests | TypeAccess |
| exprs.kt:160:45:160:49 | <Stmt> | exprs.kt:156:1:163:1 | typeTests | StmtExpr |
| exprs.kt:160:47:160:47 | <implicit cast> | exprs.kt:156:1:163:1 | typeTests | ImplicitCastExpr |
| exprs.kt:160:47:160:47 | Subclass1 | exprs.kt:156:1:163:1 | typeTests | TypeAccess |
| exprs.kt:160:47:160:47 | x | exprs.kt:156:1:163:1 | typeTests | VarAccess |