Skip to content
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

[SR-8142] Declaration 'init()' cannot override more than one superclass declaration in Xcode 10 #50674

Closed
swift-ci opened this issue Jun 28, 2018 · 9 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8142
Radar rdar://problem/41591677
Original Reporter maicki (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, 4.2Regression, ClangImporter
Assignee @DougGregor
Priority Medium

md5: 91cf17865caaea2e31b0a863ba8b5e63

Issue Description:

We are declaring an ASViewController initWithNode: method in Obj-C the following way

@interface ASViewController<__covariant DisplayNodeType : ASDisplayNode *> : UIViewController <ASVisibilityDepth>
///...
- (instancetype)initWithNode:(DisplayNodeType)node;
///...

Starting with Xcode 10 if someone tries to overwrite the `init()` method of the `ASViewController` in a subclass via:

class SomeViewControllerSubclass: ASViewController<ASTableNode> {
 override init() {
    super.init(node: ASTableNode())     
    // ...
  }

the following Xcode error will be show up:

I found kind of workaround, but I'm not sure if this is expected behavior going forward:

override init(node: ASTableNode? = nil) {
  super.init(node: ASTableNode())       
  // ...
}
@belkadan
Copy link
Contributor

Definitely seems like something fishy is going on. At the same time, though, I wouldn't expect init to be an override at all, since ASViewController presumably wants -initWithNode: to be the designated initializer. Can you (1) try adding NS_DESIGNATED_INIT to all of the designated initializers in ASViewController, and (2) attach the project so we can figure out what's going on?

@swift-ci
Copy link
Collaborator Author

Comment by Former user (JIRA)

I tried that already out, it still had the same result, here is actually some more information on the warning:

You can also check it out if you just clone down this repo: https://github.com/TextureGroup/Texture/ and change to `MSRewriteSwiftExample` branch. Head into Texture/examples_extra/ASDKgram-Swift and `pod install` and open the workspace.

And thank you, any response is greatly appreciated!

@belkadan
Copy link
Contributor

Thanks! I have a suspicion about what's going on now.

@swift-ci create

@DougGregor
Copy link
Member

I've managed to reduce this down considerably:

// Foo.h, the bridging header
#import <Foundation/Foundation.h>

@interface MyIntermediateClass : NSObject
- (nonnull instancetype)initWithDouble:(double)value NS_DESIGNATED_INITIALIZER;
@end

@interface MyGenericClass<__covariant T> : MyIntermediateClass
- (nonnull instancetype)initWithValue:(nonnull T)value;
@end

// Foo.swift
import Foundation

class MyConcreteClass: MyGenericClass<NSObject> {
  init() {
    super.init(value: NSObject())
  }
}

@DougGregor
Copy link
Member

#17703

@DougGregor
Copy link
Member

And for 4.2: #17706

@DougGregor
Copy link
Member

PRs merged to both master and 4.2

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 4, 2018

maicki (JIRA User),
Could you verify if the problem is fixed and if so move the JIRA to "Closed"?
Thanks!
Anna

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 5, 2018

Comment by Former user (JIRA)

@AnnaZaks Yep, my bad, sorry. Can confirm it's fixed!

Thanks again for @DougGregor and @belkadan for the fast turnaround.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2
Projects
None yet
Development

No branches or pull requests

4 participants