-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Still generate signatures in SkipContextSensitive mode just to match …
…on return types (#25937) * Still generate signatures in SkipContextSensitive mode just to match on return types * Add cache for context-free type of a signature node * Accept post-merge baseline
- Loading branch information
Showing
6 changed files
with
130 additions
and
0 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
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.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,21 @@ | ||
//// [badInferenceLowerPriorityThanGoodInference.ts] | ||
interface Foo<A> { | ||
a: A; | ||
b: (x: A) => void; | ||
} | ||
|
||
declare function canYouInferThis<A>(fn: () => Foo<A>): A; | ||
|
||
const result = canYouInferThis(() => ({ | ||
a: { BLAH: 33 }, | ||
b: x => { } | ||
})) | ||
|
||
result.BLAH; | ||
|
||
//// [badInferenceLowerPriorityThanGoodInference.js] | ||
var result = canYouInferThis(function () { return ({ | ||
a: { BLAH: 33 }, | ||
b: function (x) { } | ||
}); }); | ||
result.BLAH; |
42 changes: 42 additions & 0 deletions
42
tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.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,42 @@ | ||
=== tests/cases/compiler/badInferenceLowerPriorityThanGoodInference.ts === | ||
interface Foo<A> { | ||
>Foo : Symbol(Foo, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 0)) | ||
>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 14)) | ||
|
||
a: A; | ||
>a : Symbol(Foo.a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 18)) | ||
>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 14)) | ||
|
||
b: (x: A) => void; | ||
>b : Symbol(Foo.b, Decl(badInferenceLowerPriorityThanGoodInference.ts, 1, 9)) | ||
>x : Symbol(x, Decl(badInferenceLowerPriorityThanGoodInference.ts, 2, 8)) | ||
>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 14)) | ||
} | ||
|
||
declare function canYouInferThis<A>(fn: () => Foo<A>): A; | ||
>canYouInferThis : Symbol(canYouInferThis, Decl(badInferenceLowerPriorityThanGoodInference.ts, 3, 1)) | ||
>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 33)) | ||
>fn : Symbol(fn, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 36)) | ||
>Foo : Symbol(Foo, Decl(badInferenceLowerPriorityThanGoodInference.ts, 0, 0)) | ||
>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 33)) | ||
>A : Symbol(A, Decl(badInferenceLowerPriorityThanGoodInference.ts, 5, 33)) | ||
|
||
const result = canYouInferThis(() => ({ | ||
>result : Symbol(result, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 5)) | ||
>canYouInferThis : Symbol(canYouInferThis, Decl(badInferenceLowerPriorityThanGoodInference.ts, 3, 1)) | ||
|
||
a: { BLAH: 33 }, | ||
>a : Symbol(a, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 39)) | ||
>BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 8)) | ||
|
||
b: x => { } | ||
>b : Symbol(b, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 20)) | ||
>x : Symbol(x, Decl(badInferenceLowerPriorityThanGoodInference.ts, 9, 6)) | ||
|
||
})) | ||
|
||
result.BLAH; | ||
>result.BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 8)) | ||
>result : Symbol(result, Decl(badInferenceLowerPriorityThanGoodInference.ts, 7, 5)) | ||
>BLAH : Symbol(BLAH, Decl(badInferenceLowerPriorityThanGoodInference.ts, 8, 8)) | ||
|
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.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,40 @@ | ||
=== tests/cases/compiler/badInferenceLowerPriorityThanGoodInference.ts === | ||
interface Foo<A> { | ||
a: A; | ||
>a : A | ||
|
||
b: (x: A) => void; | ||
>b : (x: A) => void | ||
>x : A | ||
} | ||
|
||
declare function canYouInferThis<A>(fn: () => Foo<A>): A; | ||
>canYouInferThis : <A>(fn: () => Foo<A>) => A | ||
>fn : () => Foo<A> | ||
|
||
const result = canYouInferThis(() => ({ | ||
>result : { BLAH: number; } | ||
>canYouInferThis(() => ({ a: { BLAH: 33 }, b: x => { }})) : { BLAH: number; } | ||
>canYouInferThis : <A>(fn: () => Foo<A>) => A | ||
>() => ({ a: { BLAH: 33 }, b: x => { }}) : () => { a: { BLAH: number; }; b: (x: { BLAH: number; }) => void; } | ||
>({ a: { BLAH: 33 }, b: x => { }}) : { a: { BLAH: number; }; b: (x: { BLAH: number; }) => void; } | ||
>{ a: { BLAH: 33 }, b: x => { }} : { a: { BLAH: number; }; b: (x: { BLAH: number; }) => void; } | ||
|
||
a: { BLAH: 33 }, | ||
>a : { BLAH: number; } | ||
>{ BLAH: 33 } : { BLAH: number; } | ||
>BLAH : number | ||
>33 : 33 | ||
|
||
b: x => { } | ||
>b : (x: { BLAH: number; }) => void | ||
>x => { } : (x: { BLAH: number; }) => void | ||
>x : { BLAH: number; } | ||
|
||
})) | ||
|
||
result.BLAH; | ||
>result.BLAH : number | ||
>result : { BLAH: number; } | ||
>BLAH : number | ||
|
13 changes: 13 additions & 0 deletions
13
tests/cases/compiler/badInferenceLowerPriorityThanGoodInference.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,13 @@ | ||
interface Foo<A> { | ||
a: A; | ||
b: (x: A) => void; | ||
} | ||
|
||
declare function canYouInferThis<A>(fn: () => Foo<A>): A; | ||
|
||
const result = canYouInferThis(() => ({ | ||
a: { BLAH: 33 }, | ||
b: x => { } | ||
})) | ||
|
||
result.BLAH; |