]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: split SetInterface from SetFields
authorMatthew Dempsky <mdempsky@google.com>
Mon, 20 Mar 2017 09:32:42 +0000 (02:32 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 20 Mar 2017 22:00:14 +0000 (22:00 +0000)
Change-Id: I4e568414faf64d3d47b1795382f0615f6caf53bc
Reviewed-on: https://go-review.googlesource.com/38390
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/bimport.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/type.go
src/cmd/compile/internal/gc/universe.go

index d7d48cb07e01b3b55ae424beefa0b90faf0d8a16..e7308df2a87070efb6849b38281675353803f2c0 100644 (file)
@@ -533,7 +533,7 @@ func (p *importer) typ() *Type {
                        t = Types[TINTER]
                } else {
                        t = p.newtyp(TINTER)
-                       t.SetFields(ml)
+                       t.SetInterface(ml)
                }
                checkwidth(t)
 
index 583c440259b66bb1b7130591dec337c98015a010..6fca2062d07f352782ec930e17384c7ee7402712 100644 (file)
@@ -897,7 +897,7 @@ func tointerface0(t *Type, l []*Node) *Type {
                }
        }
        sort.Sort(methcmp(fields))
-       t.SetFields(fields)
+       t.SetInterface(fields)
 
        checkdupfields("method", t)
        checkwidth(t)
index b1eb05764e17cd15377ec8cee0fb840f18d8349e..e4841708f6e736e0f0d67de02c7f7219c560d43e 100644 (file)
@@ -865,6 +865,7 @@ func (t *Type) FieldSlice() []*Field {
 
 // SetFields sets struct/interface type t's fields/methods to fields.
 func (t *Type) SetFields(fields []*Field) {
+       t.wantEtype(TSTRUCT)
        for _, f := range fields {
                // If type T contains a field F with a go:notinheap
                // type, then T must also be go:notinheap. Otherwise,
@@ -879,6 +880,11 @@ func (t *Type) SetFields(fields []*Field) {
        t.Fields().Set(fields)
 }
 
+func (t *Type) SetInterface(methods []*Field) {
+       t.wantEtype(TINTER)
+       t.Fields().Set(methods)
+}
+
 func (t *Type) isDDDArray() bool {
        if t.Etype != TARRAY {
                return false
index a54a05a8f557138669af68456dcd814882e68acf..b6fbd2d566a2f98021dd93b35cfabc3164b27b3d 100644 (file)
@@ -382,7 +382,7 @@ func makeErrorInterface() *Type {
        field.Type = f
 
        t := typ(TINTER)
-       t.SetFields([]*Field{field})
+       t.SetInterface([]*Field{field})
        return t
 }