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

DI: Fix 'self.init' delegation to an imported factory initializer inherited from a base class [4.0] #10195

Merged
merged 1 commit into from Jun 12, 2017

Conversation

Projects
None yet
3 participants
@slavapestov
Member

slavapestov commented Jun 11, 2017

  • Description: A user in the labs reported an issue when calling an NSButton initializer inherited by an NSButton subclass. The initializer is a static factory method in Objective-C and we weren't handling the superclass delegation correctly in DI, causing us to reject the self.init call as an escaping use of 'self'. However the constructor method in question is declared as returning instancetype, and a test shows that it is indeed covariant, so we should allow this call.

  • Scope of the issue: Affects anyone trying to subclass SDK classes that may define these constructors.

  • Origination: It looks like it was broken in 3.1 as well.

  • Risk: Low, makes DI recognize a new code pattern, treating a value_metatype_inst of an upcast_inst the same as a value_metatype_inst of self itself.

  • Tested: New test added.

  • Reviewed by: @DougGregor

  • Radar: Fixes rdar://problem/32697794.

DI: Fix 'self.init' delegation to an imported factory initializer inh…
…erited from a base class

Fixes <rdar://problem/32697794>.

@slavapestov slavapestov requested a review from DougGregor Jun 11, 2017

@slavapestov

This comment has been minimized.

Show comment
Hide comment
@slavapestov

slavapestov Jun 11, 2017

Member

@swift-ci Please test

Member

slavapestov commented Jun 11, 2017

@swift-ci Please test

@ematejska ematejska merged commit 330f4da into apple:swift-4.0-branch Jun 12, 2017

4 checks passed

Swift Test Linux Platform 9910 tests run, 0 skipped, 0 failed.
Details
Swift Test Linux Platform (smoke test)
Details
Swift Test OS X Platform 49805 tests run, 0 skipped, 0 failed.
Details
Swift Test OS X Platform (smoke test)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment