Skip to content

[5.1][Runtime] Avoid +class overrides when initializing an ObjC class. #24637

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

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented May 9, 2019

Cherry-pick #24618 to 5.1.

swift_getInitializedObjCClass called [c class] to trigger class initialization, and returned the value. This wreaked havoc when the class in question overrides +class. Instead, ignore the return value and return c. Switch from +class to +self, which is much less likely to be overridden. Calling an overridden method could have performance downsides or even cause unwanted side effects.

rdar://problem/49853091

swift_getInitializedObjCClass called [c class] to trigger class initialization, and returned the value. This wreaked havoc when the class in question overrides +class. Instead, ignore the return value and return c. Switch from +class to +self, which is much less likely to be overridden. Calling an overridden method could have performance downsides or even cause unwanted side effects.

rdar://problem/49853091
@mikeash
Copy link
Contributor Author

mikeash commented May 9, 2019

@swift-ci please test

@mikeash mikeash force-pushed the self-awareness-class-struggle-5.1 branch from 1ced752 to 2523778 Compare May 9, 2019 17:10
@mikeash
Copy link
Contributor Author

mikeash commented May 9, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented May 9, 2019

Build failed
Swift Test Linux Platform
Git Sha - 1ced752573fbbf23b8b2572aa644fd34f466950a

@swift-ci
Copy link
Contributor

swift-ci commented May 9, 2019

Build failed
Swift Test OS X Platform
Git Sha - 1ced752573fbbf23b8b2572aa644fd34f466950a

@mikeash mikeash merged commit a311f42 into swiftlang:swift-5.1-branch May 9, 2019
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