Unfortunately, in the general case, it is. If self is an object, then it's trivial to detect as you can use ===. However, if self is a value type, then === is not available, and to my knowledge there's no way to detect that.
In "Alternatives considered", I supplied a possible alternative which would let this work generally. I didn't include a code snippet but imagine that PlaygroundSupport provided a DefaultPlaygroundDisplay<T>:
extension MyType: CustomPlaygroundDisplayConvertible {
var playgroundDescription: Any {
return DefaultPlaygroundDisplay(self)
}
}
I didn't include that in this proposal, as it seems like an enhancement which can come later. I'll turn this around: if a type is already a "core type" (either directly or via subclassing), then it's not required that you override CustomPlaygroundDisplayConvertible to get it to display as that "core type". What's the benefit to being able to include an empty implementation of CustomPlaygroundDisplayConvertible before it wants to be customized? (Do you frequently implement CustomStringConvertible but have it return the "default" value, knowing you'll come back to it later?)
Not quite sure I understand the question -- the rules in general for playground logging aren't changing as part of this proposal. To put it in PlaygroundLogger terms, if you return an array containing an NSLocalizedString and an NSColor, it'll generate:
LogEntry.structured(…, children: [
LogEntry.opaque(…, payload: .attributedString(<data>)),
LogEntry.opaque(…, payload: .color(<data>))
])
The intent is that both foo and bar in the example below should produce identical playground displays:
let attrString: NSAttributedString = //...
let color: NSColor = // ...
extension MyType: CustomPlaygroundDisplayConvertible {
var playgroundDescription: Any {
return [attrStr, color]
}
}
let foo = MyType()
let bar = [attrStr, color]
OK, thanks for the feedback. (And I'm sorry for the churn -- but with ABI stability around the corner, we want to kill this actively harmful API and replace it with something better, hence this proposal.)