Skip to content

Commit

Permalink
reduce indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
josharian committed Jan 16, 2024
1 parent 0b02767 commit cc2523e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,23 +424,24 @@ func typeSpec(path string, typ Type, srcDir string) (Pkg, Spec, error) {
// passed type, a nil map and false are returned. No type checking is done,
// only that there are sufficient types to match.
func matchTypeParams(spec *ast.TypeSpec, params []string) (map[string]string, bool) {
if spec.TypeParams == nil {
return nil, true
}
res := make(map[string]string, len(params))
if spec.TypeParams != nil {
var specParamNames []string
for _, typeParam := range spec.TypeParams.List {
for _, name := range typeParam.Names {
if name == nil {
continue
}
specParamNames = append(specParamNames, name.Name)
var specParamNames []string
for _, typeParam := range spec.TypeParams.List {
for _, name := range typeParam.Names {
if name == nil {
continue
}
specParamNames = append(specParamNames, name.Name)
}
if len(specParamNames) != len(params) {
return nil, false
}
for pos, specParamName := range specParamNames {
res[specParamName] = params[pos]
}
}
if len(specParamNames) != len(params) {
return nil, false
}
for pos, specParamName := range specParamNames {
res[specParamName] = params[pos]
}
return res, true
}
Expand Down

0 comments on commit cc2523e

Please sign in to comment.