File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,10 @@ class alignas(1 << TypeReprAlignInBits) TypeRepr
184
184
// / opaque return type reprs.
185
185
bool hasOpaque ();
186
186
187
+ // / Returns a Boolean value indicating whether this written type is
188
+ // / parenthesized, that is, matches the following grammar: `'(' type ')'`.
189
+ bool isParenType () const ;
190
+
187
191
// / Retrieve the type repr without any parentheses around it.
188
192
// /
189
193
// / The use of this function must be restricted to contexts where
Original file line number Diff line number Diff line change @@ -109,14 +109,18 @@ bool TypeRepr::hasOpaque() {
109
109
findIf ([](TypeRepr *ty) { return isa<OpaqueReturnTypeRepr>(ty); });
110
110
}
111
111
112
+ bool TypeRepr::isParenType () const {
113
+ auto *tuple = dyn_cast<TupleTypeRepr>(this );
114
+ return tuple && tuple->isParenType ();
115
+ }
116
+
112
117
TypeRepr *TypeRepr::getWithoutParens () const {
113
- auto *repr = const_cast <TypeRepr *>(this );
114
- while (auto *tupleRepr = dyn_cast<TupleTypeRepr>(repr)) {
115
- if (!tupleRepr->isParenType ())
116
- break ;
117
- repr = tupleRepr->getElementType (0 );
118
+ auto *result = this ;
119
+ while (result->isParenType ()) {
120
+ result = cast<TupleTypeRepr>(result)->getElementType (0 );
118
121
}
119
- return repr;
122
+
123
+ return const_cast <TypeRepr *>(result);
120
124
}
121
125
122
126
bool TypeRepr::isSimpleUnqualifiedIdentifier (Identifier identifier) const {
You can’t perform that action at this time.
0 commit comments