Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache propagating variance flags in the relationship cache (#32225)
* Cache propagating variance flags in the relationship cache * Convert base fields in relation comparison result to flags
- Loading branch information
Showing
6 changed files
with
206 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/varianceRepeatedlyPropegatesWithUnreliableFlag.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//// [varianceRepeatedlyPropegatesWithUnreliableFlag.ts] | ||
type A = { a: number }; | ||
type B = { b: number }; | ||
type X<T> = ({ [K in keyof T]: T[K] } & Record<string, void>)[keyof T]; | ||
type P1<T> = { data: X<T> }; | ||
type P2<T> = { data: X<T> }; | ||
|
||
interface I<T> { | ||
fn<K extends keyof T>(p1: P1<Pick<T, K>>, p2: P2<Pick<T, K>>): void; | ||
} | ||
|
||
const i: I<A & B> = null as any; | ||
const p2: P2<A> = null as any; | ||
|
||
// Commenting out the below line will remove the error on the `const _i: I<A> = i;` | ||
i.fn(null as any, p2); | ||
|
||
const _i: I<A> = i; | ||
|
||
//// [varianceRepeatedlyPropegatesWithUnreliableFlag.js] | ||
var i = null; | ||
var p2 = null; | ||
// Commenting out the below line will remove the error on the `const _i: I<A> = i;` | ||
i.fn(null, p2); | ||
var _i = i; |
77 changes: 77 additions & 0 deletions
77
tests/baselines/reference/varianceRepeatedlyPropegatesWithUnreliableFlag.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
=== tests/cases/compiler/varianceRepeatedlyPropegatesWithUnreliableFlag.ts === | ||
type A = { a: number }; | ||
>A : Symbol(A, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 0, 0)) | ||
>a : Symbol(a, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 0, 10)) | ||
|
||
type B = { b: number }; | ||
>B : Symbol(B, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 0, 23)) | ||
>b : Symbol(b, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 1, 10)) | ||
|
||
type X<T> = ({ [K in keyof T]: T[K] } & Record<string, void>)[keyof T]; | ||
>X : Symbol(X, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 1, 23)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 7)) | ||
>K : Symbol(K, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 16)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 7)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 7)) | ||
>K : Symbol(K, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 16)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 7)) | ||
|
||
type P1<T> = { data: X<T> }; | ||
>P1 : Symbol(P1, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 71)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 3, 8)) | ||
>data : Symbol(data, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 3, 14)) | ||
>X : Symbol(X, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 1, 23)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 3, 8)) | ||
|
||
type P2<T> = { data: X<T> }; | ||
>P2 : Symbol(P2, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 3, 28)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 4, 8)) | ||
>data : Symbol(data, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 4, 14)) | ||
>X : Symbol(X, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 1, 23)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 4, 8)) | ||
|
||
interface I<T> { | ||
>I : Symbol(I, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 4, 28)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 6, 12)) | ||
|
||
fn<K extends keyof T>(p1: P1<Pick<T, K>>, p2: P2<Pick<T, K>>): void; | ||
>fn : Symbol(I.fn, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 6, 16)) | ||
>K : Symbol(K, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 7, 7)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 6, 12)) | ||
>p1 : Symbol(p1, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 7, 26)) | ||
>P1 : Symbol(P1, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 2, 71)) | ||
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 6, 12)) | ||
>K : Symbol(K, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 7, 7)) | ||
>p2 : Symbol(p2, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 7, 45)) | ||
>P2 : Symbol(P2, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 3, 28)) | ||
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 6, 12)) | ||
>K : Symbol(K, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 7, 7)) | ||
} | ||
|
||
const i: I<A & B> = null as any; | ||
>i : Symbol(i, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 10, 5)) | ||
>I : Symbol(I, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 4, 28)) | ||
>A : Symbol(A, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 0, 0)) | ||
>B : Symbol(B, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 0, 23)) | ||
|
||
const p2: P2<A> = null as any; | ||
>p2 : Symbol(p2, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 11, 5)) | ||
>P2 : Symbol(P2, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 3, 28)) | ||
>A : Symbol(A, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 0, 0)) | ||
|
||
// Commenting out the below line will remove the error on the `const _i: I<A> = i;` | ||
i.fn(null as any, p2); | ||
>i.fn : Symbol(I.fn, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 6, 16)) | ||
>i : Symbol(i, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 10, 5)) | ||
>fn : Symbol(I.fn, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 6, 16)) | ||
>p2 : Symbol(p2, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 11, 5)) | ||
|
||
const _i: I<A> = i; | ||
>_i : Symbol(_i, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 16, 5)) | ||
>I : Symbol(I, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 4, 28)) | ||
>A : Symbol(A, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 0, 0)) | ||
>i : Symbol(i, Decl(varianceRepeatedlyPropegatesWithUnreliableFlag.ts, 10, 5)) | ||
|
51 changes: 51 additions & 0 deletions
51
tests/baselines/reference/varianceRepeatedlyPropegatesWithUnreliableFlag.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
=== tests/cases/compiler/varianceRepeatedlyPropegatesWithUnreliableFlag.ts === | ||
type A = { a: number }; | ||
>A : A | ||
>a : number | ||
|
||
type B = { b: number }; | ||
>B : B | ||
>b : number | ||
|
||
type X<T> = ({ [K in keyof T]: T[K] } & Record<string, void>)[keyof T]; | ||
>X : ({ [K in keyof T]: T[K]; } & Record<string, void>)[keyof T] | ||
|
||
type P1<T> = { data: X<T> }; | ||
>P1 : P1<T> | ||
>data : ({ [K in keyof T]: T[K]; } & Record<string, void>)[keyof T] | ||
|
||
type P2<T> = { data: X<T> }; | ||
>P2 : P2<T> | ||
>data : ({ [K in keyof T]: T[K]; } & Record<string, void>)[keyof T] | ||
|
||
interface I<T> { | ||
fn<K extends keyof T>(p1: P1<Pick<T, K>>, p2: P2<Pick<T, K>>): void; | ||
>fn : <K extends keyof T>(p1: P1<Pick<T, K>>, p2: P2<Pick<T, K>>) => void | ||
>p1 : P1<Pick<T, K>> | ||
>p2 : P2<Pick<T, K>> | ||
} | ||
|
||
const i: I<A & B> = null as any; | ||
>i : I<A & B> | ||
>null as any : any | ||
>null : null | ||
|
||
const p2: P2<A> = null as any; | ||
>p2 : P2<A> | ||
>null as any : any | ||
>null : null | ||
|
||
// Commenting out the below line will remove the error on the `const _i: I<A> = i;` | ||
i.fn(null as any, p2); | ||
>i.fn(null as any, p2) : void | ||
>i.fn : <K extends "a" | "b">(p1: P1<Pick<A & B, K>>, p2: P2<Pick<A & B, K>>) => void | ||
>i : I<A & B> | ||
>fn : <K extends "a" | "b">(p1: P1<Pick<A & B, K>>, p2: P2<Pick<A & B, K>>) => void | ||
>null as any : any | ||
>null : null | ||
>p2 : P2<A> | ||
|
||
const _i: I<A> = i; | ||
>_i : I<A> | ||
>i : I<A & B> | ||
|
17 changes: 17 additions & 0 deletions
17
tests/cases/compiler/varianceRepeatedlyPropegatesWithUnreliableFlag.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
type A = { a: number }; | ||
type B = { b: number }; | ||
type X<T> = ({ [K in keyof T]: T[K] } & Record<string, void>)[keyof T]; | ||
type P1<T> = { data: X<T> }; | ||
type P2<T> = { data: X<T> }; | ||
|
||
interface I<T> { | ||
fn<K extends keyof T>(p1: P1<Pick<T, K>>, p2: P2<Pick<T, K>>): void; | ||
} | ||
|
||
const i: I<A & B> = null as any; | ||
const p2: P2<A> = null as any; | ||
|
||
// Commenting out the below line will remove the error on the `const _i: I<A> = i;` | ||
i.fn(null as any, p2); | ||
|
||
const _i: I<A> = i; |