1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
=== tests/cases/conformance/types/thisType/typeRelationships.ts ===
class C {
>C : Symbol(C, Decl(typeRelationships.ts, 0, 0))
self = this;
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
c = new C();
>c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>C : Symbol(C, Decl(typeRelationships.ts, 0, 0))
foo() {
>foo : Symbol(C.foo, Decl(typeRelationships.ts, 2, 16))
return this;
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
}
f1() {
>f1 : Symbol(C.f1, Decl(typeRelationships.ts, 5, 5))
this.c = this.self;
>this.c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
this.self = this.c; // Error
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this.c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
}
f2() {
>f2 : Symbol(C.f2, Decl(typeRelationships.ts, 9, 5))
var a: C[];
>a : Symbol(a, Decl(typeRelationships.ts, 11, 11), Decl(typeRelationships.ts, 12, 11))
>C : Symbol(C, Decl(typeRelationships.ts, 0, 0))
var a = [this, this.c]; // C[] since this is subtype of C
>a : Symbol(a, Decl(typeRelationships.ts, 11, 11), Decl(typeRelationships.ts, 12, 11))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>this.c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
var b: this[];
>b : Symbol(b, Decl(typeRelationships.ts, 13, 11), Decl(typeRelationships.ts, 14, 11))
var b = [this, this.self, null, undefined];
>b : Symbol(b, Decl(typeRelationships.ts, 13, 11), Decl(typeRelationships.ts, 14, 11))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>undefined : Symbol(undefined)
}
f3(b: boolean) {
>f3 : Symbol(C.f3, Decl(typeRelationships.ts, 15, 5))
>b : Symbol(b, Decl(typeRelationships.ts, 16, 7))
return b ? this.c : this.self; // Should be C
>b : Symbol(b, Decl(typeRelationships.ts, 16, 7))
>this.c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(C, Decl(typeRelationships.ts, 0, 0))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
}
}
class D extends C {
>D : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>C : Symbol(C, Decl(typeRelationships.ts, 0, 0))
self1 = this;
>self1 : Symbol(D.self1, Decl(typeRelationships.ts, 21, 19))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
self2 = this.self;
>self2 : Symbol(D.self2, Decl(typeRelationships.ts, 22, 17))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
self3 = this.foo();
>self3 : Symbol(D.self3, Decl(typeRelationships.ts, 23, 22))
>this.foo : Symbol(C.foo, Decl(typeRelationships.ts, 2, 16))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>foo : Symbol(C.foo, Decl(typeRelationships.ts, 2, 16))
d = new D();
>d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
>D : Symbol(D, Decl(typeRelationships.ts, 19, 1))
bar() {
>bar : Symbol(D.bar, Decl(typeRelationships.ts, 25, 16))
this.self = this.self1;
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this.self1 : Symbol(D.self1, Decl(typeRelationships.ts, 21, 19))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self1 : Symbol(D.self1, Decl(typeRelationships.ts, 21, 19))
this.self = this.self2;
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this.self2 : Symbol(D.self2, Decl(typeRelationships.ts, 22, 17))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self2 : Symbol(D.self2, Decl(typeRelationships.ts, 22, 17))
this.self = this.self3;
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this.self3 : Symbol(D.self3, Decl(typeRelationships.ts, 23, 22))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self3 : Symbol(D.self3, Decl(typeRelationships.ts, 23, 22))
this.self1 = this.self;
>this.self1 : Symbol(D.self1, Decl(typeRelationships.ts, 21, 19))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self1 : Symbol(D.self1, Decl(typeRelationships.ts, 21, 19))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
this.self2 = this.self;
>this.self2 : Symbol(D.self2, Decl(typeRelationships.ts, 22, 17))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self2 : Symbol(D.self2, Decl(typeRelationships.ts, 22, 17))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
this.self3 = this.self;
>this.self3 : Symbol(D.self3, Decl(typeRelationships.ts, 23, 22))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self3 : Symbol(D.self3, Decl(typeRelationships.ts, 23, 22))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
this.d = this.self;
>this.d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
this.d = this.c; // Error
>this.d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
>this.c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
this.self = this.d; // Error
>this.self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>self : Symbol(C.self, Decl(typeRelationships.ts, 0, 9))
>this.d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
this.c = this.d;
>this.c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>c : Symbol(C.c, Decl(typeRelationships.ts, 1, 16))
>this.d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
>this : Symbol(D, Decl(typeRelationships.ts, 19, 1))
>d : Symbol(D.d, Decl(typeRelationships.ts, 24, 23))
}
}
|