Skip to content

Commit 0446ad3

Browse files
committed
Fix failing test cases for expected_keyword_in_decl diagnostic
1 parent 2b3ebf7 commit 0446ad3

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,15 +3014,15 @@ Parser::parseDecl(ParseDeclOptions Flags,
30143014
DescriptiveDeclKind DescriptiveKind;
30153015

30163016
switch (StaticSpelling) {
3017-
case StaticSpellingKind::None:
3018-
DescriptiveKind = DescriptiveDeclKind::Property;
3019-
break;
3020-
case StaticSpellingKind::KeywordStatic:
3021-
DescriptiveKind = DescriptiveDeclKind::StaticProperty;
3022-
break;
3023-
case StaticSpellingKind::KeywordClass:
3024-
llvm_unreachable("kw_class is only parsed as a modifier if it's "
3025-
"followed by a keyword");
3017+
case StaticSpellingKind::None:
3018+
DescriptiveKind = DescriptiveDeclKind::Property;
3019+
break;
3020+
case StaticSpellingKind::KeywordStatic:
3021+
DescriptiveKind = DescriptiveDeclKind::StaticProperty;
3022+
break;
3023+
case StaticSpellingKind::KeywordClass:
3024+
llvm_unreachable("kw_class is only parsed as a modifier if it's "
3025+
"followed by a keyword");
30263026
}
30273027

30283028
diagnose(Tok.getLoc(), diag::expected_keyword_in_decl, "var",
@@ -3043,15 +3043,15 @@ Parser::parseDecl(ParseDeclOptions Flags,
30433043
DescriptiveKind = DescriptiveDeclKind::OperatorFunction;
30443044
} else {
30453045
switch (StaticSpelling) {
3046-
case StaticSpellingKind::None:
3047-
DescriptiveKind = DescriptiveDeclKind::Method;
3048-
break;
3049-
case StaticSpellingKind::KeywordStatic:
3050-
DescriptiveKind = DescriptiveDeclKind::StaticMethod;
3051-
break;
3052-
case StaticSpellingKind::KeywordClass:
3053-
llvm_unreachable("kw_class is only parsed as a modifier if it's "
3054-
"followed by a keyword");
3046+
case StaticSpellingKind::None:
3047+
DescriptiveKind = DescriptiveDeclKind::Method;
3048+
break;
3049+
case StaticSpellingKind::KeywordStatic:
3050+
DescriptiveKind = DescriptiveDeclKind::StaticMethod;
3051+
break;
3052+
case StaticSpellingKind::KeywordClass:
3053+
llvm_unreachable("kw_class is only parsed as a modifier if it's "
3054+
"followed by a keyword");
30553055
}
30563056
}
30573057

test/Parse/diagnostic_missing_func_keyword.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,13 @@ class Baz {
5151

5252
static staticProperty: Int { 0 } // expected-error {{expected 'var' keyword in static property declaration}} {{10-10=var }}
5353
}
54+
55+
class C1 {
56+
class classMethod() {} // expected-error {{expected '{' in class}}
57+
}
58+
59+
class C2 {
60+
class classProperty: Int { 0 } // expected-error {{inheritance from non-protocol, non-class type 'Int'}}
61+
// expected-note @-1 {{in declaration of 'classProperty'}}
62+
// expected-error @-2 {{expected declaration}}
63+
}

test/SourceKit/DocumentStructure/structure.swift.empty.response

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@
14501450
key.line: 116,
14511451
key.column: 1,
14521452
key.severity: source.diagnostic.severity.error,
1453-
key.description: "expected 'func' keyword in function declaration",
1453+
key.description: "expected 'func' keyword in instance method declaration",
14541454
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
14551455
key.fixits: [
14561456
{

test/SourceKit/DocumentStructure/structure.swift.foobar.response

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@
14531453
key.column: 1,
14541454
key.filepath: "-foobar",
14551455
key.severity: source.diagnostic.severity.error,
1456-
key.description: "expected 'func' keyword in function declaration",
1456+
key.description: "expected 'func' keyword in instance method declaration",
14571457
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
14581458
key.fixits: [
14591459
{

test/SourceKit/DocumentStructure/structure.swift.response

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@
14531453
key.column: 1,
14541454
key.filepath: main.swift,
14551455
key.severity: source.diagnostic.severity.error,
1456-
key.description: "expected 'func' keyword in function declaration",
1456+
key.description: "expected 'func' keyword in instance method declaration",
14571457
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
14581458
key.fixits: [
14591459
{

0 commit comments

Comments
 (0)