1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:54:42 -07:00

go.tools/go/ssa/interp: improve "no such method" error.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/59740043
This commit is contained in:
Alan Donovan 2014-02-11 18:15:10 -05:00
parent 08fadac071
commit b2557286bb

View File

@ -177,7 +177,11 @@ func lookupMethod(i *interpreter, typ types.Type, meth *types.Func) *ssa.Functio
case errorType: case errorType:
return i.errorMethods[meth.Id()] return i.errorMethods[meth.Id()]
} }
return i.prog.Method(i.prog.MethodSets.MethodSet(typ).Lookup(meth.Pkg(), meth.Name())) sel := i.prog.MethodSets.MethodSet(typ).Lookup(meth.Pkg(), meth.Name())
if sel == nil {
panic(fmt.Sprintf("%s has no method %s (of type %s)", typ, meth.Id(), meth.Type()))
}
return i.prog.Method(sel)
} }
// visitInstr interprets a single ssa.Instruction within the activation // visitInstr interprets a single ssa.Instruction within the activation