Skip to content

Commit 31e8f02

Browse files
committed
Merge branch 'flapenguin-fix-generic-types-intersections'
2 parents 94ca501 + 045a450 commit 31e8f02

14 files changed

+319
-17
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7741,7 +7741,13 @@ namespace ts {
77417741
result.containingType = containingType;
77427742
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
77437743
result.valueDeclaration = firstValueDeclaration;
7744+
7745+
// Inherit information about parent type.
7746+
if (firstValueDeclaration.symbol.parent) {
7747+
result.parent = firstValueDeclaration.symbol.parent;
7748+
}
77447749
}
7750+
77457751
result.declarations = declarations!;
77467752
result.nameType = nameType;
77477753
result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);

tests/baselines/reference/arraySlice.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var arr: string[] | number[];
33
>arr : Symbol(arr, Decl(arraySlice.ts, 0, 3))
44

55
arr.splice(1, 1);
6-
>arr.splice : Symbol(splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
6+
>arr.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
77
>arr : Symbol(arr, Decl(arraySlice.ts, 0, 3))
8-
>splice : Symbol(splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
8+
>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
99

tests/baselines/reference/bivariantInferences.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ declare const b: (string | number)[] | null[] | undefined[] | {}[];
2424

2525
let x = a.equalsShallow(b);
2626
>x : Symbol(x, Decl(bivariantInferences.ts, 9, 3))
27-
>a.equalsShallow : Symbol(equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20))
27+
>a.equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20))
2828
>a : Symbol(a, Decl(bivariantInferences.ts, 6, 13))
29-
>equalsShallow : Symbol(equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20))
29+
>equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20))
3030
>b : Symbol(b, Decl(bivariantInferences.ts, 7, 13))
3131

