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/bexport.go b/src/cmd/compile/internal/gc/bexport.go
index f14f12f..24537ac 100644
--- a/src/cmd/compile/internal/gc/bexport.go
+++ b/src/cmd/compile/internal/gc/bexport.go
@@ -512,7 +512,7 @@
} else {
p.tag(sliceTag)
}
- p.typ(t.Type)
+ p.typ(t.Elem())
case TDDDFIELD:
// see p.param use of TDDDFIELD
@@ -525,7 +525,7 @@
case TPTR32, TPTR64: // could use Tptr but these are constants
p.tag(pointerTag)
- p.typ(t.Type)
+ p.typ(t.Elem())
case TFUNC:
p.tag(signatureTag)
@@ -548,7 +548,7 @@
case TCHAN:
p.tag(chanTag)
p.int(int(t.Chan))
- p.typ(t.Type)
+ p.typ(t.Elem())
default:
Fatalf("exporter: unexpected type: %s (Etype = %d)", Tconv(t, 0), t.Etype)
@@ -636,7 +636,7 @@
func basetypeName(t *Type) string {
s := t.Sym
if s == nil && Isptr[t.Etype] {
- s = t.Type.Sym // deref
+ s = t.Elem().Sym // deref
}
if s != nil {
return s.Name
@@ -666,7 +666,7 @@
t := q.Type
if q.Isddd {
// create a fake type to encode ... just for the p.typ call
- t = typWrapper(TDDDFIELD, t.Type)
+ t = typWrapper(TDDDFIELD, t.Elem())
}
p.typ(t)
if n > 0 {