1
0
mirror of https://github.com/golang/go synced 2024-11-20 08:24:42 -07:00

cmd/compile/internal/types: unexport Type.Copy

It's only used/needed by SubstAny.

CL prepared with gorename.

Change-Id: I243138f9dcc4e6af9b81a7746414e6d7b3ba10a2
Reviewed-on: https://go-review.googlesource.com/65311
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
Matthew Dempsky 2017-09-21 14:26:21 -07:00
parent d83b23fd4f
commit f260ae6523

View File

@ -585,28 +585,28 @@ func SubstAny(t *Type, types *[]*Type) *Type {
case TPTR32, TPTR64: case TPTR32, TPTR64:
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.copy()
t.Extra = Ptr{Elem: elem} t.Extra = Ptr{Elem: elem}
} }
case TARRAY: case TARRAY:
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.copy()
t.Extra.(*Array).Elem = elem t.Extra.(*Array).Elem = elem
} }
case TSLICE: case TSLICE:
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.copy()
t.Extra = Slice{Elem: elem} t.Extra = Slice{Elem: elem}
} }
case TCHAN: case TCHAN:
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.copy()
t.Extra.(*Chan).Elem = elem t.Extra.(*Chan).Elem = elem
} }
@ -614,7 +614,7 @@ func SubstAny(t *Type, types *[]*Type) *Type {
key := SubstAny(t.Key(), types) key := SubstAny(t.Key(), types)
val := SubstAny(t.Val(), types) val := SubstAny(t.Val(), types)
if key != t.Key() || val != t.Val() { if key != t.Key() || val != t.Val() {
t = t.Copy() t = t.copy()
t.Extra.(*Map).Key = key t.Extra.(*Map).Key = key
t.Extra.(*Map).Val = val t.Extra.(*Map).Val = val
} }
@ -624,7 +624,7 @@ func SubstAny(t *Type, types *[]*Type) *Type {
params := SubstAny(t.Params(), types) params := SubstAny(t.Params(), types)
results := SubstAny(t.Results(), types) results := SubstAny(t.Results(), types)
if recvs != t.Recvs() || params != t.Params() || results != t.Results() { if recvs != t.Recvs() || params != t.Params() || results != t.Results() {
t = t.Copy() t = t.copy()
t.FuncType().Receiver = recvs t.FuncType().Receiver = recvs
t.FuncType().Results = results t.FuncType().Results = results
t.FuncType().Params = params t.FuncType().Params = params
@ -645,7 +645,7 @@ func SubstAny(t *Type, types *[]*Type) *Type {
nfs[i].Type = nft nfs[i].Type = nft
} }
if nfs != nil { if nfs != nil {
t = t.Copy() t = t.copy()
t.SetFields(nfs) t.SetFields(nfs)
} }
} }
@ -653,8 +653,8 @@ func SubstAny(t *Type, types *[]*Type) *Type {
return t return t
} }
// Copy returns a shallow copy of the Type. // copy returns a shallow copy of the Type.
func (t *Type) Copy() *Type { func (t *Type) copy() *Type {
if t == nil { if t == nil {
return nil return nil
} }