Skip to content

Commit a2aacd7

Browse files
committed
[stdlib] Deprecated PlaygroundQuickLook and CustomPlaygroundQuickLookable.
Deprecated the `PlaygroundQuickLook` enum and `CustomPlaygroundQuickLookable` protocol. These are being targeted for removal in Swift 5, so we want to unconditionally deprecate them now to encourage use of `CustomPlaygroundDisplayConvertible` instead. This commit includes deprecated the various `CustomPlaygroundQuickLookable` conformances across the standard library and overlay libraries.
1 parent 4c41c12 commit a2aacd7

18 files changed

+24
-0
lines changed

stdlib/public/SDK/AppKit/AppKit.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Foundation
1414
@_exported import AppKit
1515

1616
extension NSCursor : _DefaultCustomPlaygroundQuickLookable {
17+
@available(*, deprecated, message: "NSCursor._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
1718
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
1819
return .image(image)
1920
}
@@ -24,6 +25,7 @@ internal struct _NSViewQuickLookState {
2425
}
2526

2627
extension NSView : _DefaultCustomPlaygroundQuickLookable {
28+
@available(*, deprecated, message: "NSView._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
2729
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
2830
// if you set NSView.needsDisplay, you can get yourself in a recursive scenario where the same view
2931
// could need to draw itself in order to get a QLObject for itself, which in turn if your code was

stdlib/public/SDK/CoreGraphics/CoreGraphics.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ extension CGPoint : CustomReflectable, CustomPlaygroundQuickLookable {
232232
return Mirror(self, children: ["x": x, "y": y], displayStyle: .`struct`)
233233
}
234234

235+
@available(*, deprecated, message: "CGPoint.customPlaygroundQuickLook will be removed in a future Swift version")
235236
public var customPlaygroundQuickLook: PlaygroundQuickLook {
236237
return .point(Double(x), Double(y))
237238
}
@@ -299,6 +300,7 @@ extension CGSize : CustomReflectable, CustomPlaygroundQuickLookable {
299300
displayStyle: .`struct`)
300301
}
301302

303+
@available(*, deprecated, message: "CGSize.customPlaygroundQuickLook will be removed in a future Swift version")
302304
public var customPlaygroundQuickLook: PlaygroundQuickLook {
303305
return .size(Double(width), Double(height))
304306
}
@@ -436,6 +438,7 @@ extension CGRect : CustomReflectable, CustomPlaygroundQuickLookable {
436438
displayStyle: .`struct`)
437439
}
438440

441+
@available(*, deprecated, message: "CGRect.customPlaygroundQuickLook will be removed in a future Swift version")
439442
public var customPlaygroundQuickLook: PlaygroundQuickLook {
440443
return .rectangle(
441444
Double(origin.x), Double(origin.y),

stdlib/public/SDK/Foundation/Date.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ extension Date : CustomPlaygroundQuickLookable {
280280
return df.string(from: self)
281281
}
282282

283+
@available(*, deprecated, message: "Date.customPlaygroundQuickLook will be removed in a future Swift version")
283284
public var customPlaygroundQuickLook: PlaygroundQuickLook {
284285
return .text(summary)
285286
}

stdlib/public/SDK/Foundation/NSDate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extension NSDate : CustomPlaygroundQuickLookable {
2121
return df.string(from: self as Date)
2222
}
2323

24+
@available(*, deprecated, message: "NSDate.customPlaygroundQuickLook will be removed in a future Swift version")
2425
public var customPlaygroundQuickLook: PlaygroundQuickLook {
2526
return .text(summary)
2627
}

stdlib/public/SDK/Foundation/NSRange.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ extension NSRange : CustomReflectable {
198198
}
199199

200200
extension NSRange : CustomPlaygroundQuickLookable {
201+
@available(*, deprecated, message: "NSRange.customPlaygroundQuickLook will be removed in a future Swift version")
201202
public var customPlaygroundQuickLook: PlaygroundQuickLook {
202203
return .range(Int64(location), Int64(length))
203204
}

stdlib/public/SDK/Foundation/NSString.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ extension NSString {
113113
}
114114

115115
extension NSString : CustomPlaygroundQuickLookable {
116+
@available(*, deprecated, message: "NSString.customPlaygroundQuickLook will be removed in a future Swift version")
116117
public var customPlaygroundQuickLook: PlaygroundQuickLook {
117118
return .text(self as String)
118119
}

stdlib/public/SDK/Foundation/NSURL.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
@_exported import Foundation // Clang module
1414

1515
extension NSURL : CustomPlaygroundQuickLookable {
16+
@available(*, deprecated, message: "NSURL.customPlaygroundQuickLook will be removed in a future Swift version")
1617
public var customPlaygroundQuickLook: PlaygroundQuickLook {
1718
guard let str = absoluteString else { return .text("Unknown URL") }
1819
return .url(str)

stdlib/public/SDK/Foundation/URL.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ extension NSURL : _HasCustomAnyHashableRepresentation {
12021202
}
12031203

12041204
extension URL : CustomPlaygroundQuickLookable {
1205+
@available(*, deprecated, message: "URL.customPlaygroundQuickLook will be removed in a future Swift version")
12051206
public var customPlaygroundQuickLook: PlaygroundQuickLook {
12061207
return .url(absoluteString)
12071208
}

stdlib/public/SDK/SpriteKit/SpriteKitQuickLooks.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
% for Self in ['SKShapeNode', 'SKSpriteNode', 'SKTextureAtlas', 'SKTexture']:
1616

1717
extension ${Self} : CustomPlaygroundQuickLookable {
18+
@available(*, deprecated, message: "${Self}.customPlaygroundQuickLook will be removed in a future Swift version")
1819
public var customPlaygroundQuickLook: PlaygroundQuickLook {
1920
let data = (self as AnyObject)._copyImageData?() as Data?
2021

stdlib/public/SDK/UIKit/UIKit.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ internal struct _UIViewQuickLookState {
231231
}
232232

233233
extension UIView : _DefaultCustomPlaygroundQuickLookable {
234+
@available(*, deprecated, message: "UIView._defaultCustomPlaygroundQuickLook will be removed in a future Swift version")
234235
public var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook {
235236
if _UIViewQuickLookState.views.contains(self) {
236237
return .view(UIImage())

stdlib/public/core/Mirror.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ internal extension Mirror {
662662

663663
/// The sum of types that can be used as a Quick Look representation.
664664
@_fixed_layout // FIXME(sil-serialize-all)
665+
@available(*, deprecated, message: "PlaygroundQuickLook will be removed in a future Swift version. For customizing how types are presented in playgrounds, use CustomPlaygroundDisplayConvertible instead.")
665666
public enum PlaygroundQuickLook {
666667
/// Plain text.
667668
case text(String)
@@ -748,6 +749,7 @@ extension PlaygroundQuickLook {
748749
/// - Parameter subject: The instance to represent with the resulting Quick
749750
/// Look.
750751
@_inlineable // FIXME(sil-serialize-all)
752+
@available(*, deprecated, message: "PlaygroundQuickLook will be removed in a future Swift version.")
751753
public init(reflecting subject: Any) {
752754
if let customized = subject as? CustomPlaygroundQuickLookable {
753755
self = customized.customPlaygroundQuickLook
@@ -773,6 +775,7 @@ extension PlaygroundQuickLook {
773775
/// with the representation supplied for your type by default, you can make it
774776
/// conform to the `CustomPlaygroundQuickLookable` protocol and provide a
775777
/// custom `PlaygroundQuickLook` instance.
778+
@available(*, deprecated, message: "CustomPlaygroundQuickLookable will be removed in a future Swift version. For customizing how types are presented in playgrounds, use CustomPlaygroundDisplayConvertible instead.")
776779
public protocol CustomPlaygroundQuickLookable {
777780
/// A custom playground Quick Look for this instance.
778781
///
@@ -784,6 +787,7 @@ public protocol CustomPlaygroundQuickLookable {
784787

785788
// A workaround for <rdar://problem/26182650>
786789
// FIXME(ABI)#50 (Dynamic Dispatch for Class Extensions) though not if it moves out of stdlib.
790+
@available(*, deprecated, message: "_DefaultCustomPlaygroundQuickLookable will be removed in a future Swift version. For customizing how types are presented in playgrounds, use CustomPlaygroundDisplayConvertible instead.")
787791
public protocol _DefaultCustomPlaygroundQuickLookable {
788792
var _defaultCustomPlaygroundQuickLook: PlaygroundQuickLook { get }
789793
}

stdlib/public/core/Mirrors.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extension ${Type[0]} : CustomReflectable {
4848
extension ${Type[0]} : CustomPlaygroundQuickLookable {
4949
/// A custom playground Quick Look for the `${Type[0]}` instance.
5050
@_inlineable // FIXME(sil-serialize-all)
51+
@available(*, deprecated, message: "${Type[0]}.customPlaygroundQuickLook will be removed in a future Swift version")
5152
public var customPlaygroundQuickLook: PlaygroundQuickLook {
5253
return ${Type[1]}(${Type[2]})
5354
}

stdlib/public/core/StringUTF16.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ extension String.UTF16View : CustomReflectable {
447447

448448
extension String.UTF16View : CustomPlaygroundQuickLookable {
449449
@_inlineable // FIXME(sil-serialize-all)
450+
@available(*, deprecated, message: "UTF16View.customPlaygroundQuickLook will be removed in a future Swift version")
450451
public var customPlaygroundQuickLook: PlaygroundQuickLook {
451452
return .text(description)
452453
}

stdlib/public/core/StringUTF8.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ extension String.UTF8View : CustomReflectable {
634634

635635
extension String.UTF8View : CustomPlaygroundQuickLookable {
636636
@_inlineable // FIXME(sil-serialize-all)
637+
@available(*, deprecated, message: "UTF8View.customPlaygroundQuickLook will be removed in a future Swift version")
637638
public var customPlaygroundQuickLook: PlaygroundQuickLook {
638639
return .text(description)
639640
}

stdlib/public/core/StringUnicodeScalarView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ extension String.UnicodeScalarView : CustomReflectable {
544544

545545
extension String.UnicodeScalarView : CustomPlaygroundQuickLookable {
546546
@_inlineable // FIXME(sil-serialize-all)
547+
@available(*, deprecated, message: "UnicodeScalarView.customPlaygroundQuickLook will be removed in a future Swift version")
547548
public var customPlaygroundQuickLook: PlaygroundQuickLook {
548549
return .text(description)
549550
}

stdlib/public/core/Substring.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ extension Substring : CustomReflectable {
338338

339339
extension Substring : CustomPlaygroundQuickLookable {
340340
@_inlineable // FIXME(sil-serialize-all)
341+
@available(*, deprecated, message: "Substring.customPlaygroundQuickLook will be removed in a future Swift version")
341342
public var customPlaygroundQuickLook: PlaygroundQuickLook {
342343
return String(self).customPlaygroundQuickLook
343344
}

stdlib/public/core/UnsafePointer.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ extension ${Self} : CustomPlaygroundQuickLookable {
10041004
}
10051005

10061006
@_inlineable // FIXME(sil-serialize-all)
1007+
@available(*, deprecated, message: "${Self}.customPlaygroundQuickLook will be removed in a future Swift version")
10071008
public var customPlaygroundQuickLook: PlaygroundQuickLook {
10081009
return .text(summary)
10091010
}

stdlib/public/core/UnsafeRawPointer.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ extension Unsafe${Mutable}RawPointer : CustomReflectable {
996996
extension Unsafe${Mutable}RawPointer : CustomPlaygroundQuickLookable {
997997
@_inlineable // FIXME(sil-serialize-all)
998998
@_versioned // FIXME(sil-serialize-all)
999+
@available(*, deprecated, message: "Unsafe${Mutable}RawPointer.customPlaygroundQuickLook will be removed in a future Swift version")
9991000
internal var summary: String {
10001001
let selfType = "${Self}"
10011002
let ptrValue = UInt64(

0 commit comments

Comments
 (0)