Skip to content

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented May 27, 2016

What's in this pull request?

Emits a warning when is casts are used with foreign types per the discussion on the attached SR.

Resolved bug number: (SR-1612)


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.

@@ -663,6 +663,9 @@ ERROR(super_initializer_not_in_initializer,none,
"'super.init' cannot be called outside of an initializer", ())
WARNING(isa_is_always_true,none, "'%0' test is always true",
(StringRef))
WARNING(isa_is_foreign_check,none,
"'%0' test always succeeds because %1 is a foreign type",
Copy link
Contributor Author

@CodaFi CodaFi May 27, 2016

Choose a reason for hiding this comment

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

This warning text needs to be improved or this term needs to be defined. Suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

What do we do for as!? Do we just use the generic message?

Unless @rjmccall has any objections, I'd be okay with just hardcoding "Core Foundation type" for now. I think I'd also change the message to say why the check always returns true (and avoid "succeeds").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

@CodaFi CodaFi May 29, 2016

Choose a reason for hiding this comment

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

We do nothing for as!, but I can insert the diagnostic (though it's counter to the point of ! for one).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, maybe we don't diagnose for as! because there's no way to silence that diagnostic and it's sometimes useful…whereas this one isn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want to leave the conditional cast warning in? On the one hand the cast always succeeds, on the other it is the form we want people to be using.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with saying "Core Foundation type".

@CodaFi CodaFi force-pushed the foreign-affairs branch 6 times, most recently from f68d9ba to 95f5b87 Compare June 2, 2016 00:42
@slavapestov slavapestov self-assigned this Jun 2, 2016
@slavapestov
Copy link
Contributor

Looks good to me.

@slavapestov
Copy link
Contributor

@swift-ci Please test

@CodaFi CodaFi force-pushed the foreign-affairs branch from 95f5b87 to f68d9ba Compare June 2, 2016 17:53
@slavapestov
Copy link
Contributor

@swift-ci Please test

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 2, 2016

This is going to fail a bunch of tests. I pushed the wrong branch here. Give me a moment to amend this with the proper patch we discussed in the comments.

@CodaFi CodaFi force-pushed the foreign-affairs branch from f68d9ba to d55d564 Compare June 2, 2016 18:05
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 2, 2016

There. Thanks!

@harlanhaskins
Copy link
Contributor

@swift-ci please test

WARNING(isa_is_always_true,none, "'%0' test is always true",
(StringRef))
WARNING(isa_is_foreign_check,none,
"'is' test always succeeds because %0 is a CoreFoundation type",
Copy link
Contributor

Choose a reason for hiding this comment

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

Phrasing nitpick: "Core Foundation", not "CoreFoundation". I'm also still not happy with "succeeds" (as opposed to "returns true" or "is always true" or "evaluates to true") because it's not going to do a test at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Phrasing nitpick: "Core Foundation", not "CoreFoundation".
...
I'm also still not happy with "succeeds"

Agree. Will fix.

because it's not going to do a test at all.

This is styled on the language of the warning above. I can change both if that is what is required.

Copy link
Contributor

@jrose-apple jrose-apple Jun 2, 2016

Choose a reason for hiding this comment

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

Yeah, but a cast does something in addition to a type-check. It's less obviously a "success" when it's just the type-check. (Thanks.)

Copy link
Contributor Author

@CodaFi CodaFi Jun 2, 2016

Choose a reason for hiding this comment

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

Precisely. We agree on that point. Should I change language with regards to the other?

@CodaFi CodaFi force-pushed the foreign-affairs branch 3 times, most recently from 95f5b87 to e880782 Compare June 3, 2016 00:26
@harlanhaskins
Copy link
Contributor

@swift-ci please test

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

Linux failure is unrelated.

@CodaFi CodaFi force-pushed the foreign-affairs branch from e880782 to 1e54f33 Compare June 3, 2016 04:43
@jrose-apple
Copy link
Contributor

One more time!

@swift-ci Please test

Per the discussion in SR-1612, we don’t have a robust mechanism for
checking this and should warn about it.

Signed-off-by: Robert Widmann <devteam.codafi@gmail.com>
@CodaFi CodaFi force-pushed the foreign-affairs branch from 1e54f33 to dee7aaa Compare June 3, 2016 23:02
@harlanhaskins
Copy link
Contributor

Once more, with feeling!
@swift-ci please test

@CodaFi CodaFi force-pushed the foreign-affairs branch 2 times, most recently from e880782 to dee7aaa Compare June 3, 2016 23:07
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

Yep, this passed a build ago. Let's see what happens now.

@jrose-apple
Copy link
Contributor

I think we're good. Thanks, Robert!

@jrose-apple jrose-apple merged commit f822361 into swiftlang:master Jun 8, 2016
@CodaFi CodaFi deleted the foreign-affairs branch June 8, 2016 16:28
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.

5 participants