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
SR-8776 Confusing error with broken CaseIterable conformance
SR-8777 CaseIterable synthesis should work in the presence of a manual AllCases typealias
relates to:
SR-8776 Confusing error with broken CaseIterable conformance
SR-8777 CaseIterable synthesis should work in the presence of a manual AllCases typealias
Issue Description:
Crasher
// error.swiftenumDirections : CaseIterable {
casenorthcasesouth// The user customized the `AllCases` requirement but not `allCases`.typealiasAllCases = UnsafeBufferPointer<Directions>
}
The condition for deriving conformances to CaseIterable currently doesn't take into account whether other requirements have been user-defined/customized. (This is true for all derived conformances, in general.)
The code synthesis for allCases creates an ArrayExpr (from this commit). This is problematic if AllCases is defined to be a collection that is not ExpressibleByArrayLiteral, as in the crasher program above.
Possible solutions
One solution is to "can derive conformances" condition for CaseIterable so that synthesis is possible only if no requirements have been user-customized. It may be useful to generalize this condition for all protocol derived conformances though - I think it's common that synthesis is intended only when no requirements are customized.
Another solution is to change the synthesis condition to account for whether AllCases conforms to ExpressibleByArrayLiteral. This seems like a weird, undocumented "point of customization" for users though.
The text was updated successfully, but these errors were encountered:
Environment
Reproducible from this commit on master: 0d4a585
Additional Detail from JIRA
md5: 04cbf9b825ea59a4ae32fe7c39ff9815
duplicates:
relates to:
Issue Description:
Crasher
Error:
Explanation
CaseIterable
has two requirements:The condition for deriving conformances to
CaseIterable
currently doesn't take into account whether other requirements have been user-defined/customized. (This is true for all derived conformances, in general.)The code synthesis for
allCases
creates anArrayExpr
(from this commit). This is problematic ifAllCases
is defined to be a collection that is notExpressibleByArrayLiteral
, as in the crasher program above.Possible solutions
One solution is to "can derive conformances" condition for
CaseIterable
so that synthesis is possible only if no requirements have been user-customized. It may be useful to generalize this condition for all protocol derived conformances though - I think it's common that synthesis is intended only when no requirements are customized.Another solution is to change the synthesis condition to account for whether
AllCases
conforms toExpressibleByArrayLiteral
. This seems like a weird, undocumented "point of customization" for users though.The text was updated successfully, but these errors were encountered: