diff --git a/ssa/builder.go b/ssa/builder.go index 37f71f0a..1f215778 100644 --- a/ssa/builder.go +++ b/ssa/builder.go @@ -2471,6 +2471,7 @@ func (b *Builder) membersFromDecl(pkg *Package, decl ast.Decl) { // func (b *Builder) typecheck(importPath string, files []*ast.File) (*types.Package, *TypeInfo, error) { info := &TypeInfo{ + fset: b.Prog.Files, types: make(map[ast.Expr]types.Type), idents: make(map[*ast.Ident]types.Object), constants: make(map[ast.Expr]*Literal), diff --git a/ssa/typeinfo.go b/ssa/typeinfo.go index 0f8cbd5a..153c2fbc 100644 --- a/ssa/typeinfo.go +++ b/ssa/typeinfo.go @@ -7,11 +7,13 @@ import ( "code.google.com/p/go.tools/go/types" "fmt" "go/ast" + "go/token" ) // TypeInfo contains information provided by the type checker about // the abstract syntax for a single package. type TypeInfo struct { + fset *token.FileSet types map[ast.Expr]types.Type // inferred types of expressions constants map[ast.Expr]*Literal // values of constant expressions idents map[*ast.Ident]types.Object // canonical type objects for named entities @@ -51,7 +53,7 @@ func (info *TypeInfo) ObjectOf(id *ast.Ident) types.Object { if obj, ok := info.idents[id]; ok { return obj } - panic(fmt.Sprintf("no types.Object for ast.Ident %s @ %p", id.Name, id)) + panic(fmt.Sprintf("no types.Object for ast.Ident %s @ %s", id.Name, info.fset.Position(id.Pos()))) } // IsType returns true iff expression e denotes a type.