You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless I'm missing something, the code below indicates we could, effectively, generate a protocol the first time someone uses `Self` in a class in a way that is currently prohibited.
classX {
finalfuncf(_: Self) {} // Can't use Self here!
}
// Okay, I'll do something equivalent, then!classY : YProtocol {}
protocolYProtocol : Y {}
extensionYProtocol {
funcf(_: Self) {} // Works fine.
}
The text was updated successfully, but these errors were encountered:
Those two Self identifiers aren't equivalent. :-( The one in the class is the dynamic type, implying that if someone subclasses X, they can only call f on that subclass with another instance of the same subclass. In the protocol case, it's the type that originally conformed to the protocol, which is Y, and any subclass instances will get upcasted to Y when calling f.
Additional Detail from JIRA
md5: db5b1fdcc8d8bafd0a998853cf91e790
Issue Description:
Unless I'm missing something, the code below indicates we could, effectively, generate a protocol the first time someone uses `Self` in a class in a way that is currently prohibited.
The text was updated successfully, but these errors were encountered: