diff --git a/go/types/eval_test.go b/go/types/eval_test.go index e0144866..b68b244f 100644 --- a/go/types/eval_test.go +++ b/go/types/eval_test.go @@ -144,6 +144,10 @@ func TestEvalPos(t *testing.T) { type FT /* FT => , p.FT */ interface{} } `, + ` + package p + /* T => , p.T */ + `, } fset := token.NewFileSet() diff --git a/go/types/resolver.go b/go/types/resolver.go index e74c3c65..6b16df3d 100644 --- a/go/types/resolver.go +++ b/go/types/resolver.go @@ -153,7 +153,10 @@ func (check *Checker) collectObjects() { // but there is no corresponding package object. check.recordDef(file.Name, nil) - fileScope := NewScope(check.pkg.scope, file.Pos(), file.End(), check.filename(fileNo)) + // Use the actual source file extent rather than *ast.File extent since the + // latter doesn't include comments which appear at the end of the file. + f := check.fset.File(file.Pos()) + fileScope := NewScope(check.pkg.scope, token.Pos(f.Base()), token.Pos(f.Base()+f.Size()), check.filename(fileNo)) check.recordScope(file, fileScope) for _, decl := range file.Decls {