mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00: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:
parent
3cad037e2f
commit
e5f49b1c9f
@ -50,12 +50,14 @@ type checker struct {
|
|||||||
|
|
||||||
func (check *checker) callIdent(id *ast.Ident, obj Object) {
|
func (check *checker) callIdent(id *ast.Ident, obj Object) {
|
||||||
if f := check.ctxt.Ident; f != nil {
|
if f := check.ctxt.Ident; f != nil {
|
||||||
|
assert(id != nil)
|
||||||
f(id, obj)
|
f(id, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (check *checker) callImplicitObj(node ast.Node, obj Object) {
|
func (check *checker) callImplicitObj(node ast.Node, obj Object) {
|
||||||
if f := check.ctxt.ImplicitObj; f != nil {
|
if f := check.ctxt.ImplicitObj; f != nil {
|
||||||
|
assert(node != nil && obj != nil)
|
||||||
f(node, obj)
|
f(node, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1018,6 +1018,7 @@ func (check *checker) callExpr(x *operand) {
|
|||||||
// This is not the case yet.
|
// This is not the case yet.
|
||||||
|
|
||||||
if check.ctxt.Expr != nil {
|
if check.ctxt.Expr != nil {
|
||||||
|
assert(x.expr != nil && typ != nil)
|
||||||
check.ctxt.Expr(x.expr, typ, val)
|
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:
|
case *ast.CallExpr:
|
||||||
check.exprOrType(x, e.Fun, iota, false)
|
check.exprOrType(x, e.Fun, iota, false)
|
||||||
if x.mode == invalid {
|
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
|
goto Error
|
||||||
|
|
||||||
} else if x.mode == typexpr {
|
} else if x.mode == typexpr {
|
||||||
check.conversion(x, e, x.typ, iota)
|
check.conversion(x, e, x.typ, iota)
|
||||||
|
|
||||||
} else if sig, ok := x.typ.Underlying().(*Signature); ok {
|
} else if sig, ok := x.typ.Underlying().(*Signature); ok {
|
||||||
// check parameters
|
// check parameters
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user