Skip to content

Commit

Permalink
fix sizegen so it handles type aliases (#16650)
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay authored Aug 26, 2024
1 parent e6843dc commit 05cdfbb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 52 deletions.
8 changes: 0 additions & 8 deletions go/mysql/collations/colldata/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions go/sqltypes/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
20 changes: 0 additions & 20 deletions go/vt/proto/query/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions go/vt/proto/topodata/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions go/vt/proto/vttime/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 05cdfbb

Please sign in to comment.