Hi,
Just looking into a frustrating case with protocols and wondering if this would be a good pitch for a language change.
When using optionals in a protocol, conformers who’s optional type is implicitly unwrapped causes an error in the compiler.
Eg:
protocol TextEntryView {
var text: String?
}
// This works.
class UITextField: TextEntryView {}
// This doesn't work because it's declaration has `text: String!`
class UITextView: TextEntryView {}
Given the content of SE-0054 which abolishes the implicitly unwrapped type and making it optional with an implicit unwrapping behavior, should we allow protocol conformance where the conformers optional type is implicitly unwrapped?
I can see good reason for avoiding this where the protocol declares implicit unwrapping and the conformer has a standard optional due to safety reasons, but vice versa has no such issues.
Thoughts?
3 Likes
masters3d
(Chéyo Jiménez)
2
Just out of curiosity, are you using a 4.2 toolchain? (Same error when develop toolchain?) If so, this seems more like bug report to me.
1 Like
I tried this on the latest 4.2 and master snapshots, yes.
Rod_Brown
(Rod Brown)
4
Moved this thread to Using Swift.
Can anyone flag whether this is a bug, and if so, is it tracked or should I raise a bug for it?