mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
25 lines
729 B
Swift
25 lines
729 B
Swift
// RUN: %target-typecheck-verify-swift -swift-version 4
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Semi-bogus factory init pattern -- Swift 4 permitted this for non-final
|
|
// classes, which is unsound, but swift-corelibs-foundation made use of
|
|
// this, so possibly there are other usages in the wild.
|
|
//
|
|
// See test/decl/func/dynamic_self.swift for the Swift 5 test case.
|
|
|
|
protocol FactoryPattern {
|
|
init(factory: @autoclosure () -> Self)
|
|
}
|
|
|
|
extension FactoryPattern {
|
|
init(factory: @autoclosure () -> Self) { self = factory() }
|
|
}
|
|
|
|
class Factory : FactoryPattern {
|
|
init(_string: String) {}
|
|
|
|
convenience init(string: String) {
|
|
self.init(factory: Factory(_string: string))
|
|
}
|
|
}
|