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-13733] .swiftinterface file should not add default intializer if we have explicit in base class #56130

Closed
swift-ci opened this issue Oct 14, 2020 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13733
Radar rdar://problem/70298053
Original Reporter Hailin (JIRA User)
Type Bug

Attachment: Download

Environment

This issue happens since Xcode 11 GM Seed 2

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 4a36bee285ec81863a9a5a6cf58296af

Issue Description:

we had submitted a feedback ticket (FB7301109) since Sep, 2019. But never get response from Apple. we have to try report this issue on forums. swift.

issue Description:
There will be build error if use a framework which is generate with below code

import Foundation

open class ObjectBase {
public init()
{ }
}

open class UntypedList : ObjectBase {
public init(capacity:Int)
{ }
}

open class EmptyList : UntypedList {
public init() {
super.init(capacity: 5)
}
}

List the reproduce steps:

  1. Use above sample code to create a framework

  2. Archive it.

  3. xcodebuild -create-xcframework to create xcframework. (Refer page: https://appspector.com/blog/xcframeworks )

  4. Create another project, then import the created xcframework at step 3.

Actually result:
In the generated *.swiftinterface file in the xcframework Modules folder. the code looks like below:

// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
// swift-module-flags: -target x86_64-apple-ios12.4-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name XCInitTest
import Foundation
import Swift
@_exported import XCInitTest
open class ObjectBase {
public init()
@objc deinit
}
open class UntypedList : XCInitTest.ObjectBase {
public init(capacity: Swift.Int)
override public init()
@objc deinit
}
open class EmptyList : XCInitTest.UntypedList {
public init()
override public init(capacity: Swift.Int)
@objc deinit
}

Expected result:
The line 'override public init()' in open class UntypedList
And
The line 'public init()' in open class EmptyList
should not be generated, because the ObjectBase has its explicit Initializers. no need Default Initializers for ObjectBase anymore.
so no need to override init() in its subclass.

@harlanhaskins
Copy link
Collaborator

@swift-ci create

@harlanhaskins
Copy link
Collaborator

@nkcsgexi Just a heads up, this should probably print `override` or not print anything at all.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@tshortli
Copy link
Contributor

This is a duplicate of #56231 which was fixed by #36333.

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
Projects
None yet
Development

No branches or pull requests

3 participants