Skip to content

Commit a77336a

Browse files
committed
[stdlib] move the string check after the optional check below it. (swiftlang#15108)
1 parent 149e91e commit a77336a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

stdlib/public/core/OutputStream.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,6 @@ internal func _adHocPrint_unlocked<T, TargetStream : TextOutputStream>(
380380
internal func _print_unlocked<T, TargetStream : TextOutputStream>(
381381
_ value: T, _ target: inout TargetStream
382382
) {
383-
if let string = value as? String {
384-
target.write(string)
385-
return
386-
}
387383
// Optional has no representation suitable for display; therefore,
388384
// values of optional type should be printed as a debug
389385
// string. Check for Optional first, before checking protocol
@@ -394,6 +390,12 @@ internal func _print_unlocked<T, TargetStream : TextOutputStream>(
394390
debugPrintable.debugDescription.write(to: &target)
395391
return
396392
}
393+
394+
if let string = value as? String {
395+
target.write(string)
396+
return
397+
}
398+
397399
if case let streamableObject as TextOutputStreamable = value {
398400
streamableObject.write(to: &target)
399401
return

0 commit comments

Comments
 (0)