Skip to content

SR-2747: Recommend type(of:) instead of .dynamicType #4974

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
Sep 28, 2016
Merged

SR-2747: Recommend type(of:) instead of .dynamicType #4974

merged 1 commit into from
Sep 28, 2016

Conversation

SlaunchaMan
Copy link
Contributor

When trying to use .class() from Objective-C, the compiler recommended using .dynamicType instead, which has been deprecated in favor of type(of:).

Resolves SR-2747.

@jrose-apple
Copy link
Contributor

Thanks for catching this and thanks for the patch! I think I'd mildly prefer just naming this operation like a Swift function: type(of:) instead of type(of: …). @DougGregor, @jckarter, what do you think?

@jckarter
Copy link
Contributor

type(of:) seems slightly better to me too. Are there other similar diagnostics to look at for consistency?

@DougGregor
Copy link
Member

Agreed on the type(of:) thing, LGTM otherwise. Thanks!

@SlaunchaMan
Copy link
Contributor Author

Fixed the issue. I used type(of: …) because that’s what showed up in Xcode:
screen shot 2016-09-23 at 1 24 48 pm
But I’m not sure where that comes from.

@SlaunchaMan
Copy link
Contributor Author

Found where it comes from. If it’s better that they’re consistent I’m happy to change the other instance(s) of type(of: ...) to type(of:).

@SlaunchaMan SlaunchaMan changed the title SR-2747: Recommend type(of: …) instead of .dynamicType SR-2747: Recommend type(of:) instead of .dynamicType Sep 24, 2016
_ = NSObject.`class`() // expected-error {{'class()' is unavailable in Swift: use 'self' instead}}
_ = obj.`class`!() // expected-error {{'class()' is unavailable in Swift: use 'dynamicType' instead}}
_ = obj.`class`!() // expected-error {{'class()' is unavailable in Swift: use 'type(of:' instead}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing paren

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, fixed!

@DougGregor
Copy link
Member

@swift-ci please smoke test

@SlaunchaMan
Copy link
Contributor Author

Any more thoughts on this?

@DougGregor
Copy link
Member

LGTM!

@DougGregor DougGregor merged commit e717571 into swiftlang:master Sep 28, 2016
@jrose-apple
Copy link
Contributor

Thanks, Jeff!

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