-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Still generate signatures in SkipContextSensitive mode just to match on return types #25937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
weswigham
merged 5 commits into
microsoft:master
from
weswigham:retain-noncontextual-return-bits
Aug 9, 2018
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2114f4a
Still generate signatures in SkipContextSensitive mode just to match …
weswigham d84df77
Add cache for context-free type of a signature node
weswigham 713ef38
Merge branch 'master' into retain-noncontextual-return-bits
weswigham e061ea1
Accept post-merge baseline
weswigham 8b71962
Merge branch 'master' into retain-noncontextual-return-bits
weswigham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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)) | ||
|
|
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.types
This file contains hidden or 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,49 @@ | ||
| === tests/cases/compiler/badInferenceLowerPriorityThanGoodInference.ts === | ||
| interface Foo<A> { | ||
| >Foo : Foo<A> | ||
| >A : A | ||
|
|
||
| a: A; | ||
| >a : A | ||
| >A : A | ||
|
|
||
| b: (x: A) => void; | ||
| >b : (x: A) => void | ||
| >x : A | ||
| >A : A | ||
| } | ||
|
|
||
| declare function canYouInferThis<A>(fn: () => Foo<A>): A; | ||
| >canYouInferThis : <A>(fn: () => Foo<A>) => A | ||
| >A : A | ||
| >fn : () => Foo<A> | ||
| >Foo : Foo<A> | ||
| >A : A | ||
| >A : 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 hidden or 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; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth caching this type in some way? Like having an internal
() => Tgeneric that I simply instantiate here?