cmd/compile: add Type.Elem
This removes almost all direct access to
Type’s heavily overloaded Type field.
Mostly generated by eg, manually checked.
Significant manual changes:
* reflect.go's typPkg used Type indiscriminately.
Use it only for specific etypes.
* gen.go's visitComponents contained a usage of Type
with structs. Using Type for structs no longer
occurs, and the Fatal contained therein has not triggered,
so it has been axed.
* Scary code in cgen.go's cgen_slice is now explicitly scary.
Passes toolstash -cmp.
Change-Id: I2dbfb3c959da7ae239f964d83898c204affcabc6
Reviewed-on: https://go-review.googlesource.com/21331
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/src/cmd/compile/internal/gc/inl.go b/src/cmd/compile/internal/gc/inl.go
index 4221842..e5b02c4 100644
--- a/src/cmd/compile/internal/gc/inl.go
+++ b/src/cmd/compile/internal/gc/inl.go
@@ -39,7 +39,7 @@
rcvr := fn.Type.Recv().Type
if Isptr[rcvr.Etype] {
- rcvr = rcvr.Type
+ rcvr = rcvr.Elem()
}
if rcvr.Sym == nil {
Fatalf("receiver with no sym: [%v] %v (%v)", fn.Sym, Nconv(fn, FmtLong), rcvr)
@@ -747,7 +747,7 @@
as.Right = nodnil()
as.Right.Type = varargtype
} else {
- vararrtype := typArray(varargtype.Type, int64(varargcount))
+ vararrtype := typArray(varargtype.Elem(), int64(varargcount))
as.Right = Nod(OCOMPLIT, nil, typenod(vararrtype))
as.Right.List.Set(varargs)
as.Right = Nod(OSLICE, as.Right, Nod(OKEY, nil, nil))
@@ -866,7 +866,7 @@
// when they come from a multiple return call.
func argvar(t *Type, i int) *Node {
n := newname(LookupN("~arg", i))
- n.Type = t.Type
+ n.Type = t.Elem()
n.Class = PAUTO
n.Used = true
n.Name.Curfn = Curfn // the calling function, not the called one