|
| 1 | +//// [tests/cases/compiler/circularControlFlowNarrowingWithCurrentElement01.ts] //// |
| 2 | + |
| 3 | +=== circularControlFlowNarrowingWithCurrentElement01.ts === |
| 4 | +class A { |
| 5 | +>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0)) |
| 6 | + |
| 7 | + next: A | null = null; |
| 8 | +>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 9 | +>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0)) |
| 10 | + |
| 11 | + constructor(readonly children: (A | null)[]) {} |
| 12 | +>children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14)) |
| 13 | +>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0)) |
| 14 | +} |
| 15 | + |
| 16 | +function getNodes(): A[] { |
| 17 | +>getNodes : Symbol(getNodes, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 4, 1)) |
| 18 | +>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0)) |
| 19 | + |
| 20 | + const out: A[] = []; |
| 21 | +>out : Symbol(out, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 7, 7)) |
| 22 | +>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0)) |
| 23 | + |
| 24 | + let current: A | null = new A([]); |
| 25 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 26 | +>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0)) |
| 27 | +>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0)) |
| 28 | + |
| 29 | + while (current !== null) { |
| 30 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 31 | + |
| 32 | + let firstChild = null; |
| 33 | +>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7)) |
| 34 | + |
| 35 | + if (out.length) { |
| 36 | +>out.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) |
| 37 | +>out : Symbol(out, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 7, 7)) |
| 38 | +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) |
| 39 | + |
| 40 | + current = current.next; |
| 41 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 42 | +>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 43 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 44 | +>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 45 | + |
| 46 | + continue; |
| 47 | + } |
| 48 | + |
| 49 | + for (let i = 0; i < current.children.length; i++) { |
| 50 | +>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12)) |
| 51 | +>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12)) |
| 52 | +>current.children.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) |
| 53 | +>current.children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14)) |
| 54 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 55 | +>children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14)) |
| 56 | +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) |
| 57 | +>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12)) |
| 58 | + |
| 59 | + const child = current.children[i]; |
| 60 | +>child : Symbol(child, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 20, 11)) |
| 61 | +>current.children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14)) |
| 62 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 63 | +>children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14)) |
| 64 | +>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12)) |
| 65 | + |
| 66 | + if (child) { |
| 67 | +>child : Symbol(child, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 20, 11)) |
| 68 | + |
| 69 | + if (!firstChild) { |
| 70 | +>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7)) |
| 71 | + |
| 72 | + firstChild = child; |
| 73 | +>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7)) |
| 74 | +>child : Symbol(child, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 20, 11)) |
| 75 | + |
| 76 | + firstChild.next = current.next; |
| 77 | +>firstChild.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 78 | +>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7)) |
| 79 | +>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 80 | +>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 81 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 82 | +>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 83 | + } |
| 84 | + |
| 85 | + child.next = current.next; |
| 86 | +>child.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 87 | +>child : Symbol(child, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 20, 11)) |
| 88 | +>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 89 | +>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 90 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 91 | +>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + current = firstChild || current.next; |
| 96 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 97 | +>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7)) |
| 98 | +>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 99 | +>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5)) |
| 100 | +>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9)) |
| 101 | + } |
| 102 | + |
| 103 | + return out; |
| 104 | +>out : Symbol(out, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 7, 7)) |
| 105 | +} |
0 commit comments