From 9c9e1878f421008fb032021982001085e87d6713 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Mon, 15 Apr 2019 20:24:28 -0400 Subject: [PATCH] internal/lsp: fix crash when there is a type alias to a struct in the symbols code Change-Id: If492a88c9f80003d7102b4f517621e52cc15759f Reviewed-on: https://go-review.googlesource.com/c/tools/+/171861 Run-TryBot: Ian Cottrell TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/source/symbols.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/lsp/source/symbols.go b/internal/lsp/source/symbols.go index 4b4d2b8b..1ce5fc86 100644 --- a/internal/lsp/source/symbols.go +++ b/internal/lsp/source/symbols.go @@ -173,8 +173,9 @@ func typeSymbol(spec *ast.TypeSpec, obj types.Object, fset *token.FileSet, q typ s.SelectionSpan = span } - if t, ok := obj.Type().Underlying().(*types.Struct); ok { - st := spec.Type.(*ast.StructType) + t, objIsStruct := obj.Type().Underlying().(*types.Struct) + st, specIsStruct := spec.Type.(*ast.StructType) + if objIsStruct && specIsStruct { for i := 0; i < t.NumFields(); i++ { f := t.Field(i) child := Symbol{Name: f.Name(), Kind: FieldSymbol}