mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Factor parsing of pattern-tuple-element into its own routine.
This simple refactor makes pattern-tuple-element available for re-use in closure expressions. As a drive-by, diagnose non-final ellipses via diagnose() rather than via assert(), the latter being considered rather unfriendly. Also, take pains to restore AST invariants after such an error. Swift SVN r5163
This commit is contained in:
@@ -139,6 +139,8 @@ public:
|
||||
/// An element of a tuple pattern.
|
||||
class TuplePatternElt {
|
||||
Pattern *ThePattern;
|
||||
|
||||
// FIXME: Init and VarargBaseType can be collapsed into one field.
|
||||
ExprHandle *Init;
|
||||
Type VarargBaseType;
|
||||
|
||||
@@ -153,6 +155,13 @@ public:
|
||||
bool isVararg() const { return !VarargBaseType.isNull(); }
|
||||
Type getVarargBaseType() const { return VarargBaseType; }
|
||||
void setVarargBaseType(Type ty) { VarargBaseType = ty; }
|
||||
|
||||
/// \brief Revert this variadic tuple pattern element to a
|
||||
/// non-variadic version.
|
||||
///
|
||||
/// Used for error recovery, when we've detected that the element
|
||||
/// is not the last one.
|
||||
void revertToNonVariadic();
|
||||
};
|
||||
|
||||
/// A pattern consisting of a tuple of patterns.
|
||||
|
||||
Reference in New Issue
Block a user