Fixes type inference of type var from context #447
Merged
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.
For type vars,
ConstraintBuilderVisitor
always created a constraint in theSUPERTYPE_OF
direction for type vars, irrespective of itsdirection
field, which is wrong. This fixes both issue #360 as well as the errors reported by Travis in #443.Currently, 15 tests are failing because the error messages changed due to the fix. Sometimes they became more accurate; sometimes they became wrong (reporting incompatible types of an assignment instead of arguments). Before I fix the messages and test cases, I'd like someone to look at the fix and confirm that it is indeed correct now.
The following example (extension of the one from #360) shows that this pull request fixes that issue and correctly reports a type error in the last line.