Skip to content

[Parse] Improve diagnostic for deprecated protocol<...> syntax #3631

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
Jul 21, 2016

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jul 20, 2016

What's in this pull request?

  • Don't emit deprecated warnings for incomplete protocol<...>.

    func fn(x: protocol<P) {}
    

    Because other error diagnostics are already emitted
    Moreover, the current fix-it tries to remove ) after P

  • Different message for single protocol compostion.

    typealias MyError = protocol<Error>
    

    Because "join the protocols using '&'" is not relevant in this case

CC: @DougGregor, @joewillsher


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

A smoke test on macOS does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library only for macOS. Simulator standard libraries and
    device standard libraries are not built.
  3. lldb is not built.
  4. The test and validation-test targets are run only for macOS. The optimized
    version of these tests are not run.

A smoke test on Linux does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library incrementally.
  3. lldb is build incrementally.
  4. The swift test and validation-test targets are run. The optimized version of these
    tests are not run.
  5. lldb is tested.

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@joewillsher
Copy link
Contributor

This looks great, I think maybe the error message should specify that the syntax ‘is deprecated and not needed here’ rather than implying the construct is useless?

.fixItRemove({ProtocolLoc, LAngleLoc}) // remove 'protocol<'
.fixItRemove(RAngleLoc); // remove '>'
if (Status.isSuccess()) {
// Only if we have complete prtocol<...> composition, diagnose deprecated.
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nitpick: typo in this comment

@rintaro
Copy link
Member Author

rintaro commented Jul 20, 2016

@joewillsher Thank you for the message suggestion! I'll do that.
Sorry, I'm not good at English 😓

@joewillsher
Copy link
Contributor

No problem at all, thanks doing this!

@rintaro rintaro force-pushed the protocolcomposition-diag branch 2 times, most recently from 3ff8610 to fb11d8d Compare July 20, 2016 12:29
@rintaro
Copy link
Member Author

rintaro commented Jul 20, 2016

Updated warning message for single protocol composition: protocol<P>

@@ -230,7 +230,7 @@ func test_lambda() {

func test_lambda2() {
{ () -> protocol<Int> in
// expected-warning @-1 {{'protocol<...>' composition syntax is deprecated; join the protocols using '&'}}
// expected-warning @-1 {{'protocol<...>' composition syntax is deprecated and not needed here}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please test the fixit is working 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.

Thank you! done.

* Don't emit deprecated warnings for incomplete protocol<...>.
  E.g: `func fn(x: protocol<P) {}`
* Different message for single protocol compostion.
  E.g: `typealias MyError = protocol<Error>`
@rintaro rintaro force-pushed the protocolcomposition-diag branch from fb11d8d to a160f0f Compare July 20, 2016 16:36
@CodaFi
Copy link
Contributor

CodaFi commented Jul 20, 2016

Thanks all!

@swift-ci please test and merge.

@rintaro
Copy link
Member Author

rintaro commented Jul 21, 2016

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Jul 21, 2016

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Jul 21, 2016

Tests passed, merging.

@rintaro rintaro merged commit 97c325f into swiftlang:master Jul 21, 2016
@DougGregor
Copy link
Member

Looks great, thank you!

@rintaro rintaro deleted the protocolcomposition-diag branch July 21, 2016 06:23
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.

4 participants