Skip to content

Commit

Permalink
sizegen: do not ignore type aliases (#17556)
Browse files Browse the repository at this point in the history
Signed-off-by: Vicent Marti <[email protected]>
  • Loading branch information
vmg authored Jan 16, 2025
1 parent b103492 commit 71ccd6d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
8 changes: 8 additions & 0 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.

8 changes: 8 additions & 0 deletions go/sqltypes/cached_size.go

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

8 changes: 6 additions & 2 deletions go/tools/sizegen/sizegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ func (sizegen *sizegen) generateTyp(tt types.Type) {
sizegen.generateKnownType(tt)
case *types.Alias:
sizegen.generateTyp(types.Unalias(tt))
default:
panic(fmt.Sprintf("unhandled type: %v (%T)", tt, tt))
}
}

Expand Down Expand Up @@ -490,9 +492,11 @@ func (sizegen *sizegen) sizeStmtForType(fieldName *jen.Statement, field types.Ty
// assume that function pointers do not allocate (although they might, if they're closures)
return nil, 0

case *types.Alias:
return sizegen.sizeStmtForType(fieldName, types.Unalias(node), alloc)

default:
log.Printf("unhandled type: %T", node)
return nil, 0
panic(fmt.Sprintf("unhandled type: %v (%T)", node, node))
}
}

Expand Down
20 changes: 20 additions & 0 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: 8 additions & 0 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: 6 additions & 0 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 71ccd6d

Please sign in to comment.