mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/types: remove unneeded functionality
This CL removes a handful of features that were only needed for the pre-unified frontends. In particular, Type.Pkg was a hack for iexport so that go/types.Var.Pkg could be precisely populated for struct fields and signature parameters by gcimporter, but it's no longer necessary with the unified export data format because we now write export data directly from types2-supplied type descriptors. Several other features (e.g., OrigType, implicit interfaces, type parameters on signatures) are no longer relevant to the unified frontend, because it only uses types1 to represent instantiated generic types. Updates #57410. Change-Id: I84fd1da5e0b65d2ab91d244a7bb593821ee916e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/458622 Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
f5eb0a7a5a
commit
f0b1563535
22 changed files with 75 additions and 148 deletions
|
|
@ -506,7 +506,7 @@ func (r *reader) doTyp() *types.Type {
|
|||
case pkgbits.TypePointer:
|
||||
return types.NewPtr(r.typ())
|
||||
case pkgbits.TypeSignature:
|
||||
return r.signature(types.LocalPkg, nil)
|
||||
return r.signature(nil)
|
||||
case pkgbits.TypeSlice:
|
||||
return types.NewSlice(r.typ())
|
||||
case pkgbits.TypeStruct:
|
||||
|
|
@ -549,8 +549,6 @@ func (r *reader) unionType() *types.Type {
|
|||
}
|
||||
|
||||
func (r *reader) interfaceType() *types.Type {
|
||||
tpkg := types.LocalPkg // TODO(mdempsky): Remove after iexport is gone.
|
||||
|
||||
nmethods, nembeddeds := r.Len(), r.Len()
|
||||
implicit := nmethods == 0 && nembeddeds == 1 && r.Bool()
|
||||
assert(!implicit) // implicit interfaces only appear in constraints
|
||||
|
|
@ -560,9 +558,8 @@ func (r *reader) interfaceType() *types.Type {
|
|||
|
||||
for i := range methods {
|
||||
pos := r.pos()
|
||||
pkg, sym := r.selector()
|
||||
tpkg = pkg
|
||||
mtyp := r.signature(pkg, types.FakeRecv())
|
||||
_, sym := r.selector()
|
||||
mtyp := r.signature(types.FakeRecv())
|
||||
methods[i] = types.NewField(pos, sym, mtyp)
|
||||
}
|
||||
for i := range embeddeds {
|
||||
|
|
@ -572,16 +569,14 @@ func (r *reader) interfaceType() *types.Type {
|
|||
if len(fields) == 0 {
|
||||
return types.Types[types.TINTER] // empty interface
|
||||
}
|
||||
return types.NewInterface(tpkg, fields, false)
|
||||
return types.NewInterface(fields)
|
||||
}
|
||||
|
||||
func (r *reader) structType() *types.Type {
|
||||
tpkg := types.LocalPkg // TODO(mdempsky): Remove after iexport is gone.
|
||||
fields := make([]*types.Field, r.Len())
|
||||
for i := range fields {
|
||||
pos := r.pos()
|
||||
pkg, sym := r.selector()
|
||||
tpkg = pkg
|
||||
_, sym := r.selector()
|
||||
ftyp := r.typ()
|
||||
tag := r.String()
|
||||
embedded := r.Bool()
|
||||
|
|
@ -593,26 +588,26 @@ func (r *reader) structType() *types.Type {
|
|||
}
|
||||
fields[i] = f
|
||||
}
|
||||
return types.NewStruct(tpkg, fields)
|
||||
return types.NewStruct(fields)
|
||||
}
|
||||
|
||||
func (r *reader) signature(tpkg *types.Pkg, recv *types.Field) *types.Type {
|
||||
func (r *reader) signature(recv *types.Field) *types.Type {
|
||||
r.Sync(pkgbits.SyncSignature)
|
||||
|
||||
params := r.params(&tpkg)
|
||||
results := r.params(&tpkg)
|
||||
params := r.params()
|
||||
results := r.params()
|
||||
if r.Bool() { // variadic
|
||||
params[len(params)-1].SetIsDDD(true)
|
||||
}
|
||||
|
||||
return types.NewSignature(tpkg, recv, nil, params, results)
|
||||
return types.NewSignature(recv, params, results)
|
||||
}
|
||||
|
||||
func (r *reader) params(tpkg **types.Pkg) []*types.Field {
|
||||
func (r *reader) params() []*types.Field {
|
||||
r.Sync(pkgbits.SyncParams)
|
||||
fields := make([]*types.Field, r.Len())
|
||||
for i := range fields {
|
||||
*tpkg, fields[i] = r.param()
|
||||
_, fields[i] = r.param()
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
|
@ -742,7 +737,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index, implicits, explicits []*types.Typ
|
|||
sym = Renameinit()
|
||||
}
|
||||
name := do(ir.ONAME, true)
|
||||
setType(name, r.signature(sym.Pkg, nil))
|
||||
setType(name, r.signature(nil))
|
||||
|
||||
name.Func = ir.NewFunc(r.pos())
|
||||
name.Func.Nname = name
|
||||
|
|
@ -981,10 +976,10 @@ func (r *reader) typeParamNames() {
|
|||
func (r *reader) method(rext *reader) *types.Field {
|
||||
r.Sync(pkgbits.SyncMethod)
|
||||
pos := r.pos()
|
||||
pkg, sym := r.selector()
|
||||
_, sym := r.selector()
|
||||
r.typeParamNames()
|
||||
_, recv := r.param()
|
||||
typ := r.signature(pkg, recv)
|
||||
typ := r.signature(recv)
|
||||
|
||||
name := ir.NewNameAt(pos, ir.MethodSym(recv.Type, sym))
|
||||
setType(name, typ)
|
||||
|
|
@ -2581,7 +2576,7 @@ func (r *reader) curry(pos src.XPos, ifaceHack bool, fun ir.Node, arg0, arg1 ir.
|
|||
|
||||
params, results := syntheticSig(fun.Type())
|
||||
params = params[len(captured)-1:] // skip curried parameters
|
||||
typ := types.NewSignature(types.NoPkg, nil, nil, params, results)
|
||||
typ := types.NewSignature(nil, params, results)
|
||||
|
||||
addBody := func(pos src.XPos, r *reader, captured []ir.Node) {
|
||||
recvs, params := r.syntheticArgs(pos)
|
||||
|
|
@ -2619,7 +2614,7 @@ func (r *reader) methodExprWrap(pos src.XPos, recv *types.Type, implicits []int,
|
|||
params = append(params[:1], params[2:]...)
|
||||
}
|
||||
|
||||
typ := types.NewSignature(types.NoPkg, nil, nil, params, results)
|
||||
typ := types.NewSignature(nil, params, results)
|
||||
|
||||
addBody := func(pos src.XPos, r *reader, captured []ir.Node) {
|
||||
recvs, args := r.syntheticArgs(pos)
|
||||
|
|
@ -3073,7 +3068,7 @@ func (r *reader) funcLit() ir.Node {
|
|||
// allocation of the closure is credited (#49171).
|
||||
r.suppressInlPos++
|
||||
pos := r.pos()
|
||||
xtype2 := r.signature(types.LocalPkg, nil)
|
||||
xtype2 := r.signature(nil)
|
||||
r.suppressInlPos--
|
||||
|
||||
fn := ir.NewClosureFunc(pos, r.curfn != nil)
|
||||
|
|
@ -3926,7 +3921,7 @@ func newWrapperType(recvType *types.Type, method *types.Field) *types.Type {
|
|||
params := clone(sig.Params().FieldSlice())
|
||||
results := clone(sig.Results().FieldSlice())
|
||||
|
||||
return types.NewSignature(types.NoPkg, recv, nil, params, results)
|
||||
return types.NewSignature(recv, params, results)
|
||||
}
|
||||
|
||||
func addTailCall(pos src.XPos, fn *ir.Func, recv ir.Node, method *types.Field) {
|
||||
|
|
@ -3994,5 +3989,5 @@ func shapeSig(fn *ir.Func, dict *readerDict) *types.Type {
|
|||
results[i] = types.NewField(result.Pos, result.Sym, result.Type)
|
||||
}
|
||||
|
||||
return types.NewSignature(types.LocalPkg, recv, nil, params, results)
|
||||
return types.NewSignature(recv, params, results)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue