Skip to content

Fix #1891: Don't add redundant constraint #1893

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 2 commits into from
Jan 11, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 10, 2017

Before adding a constraint, make sure there is no way
the two types are already in a subtype relation.

Adding redundant constraints is problematic because we
might introduce cycles. See i1891.scala for a test.

Fixes #1891. Review by @OlivierBlanvillain or/and @smarter?

Before adding a constraint, make sure there is no way
the two types are already in a subtype relation.

Adding redundant constraints is problematic because we
might introduce cycles. See i1891.scala for a test.
// The following condition is carefully formulated to catch all cases
// where the subtype relation is true without needing to add a constraint
// It's tricky because we might need to either appriximate tp2 by its
// lower bound or else widen tp1 and check that the result is a subtype of tp2.
Copy link
Member

Choose a reason for hiding this comment

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

I don't see a widening of tp1 in the code below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The widening is done by all the other parts of subtyping. The important part is not to narrow the lower bound of tp2 before we had a chance to widen tp1.

@smarter
Copy link
Member

smarter commented Jan 11, 2017

LGTM, though this is still a bit mysterious to me ;)

@odersky odersky merged commit 486b029 into scala:master Jan 11, 2017
@allanrenucci allanrenucci deleted the fix-#1891 branch December 14, 2017 16:59
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.

3 participants