Skip to content

Commit

Permalink
add test case for uppercase inner member
Browse files Browse the repository at this point in the history
  • Loading branch information
nishanths committed Nov 19, 2021
1 parent 7596586 commit c61cda0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
9 changes: 6 additions & 3 deletions exhaustive.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ denoting constants (e.g. somepkg.Grassland) listed in a switch statement's cases
can contribute towards satisfying exhaustiveness. Literal values, struct fields,
re-assignable variables, etc. will not.
The analyzer will produce a diagnostic about unhandled enum members if the
required memebers are not listed in a switch statement's cases (this applies
even if the switch statement has a 'default' case).
Type aliases
The analyzer handles type aliases for an enum type in the following manner.
Expand Down Expand Up @@ -248,11 +252,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
exportFact(pass, typ, members)
}

cfg := config{
checkSwitchStatements(pass, inspect, config{
defaultSignifiesExhaustive: fDefaultSignifiesExhaustive,
checkGeneratedFiles: fCheckGenerated,
ignoreEnumMembers: fIgnoreEnumMembers.value(),
}
checkSwitchStatements(pass, inspect, cfg)
})
return nil, nil
}
6 changes: 6 additions & 0 deletions testdata/src/general/x/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,9 @@ func _r(d Direction) {
case 5:
}
}

func _s(u bar.Uppercase) {
switch u {
case bar.ReallyExported:
}
}
8 changes: 8 additions & 0 deletions testdata/src/general/y/y.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ const (
)

type IntWrapper int

type Uppercase int // want Uppercase:"^ReallyExported$"
const ReallyExported Uppercase = 1

func f() {
type AliasForUppercase = Uppercase
const NotReallyExported AliasForUppercase = 2 // not exported, and in fact not even a member of enum type Uppercase
}

0 comments on commit c61cda0

Please sign in to comment.