-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32362 from microsoft/fix32230
Fix type parameter inference cache invalidation logic
- Loading branch information
Showing
5 changed files
with
199 additions
and
4 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
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/typeInferenceCacheInvalidation.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,37 @@ | ||
//// [typeInferenceCacheInvalidation.ts] | ||
// Repro from #32230 | ||
|
||
type Callback<TFoo, TBar> = (foo: TFoo, bar: TBar) => any | ||
|
||
declare function example<TFoo, TBar, TCallback extends Callback<TFoo, TBar>>( | ||
foo: TFoo, | ||
callback: TCallback, | ||
bar: TBar, | ||
): TCallback | ||
|
||
example(42, (foo, bar) => ({ | ||
t: () => { | ||
let s: string = bar; | ||
} | ||
}), '42'); | ||
|
||
example(42, (foo, bar) => ({ | ||
t() { | ||
let s: string = bar; | ||
} | ||
}), '42'); | ||
|
||
|
||
//// [typeInferenceCacheInvalidation.js] | ||
"use strict"; | ||
// Repro from #32230 | ||
example(42, function (foo, bar) { return ({ | ||
t: function () { | ||
var s = bar; | ||
} | ||
}); }, '42'); | ||
example(42, function (foo, bar) { return ({ | ||
t: function () { | ||
var s = bar; | ||
} | ||
}); }, '42'); |
64 changes: 64 additions & 0 deletions
64
tests/baselines/reference/typeInferenceCacheInvalidation.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,64 @@ | ||
=== tests/cases/compiler/typeInferenceCacheInvalidation.ts === | ||
// Repro from #32230 | ||
|
||
type Callback<TFoo, TBar> = (foo: TFoo, bar: TBar) => any | ||
>Callback : Symbol(Callback, Decl(typeInferenceCacheInvalidation.ts, 0, 0)) | ||
>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 2, 14)) | ||
>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 2, 19)) | ||
>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 2, 29)) | ||
>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 2, 14)) | ||
>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 2, 39)) | ||
>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 2, 19)) | ||
|
||
declare function example<TFoo, TBar, TCallback extends Callback<TFoo, TBar>>( | ||
>example : Symbol(example, Decl(typeInferenceCacheInvalidation.ts, 2, 57)) | ||
>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 4, 25)) | ||
>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 4, 30)) | ||
>TCallback : Symbol(TCallback, Decl(typeInferenceCacheInvalidation.ts, 4, 36)) | ||
>Callback : Symbol(Callback, Decl(typeInferenceCacheInvalidation.ts, 0, 0)) | ||
>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 4, 25)) | ||
>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 4, 30)) | ||
|
||
foo: TFoo, | ||
>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 4, 77)) | ||
>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 4, 25)) | ||
|
||
callback: TCallback, | ||
>callback : Symbol(callback, Decl(typeInferenceCacheInvalidation.ts, 5, 14)) | ||
>TCallback : Symbol(TCallback, Decl(typeInferenceCacheInvalidation.ts, 4, 36)) | ||
|
||
bar: TBar, | ||
>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 6, 24)) | ||
>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 4, 30)) | ||
|
||
): TCallback | ||
>TCallback : Symbol(TCallback, Decl(typeInferenceCacheInvalidation.ts, 4, 36)) | ||
|
||
example(42, (foo, bar) => ({ | ||
>example : Symbol(example, Decl(typeInferenceCacheInvalidation.ts, 2, 57)) | ||
>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 10, 13)) | ||
>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 10, 17)) | ||
|
||
t: () => { | ||
>t : Symbol(t, Decl(typeInferenceCacheInvalidation.ts, 10, 28)) | ||
|
||
let s: string = bar; | ||
>s : Symbol(s, Decl(typeInferenceCacheInvalidation.ts, 12, 11)) | ||
>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 10, 17)) | ||
} | ||
}), '42'); | ||
|
||
example(42, (foo, bar) => ({ | ||
>example : Symbol(example, Decl(typeInferenceCacheInvalidation.ts, 2, 57)) | ||
>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 16, 13)) | ||
>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 16, 17)) | ||
|
||
t() { | ||
>t : Symbol(t, Decl(typeInferenceCacheInvalidation.ts, 16, 28)) | ||
|
||
let s: string = bar; | ||
>s : Symbol(s, Decl(typeInferenceCacheInvalidation.ts, 18, 11)) | ||
>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 16, 17)) | ||
} | ||
}), '42'); | ||
|
63 changes: 63 additions & 0 deletions
63
tests/baselines/reference/typeInferenceCacheInvalidation.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,63 @@ | ||
=== tests/cases/compiler/typeInferenceCacheInvalidation.ts === | ||
// Repro from #32230 | ||
|
||
type Callback<TFoo, TBar> = (foo: TFoo, bar: TBar) => any | ||
>Callback : Callback<TFoo, TBar> | ||
>foo : TFoo | ||
>bar : TBar | ||
|
||
declare function example<TFoo, TBar, TCallback extends Callback<TFoo, TBar>>( | ||
>example : <TFoo, TBar, TCallback extends Callback<TFoo, TBar>>(foo: TFoo, callback: TCallback, bar: TBar) => TCallback | ||
|
||
foo: TFoo, | ||
>foo : TFoo | ||
|
||
callback: TCallback, | ||
>callback : TCallback | ||
|
||
bar: TBar, | ||
>bar : TBar | ||
|
||
): TCallback | ||
|
||
example(42, (foo, bar) => ({ | ||
>example(42, (foo, bar) => ({ t: () => { let s: string = bar; }}), '42') : (foo: number, bar: string) => { t: () => void; } | ||
>example : <TFoo, TBar, TCallback extends Callback<TFoo, TBar>>(foo: TFoo, callback: TCallback, bar: TBar) => TCallback | ||
>42 : 42 | ||
>(foo, bar) => ({ t: () => { let s: string = bar; }}) : (foo: number, bar: string) => { t: () => void; } | ||
>foo : number | ||
>bar : string | ||
>({ t: () => { let s: string = bar; }}) : { t: () => void; } | ||
>{ t: () => { let s: string = bar; }} : { t: () => void; } | ||
|
||
t: () => { | ||
>t : () => void | ||
>() => { let s: string = bar; } : () => void | ||
|
||
let s: string = bar; | ||
>s : string | ||
>bar : string | ||
} | ||
}), '42'); | ||
>'42' : "42" | ||
|
||
example(42, (foo, bar) => ({ | ||
>example(42, (foo, bar) => ({ t() { let s: string = bar; }}), '42') : (foo: number, bar: string) => { t(): void; } | ||
>example : <TFoo, TBar, TCallback extends Callback<TFoo, TBar>>(foo: TFoo, callback: TCallback, bar: TBar) => TCallback | ||
>42 : 42 | ||
>(foo, bar) => ({ t() { let s: string = bar; }}) : (foo: number, bar: string) => { t(): void; } | ||
>foo : number | ||
>bar : string | ||
>({ t() { let s: string = bar; }}) : { t(): void; } | ||
>{ t() { let s: string = bar; }} : { t(): void; } | ||
|
||
t() { | ||
>t : () => void | ||
|
||
let s: string = bar; | ||
>s : string | ||
>bar : string | ||
} | ||
}), '42'); | ||
>'42' : "42" | ||
|
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,23 @@ | ||
// @strict: true | ||
|
||
// Repro from #32230 | ||
|
||
type Callback<TFoo, TBar> = (foo: TFoo, bar: TBar) => any | ||
|
||
declare function example<TFoo, TBar, TCallback extends Callback<TFoo, TBar>>( | ||
foo: TFoo, | ||
callback: TCallback, | ||
bar: TBar, | ||
): TCallback | ||
|
||
example(42, (foo, bar) => ({ | ||
t: () => { | ||
let s: string = bar; | ||
} | ||
}), '42'); | ||
|
||
example(42, (foo, bar) => ({ | ||
t() { | ||
let s: string = bar; | ||
} | ||
}), '42'); |