Skip to content

[GSB] Diagnose redundant same-type constraints. #8263

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 3 commits into from
Mar 22, 2017

Conversation

DougGregor
Copy link
Member

Diagnose redundant same-type constraints using most of the same
machinery for diagnosing other redundant constraints. However,
same-type constraints are particularly interesting because
redundancies can be spelled in a number of different ways. Address
this using the connected components of the subgraph involving only
derived requirements (which is already used for the minimized generic
signature). Then, separate all of the non-derived requirements into
the intracomponent requirements and intercomponent requirements:

  • All of the intracomponent requirements are redundant by definition,
    because the components are defined by derived constraints.

  • For the intercomponent requirements, form a spanning tree among the
    various components and diagnose as redundant any edges that do not
    extend the spanning tree.

…nstraints.

It's better to compute this information once while we're sorting
through all of the same-type constraints, so we can use it later when
performing queries (e.g., enumerating requirements).
Diagnose redundant same-type constraints using most of the same
machinery for diagnosing other redundant constraints. However,
same-type constraints are particularly interesting because
redundancies can be spelled in a number of different ways. Address
this using the connected components of the subgraph involving only
derived requirements (which is already used for the minimized generic
signature). Then, separate all of the non-derived requirements into
the intracomponent requirements and intercomponent requirements:

* All of the intracomponent requirements are redundant by definition,
  because the components are defined by derived constraints.

* For the intercomponent requirements, form a spanning tree among the
  various components and diagnose as redundant any edges that do not
  extend the spanning tree.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift
// RUN: %target-typecheck-verify-swift -swift-version 4
Copy link
Contributor

Choose a reason for hiding this comment

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

What changed between 3 and 4 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm using a "where" clause on a protocol in one of the later tests.

@DougGregor
Copy link
Member Author

DougGregor commented Mar 22, 2017

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit ef4328b into swiftlang:master Mar 22, 2017
@DougGregor DougGregor deleted the redundant-same-type-constraints branch March 22, 2017 14:15
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