@@ -31,16 +31,14 @@ type TypeChecker interface {
3131}
3232
3333// NewTypeChecker returns a new TypeChecker with the provided checkFunc.
34- func NewTypeChecker (isTypeFunc func (pass * analysis.Pass , ident ast. Expr ) bool , checkFunc func ( pass * analysis. Pass , expr ast.Expr , node ast.Node , prefix string )) TypeChecker {
34+ func NewTypeChecker (checkFunc func (pass * analysis.Pass , ident * ast.Ident , node ast.Node , qualifiedFieldName string )) TypeChecker {
3535 return & typeChecker {
36- isTypeFunc : isTypeFunc ,
37- checkFunc : checkFunc ,
36+ checkFunc : checkFunc ,
3837 }
3938}
4039
4140type typeChecker struct {
42- isTypeFunc func (pass * analysis.Pass , expr ast.Expr ) bool
43- checkFunc func (pass * analysis.Pass , expr ast.Expr , node ast.Node , prefix string )
41+ checkFunc func (pass * analysis.Pass , ident * ast.Ident , node ast.Node , qualifiedFieldName string )
4442}
4543
4644// CheckNode checks the provided node for built-in types.
@@ -86,11 +84,6 @@ func (t *typeChecker) checkTypeSpec(pass *analysis.Pass, tSpec *ast.TypeSpec, no
8684}
8785
8886func (t * typeChecker ) checkTypeExpr (pass * analysis.Pass , typeExpr ast.Expr , node ast.Node , prefix string ) {
89- if t .isTypeFunc (pass , typeExpr ) {
90- t .checkFunc (pass , typeExpr , node , prefix )
91- return
92- }
93-
9487 switch typ := typeExpr .(type ) {
9588 case * ast.Ident :
9689 t .checkIdent (pass , typ , node , prefix )
@@ -109,6 +102,12 @@ func (t *typeChecker) checkTypeExpr(pass *analysis.Pass, typeExpr ast.Expr, node
109102// checkIdent calls the checkFunc with the ident, when we have hit a built-in type.
110103// If the ident is not a built in, we look at the underlying type until we hit a built-in type.
111104func (t * typeChecker ) checkIdent (pass * analysis.Pass , ident * ast.Ident , node ast.Node , prefix string ) {
105+ if IsBasicType (pass , ident ) {
106+ // We've hit a built-in type, no need to check further.
107+ t .checkFunc (pass , ident , node , prefix )
108+ return
109+ }
110+
112111 tSpec , ok := LookupTypeSpec (pass , ident )
113112 if ! ok {
114113 return
0 commit comments