Skip to content

Commit

Permalink
fix sizegen so it handles type aliases
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Aug 26, 2024
1 parent e6843dc commit f1231a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion go/tools/sizegen/sizegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,23 @@ func (sizegen *sizegen) generateType(pkg *types.Package, file *codeFile, named *
case *types.Interface:
findImplementations(pkg.Scope(), tt, func(tt types.Type) {
if _, isStruct := tt.Underlying().(*types.Struct); isStruct {
sizegen.generateKnownType(tt.(*types.Named))
sizegen.generateTyp(tt)
}
})
default:
// no-op
}
}

func (sizegen *sizegen) generateTyp(tt types.Type) {
switch tt := tt.(type) {
case *types.Named:
sizegen.generateKnownType(tt)
case *types.Alias:
sizegen.generateTyp(types.Unalias(tt))
}
}

func (sizegen *sizegen) generateKnownType(named *types.Named) {
pkgInfo := named.Obj().Pkg()
file := sizegen.codegen[pkgInfo.Path()]
Expand Down

0 comments on commit f1231a8

Please sign in to comment.