Skip to content

Avoid junk produced by Constraint#replace. #678

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 4 commits into from
Jun 25, 2015

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 22, 2015

There were two instances where a constraint undergoing a replace would still refer
to poly params that are no longer bound after the replace.

  1. In an ordering the replaced parameter was not removed from the bounds of the others.
  2. When a parameter refers to the replaced parameter in a type, (not a TypeBounds), the
    replaced parameter was not replaced.

We now have checking in place that in globally committable typer states, TypeVars are not instantiated
to PolyParams and (configurable) that constraints of such typer states are always closed.

Fixes #670. Review by @retronym

There were two instances where a constraint undergoing a replace would still refer
to poly params that are no longer bound after the replace.

1. In an ordering the replaced parameters was n ot removed from the bounds of the others.
2. When a parameter refers to the replaced parameter in a type, (not a TypeBounds), the
replaced parameter was not replaced.

We now have checking in place that in globally committable typer states, TypeVars are not instantiated
to PolyParams and (configurable) that constraints of such typer states are always closed.

Fixes scala#670.
def removeFromOrdering(po: ParamOrdering) = {
def removeFromBoundss(key: PolyType, bndss: Array[List[PolyParam]]): Array[List[PolyParam]] = {
val bndss1 = bndss.map(bnds => bnds.filterConserve(_.binder ne pt))
if ((0 until bndss.length).forall(i => bndss(i) eq bndss1(i))) bndss else bndss1
Copy link
Member

Choose a reason for hiding this comment

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

bndss.indices.forall

Copy link
Member

Choose a reason for hiding this comment

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

Maybe:

var removed = false
val bndss1 = bndss.map(bnds => bnds.filterConserve(x => (x.binder ne pt) || { removed = true; false }))
if (removed) bndss1 else bndss

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I settled for:

    val bndss1 = bndss.map(_.filterConserve(_.binder ne pt))
    if (bndss.corresponds(bndss1)(_ eq _)) bndss else bndss1

@retronym
Copy link
Member

The commit comment has a few lines longer than the git convention, makes it hard to read in the GitHub UI.

odersky added 3 commits June 23, 2015 10:39
Uncomment two lines that were commented out by accident.
Find a nicer way to express the same logic.
The operation on SimpleMap is eager. As suggested by @retronym we should
find a name different from the lazy Map#mapValues operation.
odersky added a commit that referenced this pull request Jun 25, 2015
Avoid junk produced by Constraint#replace.
@odersky odersky merged commit 67aef97 into scala:master Jun 25, 2015
@allanrenucci allanrenucci deleted the fix/#670-orphan-polyparam branch December 14, 2017 19:21
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.

Orphan PolyParam when typing overloaded array apply
2 participants