tests/baselines/reference/callsOnComplexSignatures.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ function test3(items: string[] | number[]) {
9494
>items : Symbol(items, Decl(callsOnComplexSignatures.tsx, 36, 15))
9595

9696
items.forEach(item => console.log(item));
97-
>items.forEach : Symbol(forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
97+
>items.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
9898
>items : Symbol(items, Decl(callsOnComplexSignatures.tsx, 36, 15))
99-
>forEach : Symbol(forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
99+
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
100100
>item : Symbol(item, Decl(callsOnComplexSignatures.tsx, 37, 18))
101101
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
102102
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))

tests/baselines/reference/controlFlowArrayErrors.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ function f6() {
121121
>x : Symbol(x, Decl(controlFlowArrayErrors.ts, 37, 7))
122122

123123
x.push(99); // Error
124-
>x.push : Symbol(push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
124+
>x.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
125125
>x : Symbol(x, Decl(controlFlowArrayErrors.ts, 37, 7))
126-
>push : Symbol(push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
126+
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
127127
}
128128

129129
function f7() {

tests/baselines/reference/mixinAccessModifiers.errors.txt

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ tests/cases/conformance/classes/mixinAccessModifiers.ts(84,6): error TS2445: Pro
1515
tests/cases/conformance/classes/mixinAccessModifiers.ts(89,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
1616
tests/cases/conformance/classes/mixinAccessModifiers.ts(97,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses.
1717
tests/cases/conformance/classes/mixinAccessModifiers.ts(102,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
18+
tests/cases/conformance/classes/mixinAccessModifiers.ts(119,4): error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
19+
tests/cases/conformance/classes/mixinAccessModifiers.ts(120,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
20+
tests/cases/conformance/classes/mixinAccessModifiers.ts(124,4): error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>'.
21+
tests/cases/conformance/classes/mixinAccessModifiers.ts(125,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' and its subclasses.
22+
tests/cases/conformance/classes/mixinAccessModifiers.ts(129,4): error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>'.
23+
tests/cases/conformance/classes/mixinAccessModifiers.ts(130,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
1824

1925

20-
==== tests/cases/conformance/classes/mixinAccessModifiers.ts (11 errors) ====
26+
==== tests/cases/conformance/classes/mixinAccessModifiers.ts (17 errors) ====
2127
type Constructable = new (...args: any[]) => object;
2228

2329
class Private {
@@ -152,4 +158,41 @@ tests/cases/conformance/classes/mixinAccessModifiers.ts(102,6): error TS2445: Pr
152158
C6.s
153159
}
154160
}
161+
162+
class ProtectedGeneric<T> {
163+
private privateMethod() {}
164+
protected protectedMethod() {}
165+
}
166+
167+
class ProtectedGeneric2<T> {
168+
private privateMethod() {}
169+
protected protectedMethod() {}
170+
}
171+
172+
function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) {
173+
x.privateMethod(); // Error, private constituent makes method inaccessible
174+
~~~~~~~~~~~~~
175+
!!! error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
176+
x.protectedMethod(); // Error, protected when all constituents are protected
177+
~~~~~~~~~~~~~~~
178+
!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
179+
}
180+
181+
function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) {
182+
x.privateMethod(); // Error, private constituent makes method inaccessible
183+
~~~~~~~~~~~~~
184+
!!! error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>'.
185+
x.protectedMethod(); // Error, protected when all constituents are protected
186+
~~~~~~~~~~~~~~~
187+
!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' and its subclasses.
188+
}
189+
190+
function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
191+
x.privateMethod(); // Error, private constituent makes method inaccessible
192+
~~~~~~~~~~~~~
193+
!!! error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>'.
194+
x.protectedMethod(); // Error, protected when all constituents are protected
195+
~~~~~~~~~~~~~~~
196+
!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
197+
}
155198

tests/baselines/reference/mixinAccessModifiers.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,31 @@ class C6 extends Mix(Public, Public2) {
105105
C6.s
106106
}
107107
}
108+
109+
class ProtectedGeneric<T> {
110+
private privateMethod() {}
111+
protected protectedMethod() {}
112+
}
113+
114+
class ProtectedGeneric2<T> {
115+
private privateMethod() {}
116+
protected protectedMethod() {}
117+
}
118+
119+
function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) {
120+
x.privateMethod(); // Error, private constituent makes method inaccessible
121+
x.protectedMethod(); // Error, protected when all constituents are protected
122+
}
123+
124+
function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) {
125+
x.privateMethod(); // Error, private constituent makes method inaccessible
126+
x.protectedMethod(); // Error, protected when all constituents are protected
127+
}
128+
129+
function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
130+
x.privateMethod(); // Error, private constituent makes method inaccessible
131+
x.protectedMethod(); // Error, protected when all constituents are protected
132+
}
108133

109134

110135
//// [mixinAccessModifiers.js]
@@ -266,6 +291,32 @@ var C6 = /** @class */ (function (_super) {
266291
};
267292
return C6;
268293
}(Mix(Public, Public2)));
294+
var ProtectedGeneric = /** @class */ (function () {
295+
function ProtectedGeneric() {
296+
}
297+
ProtectedGeneric.prototype.privateMethod = function () { };
298+
ProtectedGeneric.prototype.protectedMethod = function () { };
299+
return ProtectedGeneric;
300+
}());
301+
var ProtectedGeneric2 = /** @class */ (function () {
302+
function ProtectedGeneric2() {
303+
}
304+
ProtectedGeneric2.prototype.privateMethod = function () { };
305+
ProtectedGeneric2.prototype.protectedMethod = function () { };
306+
return ProtectedGeneric2;
307+
}());
308+
function f7(x) {
309+
x.privateMethod(); // Error, private constituent makes method inaccessible
310+
x.protectedMethod(); // Error, protected when all constituents are protected
311+
}
312+
function f8(x) {
313+
x.privateMethod(); // Error, private constituent makes method inaccessible
314+
x.protectedMethod(); // Error, protected when all constituents are protected
315+
}
316+
function f9(x) {
317+
x.privateMethod(); // Error, private constituent makes method inaccessible
318+
x.protectedMethod(); // Error, protected when all constituents are protected
319+
}
269320

270321

271322
//// [mixinAccessModifiers.d.ts]
@@ -329,3 +380,24 @@ declare class C6 extends C6_base {
329380
f(c4: C4, c5: C5, c6: C6): void;
330381
static g(): void;
331382
}
383+
declare class ProtectedGeneric<T> {
384+
private privateMethod;
385+
protected protectedMethod(): void;
386+
}
387+
declare class ProtectedGeneric2<T> {
388+
private privateMethod;
389+
protected protectedMethod(): void;
390+
}
391+
declare function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>): void;
392+
declare function f8(x: ProtectedGeneric<{
393+
a: void;
394+
}> & ProtectedGeneric2<{
395+
a: void;
396+
b: void;
397+
}>): void;
398+
declare function f9(x: ProtectedGeneric<{
399+
a: void;
400+
}> & ProtectedGeneric<{
401+
a: void;
402+
b: void;
403+
}>): void;

