|
| 1 | +=== tests/cases/compiler/classUsedBeforeInitializedVariables.ts === |
| 2 | +class Test { |
| 3 | +>Test : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 4 | + |
| 5 | + p1 = 0; |
| 6 | +>p1 : Symbol(Test.p1, Decl(classUsedBeforeInitializedVariables.ts, 0, 12)) |
| 7 | + |
| 8 | + p2 = this.p1; |
| 9 | +>p2 : Symbol(Test.p2, Decl(classUsedBeforeInitializedVariables.ts, 1, 11)) |
| 10 | +>this.p1 : Symbol(Test.p1, Decl(classUsedBeforeInitializedVariables.ts, 0, 12)) |
| 11 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 12 | +>p1 : Symbol(Test.p1, Decl(classUsedBeforeInitializedVariables.ts, 0, 12)) |
| 13 | + |
| 14 | + p3 = this.p4; |
| 15 | +>p3 : Symbol(Test.p3, Decl(classUsedBeforeInitializedVariables.ts, 2, 17)) |
| 16 | +>this.p4 : Symbol(Test.p4, Decl(classUsedBeforeInitializedVariables.ts, 3, 17)) |
| 17 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 18 | +>p4 : Symbol(Test.p4, Decl(classUsedBeforeInitializedVariables.ts, 3, 17)) |
| 19 | + |
| 20 | + p4 = 0; |
| 21 | +>p4 : Symbol(Test.p4, Decl(classUsedBeforeInitializedVariables.ts, 3, 17)) |
| 22 | + |
| 23 | + directlyAssigned: any = this.directlyAssigned; |
| 24 | +>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) |
| 25 | +>this.directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) |
| 26 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 27 | +>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11)) |
| 28 | + |
| 29 | + withinArrowFunction: any = () => this.withinArrowFunction; |
| 30 | +>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50)) |
| 31 | +>this.withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50)) |
| 32 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 33 | +>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50)) |
| 34 | + |
| 35 | + withinFunction: any = function () { |
| 36 | +>withinFunction : Symbol(Test.withinFunction, Decl(classUsedBeforeInitializedVariables.ts, 8, 62)) |
| 37 | + |
| 38 | + return this.withinFunction; |
| 39 | + }; |
| 40 | + |
| 41 | + withinObjectLiteral: any = { |
| 42 | +>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6)) |
| 43 | + |
| 44 | + [this.withinObjectLiteral]: true, |
| 45 | +>[this.withinObjectLiteral] : Symbol([this.withinObjectLiteral], Decl(classUsedBeforeInitializedVariables.ts, 14, 32)) |
| 46 | +>this.withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6)) |
| 47 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 48 | +>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6)) |
| 49 | + |
| 50 | + }; |
| 51 | + |
| 52 | + withinObjectLiteralGetterName: any = { |
| 53 | +>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6)) |
| 54 | + |
| 55 | + get [this.withinObjectLiteralGetterName]() { |
| 56 | +>[this.withinObjectLiteralGetterName] : Symbol([this.withinObjectLiteralGetterName], Decl(classUsedBeforeInitializedVariables.ts, 18, 42)) |
| 57 | +>this.withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6)) |
| 58 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 59 | +>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6)) |
| 60 | + |
| 61 | + return true; |
| 62 | + } |
| 63 | + }; |
| 64 | + |
| 65 | + withinObjectLiteralSetterName: any = { |
| 66 | +>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) |
| 67 | + |
| 68 | + set [this.withinObjectLiteralSetterName](_: any) {} |
| 69 | +>[this.withinObjectLiteralSetterName] : Symbol([this.withinObjectLiteralSetterName], Decl(classUsedBeforeInitializedVariables.ts, 24, 42)) |
| 70 | +>this.withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) |
| 71 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 72 | +>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6)) |
| 73 | +>_ : Symbol(_, Decl(classUsedBeforeInitializedVariables.ts, 25, 49)) |
| 74 | + |
| 75 | + }; |
| 76 | + |
| 77 | + withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { }); |
| 78 | +>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6)) |
| 79 | +>this.withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6)) |
| 80 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 81 | +>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6)) |
| 82 | + |
| 83 | + // These error cases are ignored (not checked by control flow analysis) |
| 84 | + |
| 85 | + assignedByArrowFunction: any = (() => this.assignedByFunction)(); |
| 86 | +>assignedByArrowFunction : Symbol(Test.assignedByArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 28, 100)) |
| 87 | +>this.assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69)) |
| 88 | +>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0)) |
| 89 | +>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69)) |
| 90 | + |
| 91 | + assignedByFunction: any = (function () { |
| 92 | +>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69)) |
| 93 | + |
| 94 | + return this.assignedByFunction; |
| 95 | + })(); |
| 96 | +} |
| 97 | + |
0 commit comments