Skip to content

Commit c61cda0

Browse files
committed
add test case for uppercase inner member
1 parent 7596586 commit c61cda0

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

exhaustive.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ denoting constants (e.g. somepkg.Grassland) listed in a switch statement's cases
4848
can contribute towards satisfying exhaustiveness. Literal values, struct fields,
4949
re-assignable variables, etc. will not.
5050
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+
5155
Type aliases
5256
5357
The analyzer handles type aliases for an enum type in the following manner.
@@ -248,11 +252,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
248252
exportFact(pass, typ, members)
249253
}
250254

251-
cfg := config{
255+
checkSwitchStatements(pass, inspect, config{
252256
defaultSignifiesExhaustive: fDefaultSignifiesExhaustive,
253257
checkGeneratedFiles: fCheckGenerated,
254258
ignoreEnumMembers: fIgnoreEnumMembers.value(),
255-
}
256-
checkSwitchStatements(pass, inspect, cfg)
259+
})
257260
return nil, nil
258261
}

testdata/src/general/x/general.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,9 @@ func _r(d Direction) {
187187
case 5:
188188
}
189189
}
190+
191+
func _s(u bar.Uppercase) {
192+
switch u {
193+
case bar.ReallyExported:
194+
}
195+
}

testdata/src/general/y/y.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ const (
1010
)
1111

1212
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+
}

0 commit comments

Comments
 (0)