Skip to content

Commit ea76627

Browse files
committed
Parse: Use TypeRepr * instead of DeclNameRef in a note that points to an extension
1 parent 8935acd commit ea76627

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,12 @@ ERROR(lex_conflict_marker_in_file,none,
196196
// MARK: Declaration parsing diagnostics
197197
//------------------------------------------------------------------------------
198198

199-
NOTE(note_in_decl_extension,none,
200-
"in %select{declaration|extension}0 of %1", (bool, DeclNameRef))
199+
NOTE(note_in_decl_of,none,
200+
"in declaration of %0", (DeclNameRef))
201+
NOTE(note_in_extension_of,none,
202+
"in extension of %0", (TypeRepr *))
201203
ERROR(line_directive_style_deprecated,none,
202-
"#line directive was renamed to #sourceLocation",
203-
())
204+
"#line directive was renamed to #sourceLocation", ())
204205

205206
ERROR(declaration_same_line_without_semi,none,
206207
"consecutive declarations on a line must be separated by ';'", ())

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4948,13 +4948,12 @@ Parser::parseDecl(ParseDeclOptions Flags,
49484948

49494949
if (CurDeclContext) {
49504950
if (auto nominal = dyn_cast<NominalTypeDecl>(CurDeclContext)) {
4951-
diagnose(nominal->getLoc(), diag::note_in_decl_extension, false,
4951+
diagnose(nominal->getLoc(), diag::note_in_decl_of,
49524952
nominal->createNameRef());
49534953
} else if (auto extension = dyn_cast<ExtensionDecl>(CurDeclContext)) {
49544954
if (auto repr = extension->getExtendedTypeRepr()) {
49554955
if (auto idRepr = dyn_cast<IdentTypeRepr>(repr)) {
4956-
diagnose(extension->getLoc(), diag::note_in_decl_extension, true,
4957-
idRepr->getComponentRange().front()->getNameRef());
4956+
diagnose(extension->getLoc(), diag::note_in_extension_of, idRepr);
49584957
}
49594958
}
49604959
}

test/Parse/recovery.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,3 +874,10 @@ func testSkipToFindOpenBrace1() {
874874
func testSkipToFindOpenBrace2() {
875875
do { if true {} else false } // expected-error {{expected '{' or 'if' after 'else'}}
876876
}
877+
878+
struct Outer {
879+
struct Inner<T> {}
880+
}
881+
extension Outer.Inner<Never> { // expected-note {{in extension of 'Outer.Inner<Never>'}}
882+
@someAttr
883+
} // expected-error {{expected declaration}}

test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
key.column: 8,
8484
key.filepath: syntaxmap-edit-del.swift,
8585
key.severity: source.diagnostic.severity.note,
86-
key.id: "note_in_decl_extension",
86+
key.id: "note_in_decl_of",
8787
key.description: "in declaration of 'Foo'"
8888
}
8989
]

0 commit comments

Comments
 (0)