-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[AST] Introduce the notion of a protocol requirement signature. #7029
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // RUN: %target-typecheck-verify-swift -typecheck %s -verify | ||
| // RUN: %target-typecheck-verify-swift -typecheck -debug-generic-signatures %s > %t.dump 2>&1 | ||
| // RUN: %FileCheck %s < %t.dump | ||
|
|
||
| // CHECK-LABEL: .P1@ | ||
| // CHECK-NEXT: Requirement signature: <Self> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0> | ||
| protocol P1 {} | ||
|
|
||
| // CHECK-LABEL: .P2@ | ||
| // CHECK-NEXT: Requirement signature: <Self> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0> | ||
| protocol P2 {} | ||
|
|
||
| // CHECK-LABEL: .P3@ | ||
| // CHECK-NEXT: Requirement signature: <Self> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0> | ||
| protocol P3 {} | ||
|
|
||
| // basic protocol | ||
| // CHECK-LABEL: .Q1@ | ||
| // CHECK-NEXT: Requirement signature: <Self where Self.X : P1> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0 where τ_0_0.X : P1> | ||
| protocol Q1 { | ||
| associatedtype X: P1 | ||
| } | ||
|
|
||
| // inheritance | ||
| // CHECK-LABEL: .Q2@ | ||
| // CHECK-NEXT: Requirement signature: <Self where Self : Q1> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0 where τ_0_0 : Q1> | ||
| protocol Q2: Q1 {} | ||
|
|
||
| // inheritance without any new requirements | ||
| // CHECK-LABEL: .Q3@ | ||
| // CHECK-NEXT: Requirement signature: <Self where Self : Q1> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0 where τ_0_0 : Q1> | ||
| protocol Q3: Q1 { | ||
| associatedtype X | ||
| } | ||
|
|
||
| // inheritance adding a new conformance | ||
| // CHECK-LABEL: .Q4@ | ||
| // CHECK-NEXT: Requirement signature: <Self where Self : Q1, Self.X : P2> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0 where τ_0_0 : Q1, τ_0_0.X : P2> | ||
| protocol Q4: Q1 { | ||
| associatedtype X: P2 | ||
| } | ||
|
|
||
| // multiple inheritance | ||
| // CHECK-LABEL: .Q5@ | ||
| // CHECK-NEXT: Requirement signature: <Self where Self : Q2, Self : Q3, Self : Q4> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0 where τ_0_0 : Q2, τ_0_0 : Q3, τ_0_0 : Q4> | ||
| protocol Q5: Q2, Q3, Q4 {} | ||
|
|
||
| // multiple inheritance without any new requirements | ||
| // CHECK-LABEL: .Q6@ | ||
| // CHECK-NEXT: Requirement signature: <Self where Self : Q2, Self : Q3, Self : Q4> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0 where τ_0_0 : Q2, τ_0_0 : Q3, τ_0_0 : Q4> | ||
| protocol Q6: Q2, Q3, Q4 { | ||
| associatedtype X: P1 | ||
| } | ||
|
|
||
| // multiple inheritance with a new conformance | ||
| // CHECK-LABEL: .Q7@ | ||
| // CHECK-NEXT: Requirement signature: <Self where Self : Q2, Self : Q3, Self : Q4, Self.X : P3> | ||
| // CHECK-NEXT: Canonical requirement signature: <τ_0_0 where τ_0_0 : Q2, τ_0_0 : Q3, τ_0_0 : Q4, τ_0_0.X : P3> | ||
| protocol Q7: Q2, Q3, Q4 { | ||
| associatedtype X: P3 | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is just a refactoring of what was there before, but it seems odd to use
RequirementSource::Redundanthere rather thanRequirementSource::Protocol. Maybe we should (separately!) see if we can make that change to align it with what we do below.