-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] [Typechecker] Emit fix-its for witness mismatches #26990
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
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7f959fd
[Typechecker] Emit fix-its for witness mismatches
theblixguy 8c3cb71
[Typechecker] Remove some questionable fix-its when there is a witnes…
theblixguy 6b1f0c9
[Typechecker] Don't emit a diagnostic for NonMutatingConflict
theblixguy eb045f5
[Test] Add a test case for computed property
theblixguy 37ffd6b
[Test] Add a test case for static subscript
theblixguy 4c8450e
[Typechecker] Add a comment to explain why we don't offer a fix-it wh…
theblixguy 535364c
[Typechecker] We could also have a subscript when diagnosing Settable…
theblixguy 5d04df0
[Typechecker] Add trailing space when adding the 'static' fix-it
theblixguy 5077b00
[Test] Update test and add trailing space to 'static' fix-its
theblixguy 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
prefix operator ^^^ | ||
postfix operator ^^^^ | ||
|
||
protocol Foo { | ||
var bar1: Int { get set } // expected-note {{protocol requires property 'bar1' with type 'Int'; do you want to add a stub?}} | ||
static var bar2: Int { get set } // expected-note {{protocol requires property 'bar2' with type 'Int'; do you want to add a stub?}} | ||
var bar3: Int { get set } // expected-note {{protocol requires property 'bar3' with type 'Int'; do you want to add a stub?}} | ||
static prefix func ^^^(value: Self) -> Int // expected-note {{protocol requires function '^^^' with type '(ConformsToFoo) -> Int'; do you want to add a stub?}} | ||
static postfix func ^^^^(value: Self) -> Int // expected-note {{protocol requires function '^^^^' with type '(ConformsToFoo) -> Int'; do you want to add a stub?}} | ||
func bar4(closure: () throws -> Int) rethrows // expected-note {{protocol requires function 'bar4(closure:)' with type '(() throws -> Int) throws -> ()'; do you want to add a stub?}} | ||
var bar5: Int { get set } // expected-note {{protocol requires property 'bar5' with type 'Int'; do you want to add a stub?}} | ||
static subscript(_ pos: Int) -> Int { get } // expected-note {{protocol requires subscript with type '(Int) -> Int'; do you want to add a stub?}} | ||
} | ||
|
||
struct ConformsToFoo: Foo { // expected-error {{type 'ConformsToFoo' does not conform to protocol 'Foo'}} | ||
let bar1: Int // expected-note {{candidate is not settable, but protocol requires it}}{{3-6=var}} | ||
var bar2: Int // expected-note {{candidate operates on an instance, not a type as required}}{{3-3=static }} | ||
static var bar3: Int = 1 // expected-note {{candidate operates on a type, not an instance as required}}{{3-10=}} | ||
static postfix func ^^^(value: ConformsToFoo) -> Int { return 0 } // expected-error {{operator implementation without matching operator declaration}} | ||
// expected-note@-1 {{candidate is postfix, not prefix as required}}{{10-17=prefix}} | ||
static prefix func ^^^^(value: ConformsToFoo) -> Int { return 0 } // expected-error {{operator implementation without matching operator declaration}} | ||
// expected-note@-1 {{candidate is prefix, not postfix as required}}{{10-16=postfix}} | ||
func bar4(closure: () throws -> Int) throws {} // expected-note {{candidate is not 'rethrows', but protocol requires it}}{{40-46=rethrows}} | ||
var bar5: Int { return 0 } // expected-note {{candidate is not settable, but protocol requires it}}{{none}} | ||
subscript(_ pos: Int) -> Int { return 0 } // expected-note {{candidate operates on an instance, not a type as required}}{{3-3=static }} | ||
} | ||
|
||
protocol Foo1 { | ||
subscript(value: Bool) -> Bool { get set } // expected-note {{protocol requires subscript with type '(Bool) -> Bool'; do you want to add a stub?}} | ||
} | ||
|
||
struct ConformsToFoo1: Foo1 { // expected-error {{type 'ConformsToFoo1' does not conform to protocol 'Foo1'}} | ||
subscript(value: Bool) -> Bool { return false } // expected-note {{candidate is not settable, but protocol requires it}}{{none}} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.