.swiftinterface file should not add default intializer if we have explicit in base class

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.

This issue happens since Xcode 11 GM Seed 2
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.

Wrong place to submit a bug report. Try bugs.swift.org

Thanks for reminder, SR is filed here - https://bugs.swift.org/browse/SR-13733

Terms of Service

Privacy Policy

Cookie Policy