tests/baselines/reference/mixinAccessModifiers.symbols

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,82 @@ class C6 extends Mix(Public, Public2) {
328328
}
329329
}
330330

331+
class ProtectedGeneric<T> {
332+
>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1))
333+
>T : Symbol(T, Decl(mixinAccessModifiers.ts, 107, 23))
334+
335+
private privateMethod() {}
336+
>privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27))
337+
338+
protected protectedMethod() {}
339+
>protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27))
340+
}
341+
342+
class ProtectedGeneric2<T> {
343+
>ProtectedGeneric2 : Symbol(ProtectedGeneric2, Decl(mixinAccessModifiers.ts, 110, 1))
344+
>T : Symbol(T, Decl(mixinAccessModifiers.ts, 112, 24))
345+
346+
private privateMethod() {}
347+
>privateMethod : Symbol(ProtectedGeneric2.privateMethod, Decl(mixinAccessModifiers.ts, 112, 28))
348+
349+
protected protectedMethod() {}
350+
>protectedMethod : Symbol(ProtectedGeneric2.protectedMethod, Decl(mixinAccessModifiers.ts, 113, 27))
351+
}
352+
353+
function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) {
354+
>f7 : Symbol(f7, Decl(mixinAccessModifiers.ts, 115, 1))
355+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 117, 12))
356+
>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1))
357+
>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1))
358+
359+
x.privateMethod(); // Error, private constituent makes method inaccessible
360+
>x.privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27))
361+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 117, 12))
362+
>privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27))
363+
364+
x.protectedMethod(); // Error, protected when all constituents are protected
365+
>x.protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27))
366+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 117, 12))
367+
>protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27))
368+
}
369+
370+
function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) {
371+
>f8 : Symbol(f8, Decl(mixinAccessModifiers.ts, 120, 1))
372+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12))
373+
>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1))
374+
>a : Symbol(a, Decl(mixinAccessModifiers.ts, 122, 33))
375+
>ProtectedGeneric2 : Symbol(ProtectedGeneric2, Decl(mixinAccessModifiers.ts, 110, 1))
376+
>a : Symbol(a, Decl(mixinAccessModifiers.ts, 122, 65))
377+
>b : Symbol(b, Decl(mixinAccessModifiers.ts, 122, 72))
378+
379+
x.privateMethod(); // Error, private constituent makes method inaccessible
380+
>x.privateMethod : Symbol(privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 112, 28))
381+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12))
382+
>privateMethod : Symbol(privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 112, 28))
383+
384+
x.protectedMethod(); // Error, protected when all constituents are protected
385+
>x.protectedMethod : Symbol(protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 113, 27))
386+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12))
387+
>protectedMethod : Symbol(protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 113, 27))
388+
}
389+
390+
function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
391+
>f9 : Symbol(f9, Decl(mixinAccessModifiers.ts, 125, 1))
392+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12))
393+
>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1))
394+
>a : Symbol(a, Decl(mixinAccessModifiers.ts, 127, 33))
395+
>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1))
396+
>a : Symbol(a, Decl(mixinAccessModifiers.ts, 127, 64))
397+
>b : Symbol(b, Decl(mixinAccessModifiers.ts, 127, 71))
398+
399+
x.privateMethod(); // Error, private constituent makes method inaccessible
400+
>x.privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 107, 27))
401+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12))
402+
>privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 107, 27))
403+
404+
x.protectedMethod(); // Error, protected when all constituents are protected
405+
>x.protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 108, 27))
406+
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12))
407+
>protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 108, 27))
408+
}
409+

