Awesome icon indicating copy to clipboard operation
Awesome copied to clipboard

Make Amazing implement CustomStringConvertible somehow

Open ghowen opened this issue 6 years ago • 1 comments

This one is beyond me: Amazing uses String(describing: self) in the computed property description. When I try to make Amazing implement CustomStringConvertible, the compiler does not complain, but I run into a BAD EXEC at runtime.

It looks like as this overwrites the default implementation, which I need to access to get the description.

If someone is smart enough to find a way to achieve this, this would be great, as we already are compliant to the protocol. I just don't know how to express this.

I also tried to use String(reflecting: self) in the computed description property instead but this also gives a BAD EXEC at runtime.

ghowen avatar Oct 30 '18 18:10 ghowen

It does not overwrite the default implementation. String(describing: self) simply checks if self conforms to CustomStringConvertible and if it does it will use self.description therefore we will run into a loop resulting in BAD_EXEC.

If self does not conform to CustomStringConvertible, CustomDebugStringConvertible or TextOutputStreamable it will use the Swift Standard Library implementation. I'm unsure if we can (or even should) use the Swift Standard Library implementation directly as it uses internal functions.

divadretlaw avatar Oct 30 '18 22:10 divadretlaw