mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
e526ae36e8
This PR allows the use, in Embedded Swift, of the overloads of `String.init(describing:)` that are constrained to specific protocols (currently `CustomStringConvertible` and `TextOutputStreamable`). These overloads can be fully supported in Embedded Swift as they do not rely on runtime type inspection and just call through to protocol requirements known at compile time. - **Explanation**: Allows some uses of `String.init(describing:)` in Embedded Swift. - **Scope**: Embedded Swift, stringification - **Issues**: rdar://139729101 - **Risk**: Low - **Testing**: Existing CI coverage and new test file.
21 lines
567 B
Swift
21 lines
567 B
Swift
// RUN: %target-swift-emit-ir -verify -verify-ignore-unrelated %s -enable-experimental-feature Embedded -wmo
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
// REQUIRES: optimized_stdlib
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
public struct MyStruct: CustomStringConvertible {
|
|
public var description: String { "" }
|
|
}
|
|
|
|
public struct MyStreamableStruct: TextOutputStreamable {
|
|
public func write<Target: TextOutputStream>(to target: inout Target) {}
|
|
}
|
|
|
|
public func foo(s: MyStruct) {
|
|
_ = String(describing: s)
|
|
}
|
|
|
|
public func bar(s: MyStreamableStruct) {
|
|
_ = String(describing: s)
|
|
} |