cmd/compile: clean up various bits of code

* replace a copy of IsMethod with a call of it.
* a few more switches where they simplify the code.
* prefer composite literals over "n := new(...); n.x = y; ...".
* use defers to get rid of three goto labels.
* rewrite updateHasCall into two funcs to remove gotos.

Passes toolstash-check on std cmd.

Change-Id: Icb5442a89a87319ef4b640bbc5faebf41b193ef1
Reviewed-on: https://go-review.googlesource.com/72070
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Daniel Martí 2017-10-20 11:56:31 +01:00
parent 7092a312e5
commit 006bc57095
9 changed files with 53 additions and 79 deletions

View file

@ -1373,7 +1373,8 @@ func defaultlitreuse(n *Node, t *types.Type, reuse canReuseNode) *Node {
return convlit(n, t)
}
if n.Val().Ctype() == CTNIL {
switch n.Val().Ctype() {
case CTNIL:
lineno = lno
if !n.Diag() {
yyerror("use of untyped nil")
@ -1381,17 +1382,13 @@ func defaultlitreuse(n *Node, t *types.Type, reuse canReuseNode) *Node {
}
n.Type = nil
break
}
if n.Val().Ctype() == CTSTR {
case CTSTR:
t1 := types.Types[TSTRING]
n = convlit1(n, t1, false, reuse)
break
default:
yyerror("defaultlit: unknown literal: %v", n)
}
yyerror("defaultlit: unknown literal: %v", n)
case CTxxx:
Fatalf("defaultlit: idealkind is CTxxx: %+v", n)