Skip to content

[SR-3168] Add fix-it for "'optional' can only be applied to protocol members" #5717

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 1 commit into from
Nov 11, 2016
Merged

[SR-3168] Add fix-it for "'optional' can only be applied to protocol members" #5717

merged 1 commit into from
Nov 11, 2016

Conversation

robinkunde
Copy link
Contributor

This PR adds a fixit for cases in which the keyword "optional" is incorrectly applied to class or struct methods.

Resolves SR-3168.

@robinkunde
Copy link
Contributor Author

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Nov 11, 2016

@robinkunde Thanks!
test/FixCode/fixits-apply.swift is not the primary place for testing diagnostics.
Could you update test/decl/protocol/req/optional.swift instead?

@robinkunde
Copy link
Contributor Author

@rintaro Maybe I'm misunderstanding, but I didn't touch the diagnostic itself and it's already covered in test/decl/protocol/req/optional.swift starting at line 207. Do you want me to set up that test file to test fixits as well?

@rintaro
Copy link
Member

rintaro commented Nov 11, 2016

Yeah, testing fix-its can be done with:

  optional var ivar: Int // expected-error{{'optional' can only be applied to protocol members}} {{3-14=}}

The format is:

{{3-14=something}}
   \ \     `- replacing text
    \ `- end column
     `- start column

@robinkunde
Copy link
Contributor Author

@rintaro Thanks for pointing that out! I've amended the commit.

@rintaro
Copy link
Member

rintaro commented Nov 11, 2016

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Nov 11, 2016

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Nov 11, 2016

Merging. Thank you @robinkunde !

@rintaro rintaro merged commit 71364d0 into swiftlang:master Nov 11, 2016
@robinkunde robinkunde deleted the fixit_optional_method branch December 9, 2016 15:39
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.

2 participants