1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:54:43 -07:00

go.tools/go/types: typecheck call arguments even if the call doesn't typecheck

This provides better partial type information in case of type errors.

R=r
CC=golang-dev
https://golang.org/cl/9835049
This commit is contained in:
Robert Griesemer 2013-05-31 11:22:00 -07:00
parent 3cad037e2f
commit e5f49b1c9f
2 changed files with 11 additions and 0 deletions

View File

@ -50,12 +50,14 @@ type checker struct {
func (check *checker) callIdent(id *ast.Ident, obj Object) {
if f := check.ctxt.Ident; f != nil {
assert(id != nil)
f(id, obj)
}
}
func (check *checker) callImplicitObj(node ast.Node, obj Object) {
if f := check.ctxt.ImplicitObj; f != nil {
assert(node != nil && obj != nil)
f(node, obj)
}
}

View File

@ -1018,6 +1018,7 @@ func (check *checker) callExpr(x *operand) {
// This is not the case yet.
if check.ctxt.Expr != nil {
assert(x.expr != nil && typ != nil)
check.ctxt.Expr(x.expr, typ, val)
}
}
@ -1536,9 +1537,17 @@ func (check *checker) rawExpr(x *operand, e ast.Expr, hint Type, iota int, cycle
case *ast.CallExpr:
check.exprOrType(x, e.Fun, iota, false)
if x.mode == invalid {
// We don't have a valid call or conversion but we have list of arguments.
// Typecheck them independently for better partial type information in
// the presence of type errors.
for _, arg := range e.Args {
check.expr(x, arg, nil, iota)
}
goto Error
} else if x.mode == typexpr {
check.conversion(x, e, x.typ, iota)
} else if sig, ok := x.typ.Underlying().(*Signature); ok {
// check parameters