mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
It's not clear whether we'll actually need this feature in the long run, but we certainly need it now because non-@usableFromInline members can (currently) satisfy public requirements when a @usableFromInline internal type conforms to a public protocol. In these cases, we'll treat the witnesses as present but opaque, and clients will perform dynamic dispatch when using them even when a generic function gets specialized. With this, we're able to generate a textual interface for the standard library, compile it back to a swiftmodule, and use it to build a Hello World program!
17 lines
301 B
Swift
17 lines
301 B
Swift
import Conformances
|
|
|
|
func testGeneric<T: MyProto>(_: T.Type) -> Int {
|
|
var impl = T.init()
|
|
impl.method()
|
|
impl.prop = 0
|
|
return impl[0]
|
|
}
|
|
|
|
public func testFull() -> Int {
|
|
return testGeneric(FullStructImpl.self)
|
|
}
|
|
|
|
public func testOpaque() -> Int {
|
|
return testGeneric(OpaqueStructImpl.self)
|
|
}
|