Skip to content

Commit fe9fc26

Browse files
author
Nathan Hawes
authored
Merge pull request #31465 from nathawes/doc-info-availability-catalyst
[IDE] Loosen assertion check in IDE/SyntaxModelWalker
2 parents 717eeb9 + deecb58 commit fe9fc26

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/IDE/SyntaxModel.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,13 @@ bool ModelASTWalker::handleSpecialDeclAttribute(const DeclAttribute *D,
12141214
if (!passNode({SyntaxNodeKind::AttributeBuiltin, Next.Range}))
12151215
return false;
12161216
} else {
1217-
assert(0 && "Attribute's TokenNodes already consumed?");
1217+
// Only mispelled attributes, corrected in the AST but not
1218+
// recognised or present in TokenNodes should get us here.
1219+
// E.g. @availability(...) comes through as if @available(...) was
1220+
// specified, but there's no TokenNode because we don't highlight them
1221+
// (to indicate they're invalid).
1222+
assert(Next.Range.getStart() == D->getRange().Start &&
1223+
"Attribute's TokenNodes already consumed?");
12181224
}
12191225
} else {
12201226
assert(0 && "No TokenNodes?");

test/IDE/coloring.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,8 @@ struct FreeWhere<T> {
554554
// CHECK: <kw>typealias</kw> Alias = <type>Int</type> <kw>where</kw> <type>T</type> == <type>Int</type>
555555
typealias Alias = Int where T == Int
556556
}
557+
558+
// Renamed attribute ('fixed' to @available by the parser after emitting an error, so not treated as a custom attribute)
559+
// CHECK: @availability(<kw>macOS</kw> <float>10.11</float>, *)
560+
@availability(macOS 10.11, *)
561+
class HasMisspelledAttr {}

0 commit comments

Comments
 (0)