Skip to content

Commit 7ed8a07

Browse files
authored
Merge pull request #4295 from rintaro/swift3-print-fixit
[swift-3.0-branch] stdlib: Add unavailable declarations with fix-it for 'print' and 'debugPrint'
2 parents e391105 + 4886790 commit 7ed8a07

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
@@ -281,6 +281,22 @@ internal func _debugPrint<Target : TextOutputStream>(
281281
//===----------------------------------------------------------------------===//
282282
//===--- Migration Aids ---------------------------------------------------===//
283283

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