mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
39 lines
676 B
Swift
39 lines
676 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -O -module-name=test %s -o %t/a.out
|
|
// RUN: %target-codesign %t/a.out
|
|
// RUN: %target-run %t/a.out | %FileCheck %s
|
|
// REQUIRES: executable_test
|
|
|
|
class Base {
|
|
required init() { }
|
|
|
|
class func instance() -> Base {
|
|
return self.init()
|
|
}
|
|
}
|
|
|
|
class Middle: Base {
|
|
override class func instance() -> Middle {
|
|
return self.init()
|
|
}
|
|
}
|
|
|
|
class Derived: Middle {
|
|
required init() {
|
|
super.init()
|
|
print("init Derived")
|
|
}
|
|
}
|
|
|
|
struct Maker<C: Base> {
|
|
@inline(never)
|
|
static func create() -> Base {
|
|
return C.instance()
|
|
}
|
|
}
|
|
|
|
// CHECK: init Derived
|
|
// CHECK: test.Derived
|
|
print(Maker<Derived>.create())
|
|
|