File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ denoting constants (e.g. somepkg.Grassland) listed in a switch statement's cases
48
48
can contribute towards satisfying exhaustiveness. Literal values, struct fields,
49
49
re-assignable variables, etc. will not.
50
50
51
+ The analyzer will produce a diagnostic about unhandled enum members if the
52
+ required memebers are not listed in a switch statement's cases (this applies
53
+ even if the switch statement has a 'default' case).
54
+
51
55
Type aliases
52
56
53
57
The analyzer handles type aliases for an enum type in the following manner.
@@ -248,11 +252,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
248
252
exportFact (pass , typ , members )
249
253
}
250
254
251
- cfg := config {
255
+ checkSwitchStatements ( pass , inspect , config {
252
256
defaultSignifiesExhaustive : fDefaultSignifiesExhaustive ,
253
257
checkGeneratedFiles : fCheckGenerated ,
254
258
ignoreEnumMembers : fIgnoreEnumMembers .value (),
255
- }
256
- checkSwitchStatements (pass , inspect , cfg )
259
+ })
257
260
return nil , nil
258
261
}
Original file line number Diff line number Diff line change @@ -187,3 +187,9 @@ func _r(d Direction) {
187
187
case 5 :
188
188
}
189
189
}
190
+
191
+ func _s (u bar.Uppercase ) {
192
+ switch u {
193
+ case bar .ReallyExported :
194
+ }
195
+ }
Original file line number Diff line number Diff line change @@ -10,3 +10,11 @@ const (
10
10
)
11
11
12
12
type IntWrapper int
13
+
14
+ type Uppercase int // want Uppercase:"^ReallyExported$"
15
+ const ReallyExported Uppercase = 1
16
+
17
+ func f () {
18
+ type AliasForUppercase = Uppercase
19
+ const NotReallyExported AliasForUppercase = 2 // not exported, and in fact not even a member of enum type Uppercase
20
+ }
You can’t perform that action at this time.
0 commit comments