checkinfo: Also skip vars whose type is a type parameter.

PiperOrigin-RevId: 507497705
This commit is contained in:
Jamie Liu
2023-02-06 09:13:43 -08:00
committed by gVisor bot
parent 09459b203a
commit 5614151724
+7 -2
View File
@@ -73,9 +73,14 @@ func (p *pkg) walkObject(pass *analysis.Pass, obj types.Object) {
case *types.PkgName:
// Don't walk to other packages.
case *types.Var:
// Skip if the var's type is a type parameter.
typ := x.Type()
if _, ok := typ.(*types.TypeParam); ok {
break
}
// Add information as a field.
a := Align(pass.TypesSizes.Alignof(x.Type()))
s := Size(pass.TypesSizes.Sizeof(x.Type()))
a := Align(pass.TypesSizes.Alignof(typ))
s := Size(pass.TypesSizes.Sizeof(typ))
pass.ExportObjectFact(obj, &a)
pass.ExportObjectFact(obj, &s)
case *types.TypeName: