[dev.typeparams] cmd/compile: swap export order of union term components (cleanup)

Export a term as a pair (tilde, type) rather than (type, tilde)
to match the new Union/Term API.

Change-Id: I221c09c2c746ae19fbae0c970ffb26fa7a8ac736
Reviewed-on: https://go-review.googlesource.com/c/go/+/340251
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2021-08-05 13:58:24 -07:00
parent 0d7dc417ea
commit 313924f272
5 changed files with 8 additions and 13 deletions

View file

@ -676,12 +676,9 @@ func (r *importReader) doType(base *types2.Named) types2.Type {
if r.p.exportVersion < iexportVersionGenerics {
errorf("unexpected instantiation type")
}
nt := int(r.uint64())
terms := make([]*types2.Term, nt)
terms := make([]*types2.Term, r.uint64())
for i := range terms {
typ := r.typ()
tilde := r.bool()
terms[i] = types2.NewTerm(tilde, typ)
terms[i] = types2.NewTerm(r.bool(), r.typ())
}
return types2.NewUnion(terms)
}

View file

@ -283,9 +283,7 @@ func (r *reader2) structType() *types2.Struct {
func (r *reader2) unionType() *types2.Union {
terms := make([]*types2.Term, r.len())
for i := range terms {
typ := r.typ()
tilde := r.bool()
terms[i] = types2.NewTerm(tilde, typ)
terms[i] = types2.NewTerm(r.bool(), r.typ())
}
return types2.NewUnion(terms)
}

View file

@ -397,8 +397,8 @@ func (w *writer) unionType(typ *types2.Union) {
w.len(typ.Len())
for i := 0; i < typ.Len(); i++ {
t := typ.Term(i)
w.typ(t.Type())
w.bool(t.Tilde())
w.typ(t.Type())
}
}

View file

@ -1002,9 +1002,9 @@ func (w *exportWriter) doTyp(t *types.Type) {
nt := t.NumTerms()
w.uint64(uint64(nt))
for i := 0; i < nt; i++ {
t, b := t.Term(i)
w.typ(t)
w.bool(b)
typ, tilde := t.Term(i)
w.bool(tilde)
w.typ(typ)
}
default:

View file

@ -847,8 +847,8 @@ func (r *importReader) typ1() *types.Type {
terms := make([]*types.Type, nt)
tildes := make([]bool, nt)
for i := range terms {
terms[i] = r.typ()
tildes[i] = r.bool()
terms[i] = r.typ()
}
return types.NewUnion(terms, tildes)
}