blob: a6c8100d0d3119474452c7e627810b229aa5437b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package codescan
import (
"fmt"
"go/types"
)
type Error string
func (e Error) Error() string {
return string(e)
}
const (
ErrInternal Error = "internal error due to a bug or a mishandling of go types AST. This usually indicates a bug in the scanner"
)
// code assertions to be explicit about the various expectations when entering a function
func mustNotBeABuiltinType(o *types.TypeName) {
if o.Pkg() != nil {
return
}
panic(fmt.Errorf("type %q expected not to be a builtin: %w", o.Name(), ErrInternal))
}
func mustHaveRightHandSide(a *types.Alias) {
if a.Rhs() != nil {
return
}
panic(fmt.Errorf("type alias %q expected to declare a right-hand-side: %w", a.Obj().Name(), ErrInternal))
}
|