cmd/compile: inline checknil

Now that checknil has only a single caller, inline it.

Passes toolstash-check.

Change-Id: I5b13596bef84dd9a3e7f4bff8560903f1e54acfb
Reviewed-on: https://go-review.googlesource.com/c/148829
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2018-11-10 07:00:32 -08:00
parent e90e7a59dc
commit 1e58bb1491
2 changed files with 7 additions and 13 deletions

View file

@ -523,8 +523,14 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
// Trigger panic for method on nil interface now.
// Otherwise it happens in the wrapper and is confusing.
n.Left = cheapexpr(n.Left, init)
n.Left = walkexpr(n.Left, nil)
checknil(n.Left, init)
tab := nod(OITAB, n.Left, nil)
tab = typecheck(tab, ctxExpr)
c := nod(OCHECKNIL, tab, nil)
c.SetTypecheck(1)
init.Append(c)
}
typ := partialCallType(n)

View file

@ -1829,18 +1829,6 @@ func isbadimport(path string, allowSpace bool) bool {
return false
}
func checknil(x *Node, init *Nodes) {
x = walkexpr(x, nil) // caller has not done this yet
if x.Type.IsInterface() {
x = nod(OITAB, x, nil)
x = typecheck(x, ctxExpr)
}
n := nod(OCHECKNIL, x, nil)
n.SetTypecheck(1)
init.Append(n)
}
// Can this type be stored directly in an interface word?
// Yes, if the representation is a single pointer.
func isdirectiface(t *types.Type) bool {