Skip to content

Fixit to remove empty argument for non-function calls #3196

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
Jun 27, 2016

Conversation

harlanhaskins
Copy link
Contributor

@harlanhaskins harlanhaskins commented Jun 24, 2016

What's in this pull request?

When attempting to call a non-function type with an empty tuple as arguments, remove the empty tuple and use the value directly.

This will be a big help to people who mistakenly use class methods that are now class vars in Objective-C.

Resolved bug number: (N/A)


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

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.

@nkcsgexi
Copy link
Contributor

Nice! Can we do something like this to support getter/setter to property change, e.g. Fixing I.getA() to I.A, when A is available of course.

@harlanhaskins
Copy link
Contributor Author

I'm sure we could! I don't think that's in scope for this patch, but we can make another one. That'll be more complicated, though

@jrose-apple
Copy link
Contributor

It helps that most Cocoa getters have the same name as the property.

@harlanhaskins
Copy link
Contributor Author

@jrose-apple @nkcsgexi Should this fix-it be applied to a note that says why to remove the parens?

@nkcsgexi
Copy link
Contributor

Jordan may believe otherwise, but i think the error message itself is clear enough.

@@ -305,7 +305,7 @@ class NSObjectable : NSObjectProtocol {
// Properties with custom accessors
func customAccessors(_ hive: Hive, bee: Bee) {
markUsed(hive.isMakingHoney)
markUsed(hive.makingHoney()) // expected-error{{cannot call value of non-function type 'Bool'}}
markUsed(hive.makingHoney()) // expected-error{{cannot call value of non-function type 'Bool'}}{{28-29=}}
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, this fix-it only removes l-paren (. Shouldn't it be {{28-30=}}?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@jrose-apple
Copy link
Contributor

I agree with Xi on this one. Removing the parens is the obvious thing a human would try, and it's highly likely to be correct.

@harlanhaskins
Copy link
Contributor Author

@swift-ci please test

@harlanhaskins
Copy link
Contributor Author

@jrose-apple @rintaro good to merge?

@rintaro
Copy link
Member

rintaro commented Jun 25, 2016

LGTM.

@jrose-apple
Copy link
Contributor

Yep, looks good.

@harlanhaskins harlanhaskins merged commit cca7dca into swiftlang:master Jun 27, 2016
@harlanhaskins harlanhaskins deleted the call-me-maybe branch June 27, 2016 00:06
harlanhaskins pushed a commit to harlanhaskins/swift that referenced this pull request Jun 27, 2016
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