Skip to content

Commit 01e4b1e

Browse files
author
Harlan Haskins
committed
Added String.init<T>(_: T) and marked it unavailable
1 parent 212ffad commit 01e4b1e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

stdlib/public/core/String.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,11 @@ extension String {
10461046
public var uppercaseString: String {
10471047
Builtin.unreachable()
10481048
}
1049+
1050+
@available(*, unavailable, renamed: "init(describing:)")
1051+
public init<T>(_: T) {
1052+
Builtin.unreachable()
1053+
}
10491054
}
10501055

10511056
extension Sequence where Iterator.Element == String {

test/1_stdlib/StringDiagnostics_without_Foundation.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ func testStringCollectionTypes(s: String) {
2323
acceptsBidirectionalCollection(s.characters)
2424
acceptsRandomAccessCollection(s.characters) // expected-error{{argument type 'String.CharacterView' does not conform to expected type 'RandomAccessCollection'}}
2525
}
26+
27+
struct NotLosslessStringConvertible {}
28+
29+
func testStringInitT() {
30+
_ = String(NotLosslessStringConvertible()) // expected-error{{'init' has been renamed to 'init(describing:)}}
31+
}

0 commit comments

Comments
 (0)