Skip to content

Commit 5eea13e

Browse files
committed
Improve closure lookahead for custom attributes
1 parent 0760739 commit 5eea13e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/AST/NameLookup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,7 @@ CustomAttrNominalRequest::evaluate(Evaluator &evaluator,
26252625
}
26262626

26272627
ctx.Diags.diagnose(attr->getLocation(), diag::unknown_attribute, typeName);
2628+
attr->setInvalid();
26282629

26292630
return nullptr;
26302631
}

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,11 +5856,10 @@ void Parser::skipSILUntilSwiftDecl() {
58565856

58575857
void Parser::skipAnyAttribute() {
58585858
consumeToken(tok::at_sign);
5859-
if (!consumeIf(tok::identifier))
5859+
if (!Tok.is(tok::identifier))
58605860
return;
58615861

5862-
if (consumeIf(tok::l_paren))
5863-
skipUntil(tok::r_paren);
5862+
(void)canParseCustomAttribute();
58645863
}
58655864

58665865
/// Returns a descriptive name for the given accessor/addressor kind.

lib/Sema/TypeCheckType.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,10 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
21122112
if (globalActorAttr == customAttr)
21132113
continue;
21142114

2115+
// If this attribute was marked invalid, ignore it.
2116+
if (customAttr->isInvalid())
2117+
continue;
2118+
21152119
// Diagnose the attribute, because we don't yet handle custom type
21162120
// attributes.
21172121
std::string typeName;
@@ -2123,6 +2127,7 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
21232127
}
21242128

21252129
diagnose(customAttr->getLocation(), diag::unknown_attribute, typeName);
2130+
customAttr->setInvalid();
21262131
}
21272132

21282133
// The type we're working with, in case we want to build it differently

0 commit comments

Comments
 (0)