tests/baselines/reference/mixinAccessModifiers.types

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,80 @@ class C6 extends Mix(Public, Public2) {
307307
}
308308
}
309309

310+
class ProtectedGeneric<T> {
311+
>ProtectedGeneric : ProtectedGeneric<T>
312+
313+
private privateMethod() {}
314+
>privateMethod : () => void
315+
316+
protected protectedMethod() {}
317+
>protectedMethod : () => void
318+
}
319+
320+
class ProtectedGeneric2<T> {
321+
>ProtectedGeneric2 : ProtectedGeneric2<T>
322+
323+
private privateMethod() {}
324+
>privateMethod : () => void
325+
326+
protected protectedMethod() {}
327+
>protectedMethod : () => void
328+
}
329+
330+
function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) {
331+
>f7 : (x: ProtectedGeneric<{}>) => void
332+
>x : ProtectedGeneric<{}>
333+
334+
x.privateMethod(); // Error, private constituent makes method inaccessible
335+
>x.privateMethod() : void
336+
>x.privateMethod : () => void
337+
>x : ProtectedGeneric<{}>
338+
>privateMethod : () => void
339+
340+
x.protectedMethod(); // Error, protected when all constituents are protected
341+
>x.protectedMethod() : void
342+
>x.protectedMethod : () => void
343+
>x : ProtectedGeneric<{}>
344+
>protectedMethod : () => void
345+
}
346+
347+
function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) {
348+
>f8 : (x: ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>) => void
349+
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>
350+
>a : void
351+
>a : void
352+
>b : void
353+
354+
x.privateMethod(); // Error, private constituent makes method inaccessible
355+
>x.privateMethod() : void
356+
>x.privateMethod : (() => void) & (() => void)
357+
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>
358+
>privateMethod : (() => void) & (() => void)
359+
360+
x.protectedMethod(); // Error, protected when all constituents are protected
361+
>x.protectedMethod() : void
362+
>x.protectedMethod : (() => void) & (() => void)
363+
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>
364+
>protectedMethod : (() => void) & (() => void)
365+
}
366+
367+
function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
368+
>f9 : (x: ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>) => void
369+
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>
370+
>a : void
371+
>a : void
372+
>b : void
373+
374+
x.privateMethod(); // Error, private constituent makes method inaccessible
375+
>x.privateMethod() : void
376+
>x.privateMethod : (() => void) & (() => void)
377+
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>
378+
>privateMethod : (() => void) & (() => void)
379+
380+
x.protectedMethod(); // Error, protected when all constituents are protected
381+
>x.protectedMethod() : void
382+
>x.protectedMethod : (() => void) & (() => void)
383+
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>
384+
>protectedMethod : (() => void) & (() => void)
385+
}
386+

tests/baselines/reference/typeParameterExtendingUnion1.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ function f<T extends Cat | Dog>(a: T) {
3333
>T : Symbol(T, Decl(typeParameterExtendingUnion1.ts, 8, 11))
3434

3535
a.run();
36-
>a.run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14))
36+
>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14))
3737
>a : Symbol(a, Decl(typeParameterExtendingUnion1.ts, 8, 32))
38-
>run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14))
38+
>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14))
3939

4040
run(a);
4141
>run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 2, 33))

0 commit comments

Comments
 (0)