Skip to content

Commit d95fbf9

Browse files
committed
udpate test
1 parent 1acbf56 commit d95fbf9

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lib/Sema/TypeCheckSwitchStmt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,8 @@ namespace {
939939
}
940940
}
941941

942-
Ctx.Diags.diagnose(StartLoc, diag::non_exhaustive_switch),
943-
Ctx.Diags.diagnose(StartLoc, diag::missing_several_cases, false)
942+
Ctx.Diags.diagnose(StartLoc, diag::non_exhaustive_switch);
943+
Ctx.Diags.diagnose(EndLoc, diag::missing_several_cases, false)
944944
.fixItInsert(EndLoc, Buffer.str());
945945
} else {
946946
Ctx.Diags.diagnose(StartLoc, diag::non_exhaustive_switch);

test/stmt/switch_stmt1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ enum E {
66
}
77

88
func foo1(e : E, i : Int) {
9-
switch e {} // expected-error{{switch must be exhaustive, consider adding missing cases:}}
9+
switch e {} // expected-error{{switch must be exhaustive}}
1010
// expected-note@-1 {{missing case: '.e1'}}
1111
// expected-note@-2 {{missing case: '.e2'}}
1212
switch i {} // expected-error{{'switch' statement body must have at least one 'case' or 'default' block; do you want to add a default case?}}{{13-13=default: <#code#>\n}}

test/stmt/switch_stmt2.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ enum E {
66
}
77

88
func foo1(e : E) {
9-
switch e { // expected-error{{switch must be exhaustive, consider adding missing cases:}}
10-
// expected-note@-1 {{missing case: '.e2'}}
9+
switch e { // expected-error{{switch must be exhaustive}}
10+
// expected-note@-1 {{add missing case: '.e2'}}
1111
case .e1: return
1212
}
1313
}
1414

1515
func foo2(i : Int) {
16-
switch i { // expected-error{{switch must be exhaustive, consider adding a default clause}}{{3-3=default: <#code#>\n}}
16+
switch i { // expected-error{{switch must be exhaustive}}
17+
// expected-note@-1{{do you want to add a default clause?}}{{3-3=default: <#code#>\n}}
1718
case 1: return
1819
}
1920
}
@@ -75,7 +76,7 @@ func testSwitchOptionalBool(_ b: Bool?, xi: Int) -> Int {
7576
}
7677

7778
switch b { // expected-error{{switch must be exhaustive}}
78-
// expected-note@-1 {{missing case: '.some(false)'}}
79+
// expected-note@-1 {{add missing case: '.some(false)'}}
7980
case .some(true):
8081
x += 1
8182
case .none:
@@ -97,15 +98,15 @@ func testSwitchEnumBoolTuple(_ b1: Bool, b2: Bool, xi: Int) -> Int {
9798
}
9899

99100
switch Cond { // expected-error{{switch must be exhaustive}}
100-
// expected-note@-1 {{missing case: '(false, _)'}}
101-
// expected-note@-2 {{missing case: '(_, false)'}}
101+
// expected-note@-1 {{add missing case: '(false, _)'}}
102+
// expected-note@-2 {{add missing case: '(_, false)'}}
102103
case (true, true):
103104
x += 1
104105
}
105106

106107
switch Cond { // expected-error{{switch must be exhaustive}}
107-
// expected-note@-1 {{missing case: '(true, _)'}}
108-
// expected-note@-2 {{missing case: '(_, false)'}}
108+
// expected-note@-1 {{add missing case: '(true, _)'}}
109+
// expected-note@-2 {{add missing case: '(_, false)'}}
109110
case (false, true):
110111
x += 1
111112
}
@@ -126,7 +127,8 @@ func testSwitchEnumBoolTuple(_ b1: Bool, b2: Bool, xi: Int) -> Int {
126127

127128
func non_fully_covered_switch(x: Int) -> Int {
128129
var x = x
129-
switch x { // expected-error{{switch must be exhaustive, consider adding a default clause:}}
130+
switch x { // expected-error{{switch must be exhaustive}}
131+
// expected-note@-1{{do you want to add a default clause?}}
130132
case 0:
131133
x += 1
132134
case 3:

0 commit comments

Comments
 (0)