Skip to content

Fix #2928: Add special mode for computing the type of a LHS #2946

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
merged 23 commits into from
Aug 21, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 2, 2017

To fix #2928, we need to compute the member type of an assigment's
left-hand side using negative variance.

Based on #2945. Only last two commits are new.

liufengyun
liufengyun previously approved these changes Aug 4, 2017
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last two commits LGTM.

@felixmulder felixmulder dismissed liufengyun’s stale review August 15, 2017 10:52

Not quite there yet.

odersky added 23 commits August 16, 2017 16:18
Approximating type maps now work with bounds instead of NoTypes. This
gives more precision (in particular for type applications), and also
makes it possible to combine approximation with other mappings.

As a side-effect we provide the hooks for preventing constructing
illegal types C#A where C is non-singleton and A is abstract by
setting variance to 0 for the prefix of an abstract type selection.

There's one test case that fails: One of the types in
dependent-exractors.scala does not check out anymore. This has
likely to do with the loss of precision incurred by the maps.
Exact cause remains to be tracked down.
A Range, if it survives, will always lead to a situation
where the upper bound appears in a covariant position
in the result, and the lower bound appears in a contravariant
position. Hence, when we apply a type map to the
argument in a range we should take this into account.
Fixes a previous failure in t2435.scala and dependent-extractors.scala.
Supersedes old scheme of dealing with unstable prefixes in non-variant positions.
It's no longer needed.
 - Use range instead of Range in AsSeenFromMap#apply. We needed Range
   before because we did an incorrect variance computation for NamedTypes.

 - Refine derivedSelect
The logic before was overcomplicated since I did not take into
account that Range refinedInfos could only happen at variance 0.
On the othet hand, it did not take into account all the subtleties of
alias types with variances.
This puts avoid on firmer ground.
 - Add documentation
 - Drop debug code
 - Tweak what we do in the TypeVar case to align
   with interpolation.
In a commonly used derived... operation, deal with the common
case that the types have not chanegd first.
Test case in i2945.scala.
For a Block, TypeAssigner does an avoid just for term symbols whereas
Typer does one for all local symbols. Since Typer called TypeAssigner,
we got a double avoidance pass. This is eliminated by assigning types
directly in Typer without passing through TypeAssigner.
To fix scala#2928, we need to compute the member type of an assigment's
left-hand side using negative variance.
@odersky odersky merged commit 72c7a90 into scala:master Aug 21, 2017
@allanrenucci allanrenucci deleted the fix-#2928 branch December 14, 2017 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unsound type widening for setters with wildcard types
2 participants