internal/analysisinternal: prevent fillstruct panic on nil package

The previous implementation missed a nil check which caused a panic
when the package of a type was nil.

Fixes: golang/go#39899
Change-Id: I2dfb50d6b79f52df367e093e5d857cd70b7cef27
Reviewed-on: https://go-review.googlesource.com/c/tools/+/240537
Run-TryBot: Josh Baum <joshbaum@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Josh Baum 2020-06-30 09:38:00 -04:00
parent aa94e735be
commit aa3d50130b
1 changed files with 3 additions and 0 deletions

View File

@ -80,6 +80,9 @@ func TypeExpr(fset *token.FileSet, f *ast.File, pkg *types.Package, typ types.Ty
return ast.NewIdent(t.Name())
}
case *types.Named:
if t.Obj().Pkg() == nil {
return nil
}
if t.Obj().Pkg() == pkg {
return ast.NewIdent(t.Obj().Name())
}