Files
swift-mirror/test/embedded/string-describing.swift
T
Jonathan Grynspan e526ae36e8 Allow String.init(describing:) in Embedded Swift (sometimes). (#88738)
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.
2026-04-30 17:50:26 -07:00

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)
}