Skip to content

Commit 2202581

Browse files
committed
stdlib: Add unavailable declarations with fix-it for 'print' and 'debugPrint'
1 parent b906a25 commit 2202581

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

stdlib/public/core/Print.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,22 @@ internal func _debugPrint<Target : TextOutputStream>(
283283
//===----------------------------------------------------------------------===//
284284
//===--- Migration Aids ---------------------------------------------------===//
285285

286+
@available(*, unavailable, renamed: "print(_:separator:terminator:to:)")
287+
public func print<Target : TextOutputStream>(
288+
_ items: Any...,
289+
separator: String = "",
290+
terminator: String = "",
291+
toStream output: inout Target
292+
) {}
293+
294+
@available(*, unavailable, renamed: "debugPrint(_:separator:terminator:to:)")
295+
public func debugPrint<Target : TextOutputStream>(
296+
_ items: Any...,
297+
separator: String = "",
298+
terminator: String = "",
299+
toStream output: inout Target
300+
) {}
301+
286302
@available(*, unavailable, message: "Please use 'terminator: \"\"' instead of 'appendNewline: false': 'print((...), terminator: \"\")'")
287303
public func print<T>(_: T, appendNewline: Bool = true) {}
288304
@available(*, unavailable, message: "Please use 'terminator: \"\"' instead of 'appendNewline: false': 'debugPrint((...), terminator: \"\")'")

test/1_stdlib/Renames.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,15 @@ func _Policy() {
334334
func fn<O : BitwiseOperationsType>(_: O) {} // expected-error {{'BitwiseOperationsType' has been renamed to 'BitwiseOperations'}} {{15-36=BitwiseOperations}} {{none}}
335335
}
336336

337+
func _Print<T, O : TextOutputStream>(x: T, out: O) {
338+
var out = out
339+
print(x, toStream: &out) // expected-error {{'print(_:separator:terminator:toStream:)' has been renamed to 'print(_:separator:terminator:to:)'}} {{3-8=print}} {{12-20=to}} {{none}}
340+
print(x, x, separator: "/", toStream: &out) // expected-error {{'print(_:separator:terminator:toStream:)' has been renamed to 'print(_:separator:terminator:to:)'}} {{3-8=print}} {{31-39=to}} {{none}}
341+
print(terminator: "|", toStream: &out) // expected-error {{'print(_:separator:terminator:toStream:)' has been renamed to 'print(_:separator:terminator:to:)'}} {{3-8=print}} {{26-34=to}} {{none}}
342+
print(x, separator: "*", terminator: "$", toStream: &out) // expected-error {{'print(_:separator:terminator:toStream:)' has been renamed to 'print(_:separator:terminator:to:)'}} {{3-8=print}} {{45-53=to}} {{none}}
343+
debugPrint(x, toStream: &out) // expected-error {{'debugPrint(_:separator:terminator:toStream:)' has been renamed to 'debugPrint(_:separator:terminator:to:)'}} {{3-13=debugPrint}} {{17-25=to}} {{none}}
344+
}
345+
337346
func _Print<T>(x: T) {
338347
print(x, appendNewline: true) // expected-error {{'print(_:appendNewline:)' is unavailable: Please use 'terminator: ""' instead of 'appendNewline: false': 'print((...), terminator: "")'}} {{none}}
339348
debugPrint(x, appendNewline: true) // expected-error {{'debugPrint(_:appendNewline:)' is unavailable: Please use 'terminator: ""' instead of 'appendNewline: false': 'debugPrint((...), terminator: "")'}} {{none}}

0 commit comments

Comments
 (0)