Fix type parameters upon subsequent visits to a parameter that caused fixing the first time#3787
Merged
JsonFreeman merged 12 commits intomasterfrom Jul 17, 2015
Merged
Fix type parameters upon subsequent visits to a parameter that caused fixing the first time#3787JsonFreeman merged 12 commits intomasterfrom
JsonFreeman merged 12 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
why you have to check mightFixTypeParameters again?
Contributor
Author
There was a problem hiding this comment.
Good question. In this case, I noticed that we are passing the contextualMapper into getReturnTypeFromBody. That indicates to me that we may fix some type parameters if the return expression contains a function expression. So I am ensuring that anywhere that it's possible to fix type parameters, we go through that code path.
… fixingTypeParameters Conflicts: src/compiler/checker.ts
… fixingTypeParameters
… fixingTypeParameters
Contributor
Author
|
@yuit any more feedback? @DanielRosenwasser @ahejlsberg Do you have any feedback on this change? |
… fixingTypeParameters
… fixingTypeParameters
src/compiler/checker.ts
Outdated
Member
|
👍 |
JsonFreeman
added a commit
that referenced
this pull request
Jul 17, 2015
Fix type parameters upon subsequent visits to a parameter that caused fixing the first time
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #2378.
The problem is that if a type parameter has already been given a type in the process of type argument inference, and caused type parameters to be fixed, we don't consistently fix the type parameters on a subsequent visit. See the bug for examples of how this can be observed.
The fix is that if a contextually typed parameter already has a type, we should still fix the type parameters that would have been fixed, had this been the first encounter of the given parameter.