nxp := src.NoXPos
bp := types.NewPtr(types.Types[types.TUINT8])
it := types.Types[types.TINT]
- synthSlice = types.NewStruct(types.NoPkg, []*types.Field{
+ synthSlice = types.NewStruct([]*types.Field{
types.NewField(nxp, fname("ptr"), bp),
types.NewField(nxp, fname("len"), it),
types.NewField(nxp, fname("cap"), it),
})
types.CalcStructSize(synthSlice)
- synthString = types.NewStruct(types.NoPkg, []*types.Field{
+ synthString = types.NewStruct([]*types.Field{
types.NewField(nxp, fname("data"), bp),
types.NewField(nxp, fname("len"), it),
})
types.CalcStructSize(synthString)
unsp := types.Types[types.TUNSAFEPTR]
- synthIface = types.NewStruct(types.NoPkg, []*types.Field{
+ synthIface = types.NewStruct([]*types.Field{
types.NewField(nxp, fname("f1"), unsp),
types.NewField(nxp, fname("f2"), unsp),
})
}{
{"struct without fields", 0, 0,
func() *types.Type {
- return types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ return types.NewStruct([]*types.Field{})
}},
{"struct with 1 byte field", 1, 1,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := []*types.Field{
newByteField(parent, 0),
}
},
{"struct with 8 byte fields", 1, 8,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := make([]*types.Field, 8)
for i := range fields {
fields[i] = newByteField(parent, int64(i))
},
{"struct with 16 byte fields", 2, 16,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := make([]*types.Field, 16)
for i := range fields {
fields[i] = newByteField(parent, int64(i))
},
{"struct with 32 byte fields", 4, 32,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := make([]*types.Field, 32)
for i := range fields {
fields[i] = newByteField(parent, int64(i))
},
{"struct with 2 int32 fields", 1, 2,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := make([]*types.Field, 2)
for i := range fields {
fields[i] = newField(parent, int64(i*4), types.TINT32)
},
{"struct with 2 int32 fields and 1 int64", 2, 3,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := make([]*types.Field, 3)
fields[0] = newField(parent, int64(0), types.TINT32)
fields[1] = newField(parent, int64(4), types.TINT32)
},
{"struct with 1 int field and 1 string", 3, 3,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := make([]*types.Field, 2)
fields[0] = newField(parent, int64(0), types.TINT64)
fields[1] = newField(parent, int64(8), types.TSTRING)
},
{"struct with 2 strings", 4, 4,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := make([]*types.Field, 2)
fields[0] = newField(parent, int64(0), types.TSTRING)
fields[1] = newField(parent, int64(8), types.TSTRING)
},
{"struct with 1 large byte array field", 26, 101,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := []*types.Field{
newArrayField(parent, 0, 101, types.TUINT16),
}
},
{"struct with string array field", 4, 4,
func() *types.Type {
- parent := types.NewStruct(types.NewPkg("main", ""), []*types.Field{})
+ parent := types.NewStruct([]*types.Field{})
fields := []*types.Field{
newArrayField(parent, 0, 2, types.TSTRING),
}
// Create a new no-argument function that we'll hand off to defer.
fn := ir.NewClosureFunc(n.Pos(), true)
fn.SetWrapper(true)
- fn.Nname.SetType(types.NewSignature(types.LocalPkg, nil, nil, nil, nil))
+ fn.Nname.SetType(types.NewSignature(nil, nil, nil))
fn.Body = []ir.Node{call}
if call, ok := call.(*ir.CallExpr); ok && call.Op() == ir.OCALLFUNC {
// If the callee is a named function, link to the original callee.
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:
}
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
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 {
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()
}
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
}
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
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)
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)
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)
// 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)
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) {
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)
}
// runtime.asanregisterglobals(unsafe.Pointer(&globals[0]), ni)
asanf := typecheck.NewName(ir.Pkgs.Runtime.Lookup("asanregisterglobals"))
ir.MarkFunc(asanf)
- asanf.SetType(types.NewSignature(types.NoPkg, nil, nil, []*types.Field{
+ asanf.SetType(types.NewSignature(nil, []*types.Field{
types.NewField(base.Pos, nil, types.Types[types.TUNSAFEPTR]),
types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]),
}, nil))
fname := typecheck.Lookup
nxp := src.NoXPos
nfield := types.NewField
- asanGlobal := types.NewStruct(types.NoPkg, []*types.Field{
+ asanGlobal := types.NewStruct([]*types.Field{
nfield(nxp, fname("beg"), up),
nfield(nxp, fname("size"), up),
nfield(nxp, fname("sizeWithRedzone"), up),
})
types.CalcSize(asanGlobal)
- asanLocation := types.NewStruct(types.NoPkg, []*types.Field{
+ asanLocation := types.NewStruct([]*types.Field{
nfield(nxp, fname("filename"), up),
nfield(nxp, fname("line"), i32),
nfield(nxp, fname("column"), i32),
})
types.CalcSize(asanLocation)
- defString := types.NewStruct(types.NoPkg, []*types.Field{
+ defString := types.NewStruct([]*types.Field{
types.NewField(nxp, fname("data"), up),
types.NewField(nxp, fname("len"), up),
})
// TODO(austin): This creates an ir.Name with a nil Func.
n := typecheck.NewName(sym)
ir.MarkFunc(n)
- n.SetType(types.NewSignature(types.NoPkg, nil, nil, []*types.Field{
+ n.SetType(types.NewSignature(nil, []*types.Field{
types.NewField(base.Pos, nil, types.NewPtr(t)),
types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]),
}, []*types.Field{
// TODO(austin): This creates an ir.Name with a nil Func.
n := typecheck.NewName(sym)
ir.MarkFunc(n)
- n.SetType(types.NewSignature(types.NoPkg, nil, nil, []*types.Field{
+ n.SetType(types.NewSignature(nil, []*types.Field{
types.NewField(base.Pos, nil, types.NewPtr(t)),
types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]),
types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]),
field = append(field, overflow)
// link up fields
- bucket := types.NewStruct(types.NoPkg, field[:])
+ bucket := types.NewStruct(field[:])
bucket.SetNoalg(true)
types.CalcSize(bucket)
makefield("extra", types.Types[types.TUNSAFEPTR]),
}
- hmap := types.NewStruct(types.NoPkg, fields)
+ hmap := types.NewStruct(fields)
hmap.SetNoalg(true)
types.CalcSize(hmap)
}
// build iterator struct holding the above fields
- hiter := types.NewStruct(types.NoPkg, fields)
+ hiter := types.NewStruct(fields)
hiter.SetNoalg(true)
types.CalcSize(hiter)
if hiter.Size() != int64(12*types.PtrSize) {
if typ.Sym() == nil && typ.Kind() == types.TFUNC {
f := typ.FuncType()
// func(error) string
- if f.Receiver.NumFields() == 0 && f.TParams.NumFields() == 0 &&
+ if f.Receiver.NumFields() == 0 &&
f.Params.NumFields() == 1 && f.Results.NumFields() == 1 &&
f.Params.FieldType(0) == types.ErrorType &&
f.Results.FieldType(0) == types.Types[types.TSTRING] {
// emit type for func(error) string,
// which is the type of an auto-generated wrapper.
- writeType(types.NewPtr(types.NewSignature(types.NoPkg, nil, nil, []*types.Field{
+ writeType(types.NewPtr(types.NewSignature(nil, []*types.Field{
types.NewField(base.Pos, nil, types.ErrorType),
}, []*types.Field{
types.NewField(base.Pos, nil, types.Types[types.TSTRING]),
}
// build struct holding the above fields
- s := types.NewStruct(types.NoPkg, fields)
+ s := types.NewStruct(fields)
s.SetNoalg(true)
types.CalcStructSize(s)
return s
fldt := mkFuncType(types.FakeRecvType(), []*types.Type{},
[]*types.Type{types.Types[types.TSTRING]})
field := types.NewField(src.NoXPos, typecheck.Lookup("F"), fldt)
- nei := types.NewInterface(types.LocalPkg, []*types.Field{field}, false)
+ nei := types.NewInterface([]*types.Field{field})
i16 := types.Types[types.TINT16]
tb := types.Types[types.TBOOL]
s1 := mkstruct([]*types.Type{i16, i16, tb})
f := types.NewField(src.NoXPos, nil, t)
fields[k] = f
}
- s := types.NewStruct(types.LocalPkg, fields)
+ s := types.NewStruct(fields)
return s
}
if rcvr != nil {
rf = mkParamResultField(rcvr, q, ir.PPARAM)
}
- return types.NewSignature(types.LocalPkg, rf, nil, inf, outf)
+ return types.NewSignature(rf, inf, outf)
}
type expectedDump struct {
//
//go:noinline
func newSig(params, results []*types.Field) *types.Type {
- return types.NewSignature(types.NoPkg, nil, nil, params, results)
+ return types.NewSignature(nil, params, results)
}
func params(tlist ...*types.Type) []*types.Field {
typs[102] = types.NewChan(typs[2], types.Csend)
typs[103] = newSig(params(typs[102], typs[3]), nil)
typs[104] = types.NewArray(typs[0], 3)
- typs[105] = types.NewStruct(types.NoPkg, []*types.Field{types.NewField(src.NoXPos, Lookup("enabled"), typs[6]), types.NewField(src.NoXPos, Lookup("pad"), typs[104]), types.NewField(src.NoXPos, Lookup("needed"), typs[6]), types.NewField(src.NoXPos, Lookup("cgo"), typs[6]), types.NewField(src.NoXPos, Lookup("alignme"), typs[24])})
+ typs[105] = types.NewStruct([]*types.Field{types.NewField(src.NoXPos, Lookup("enabled"), typs[6]), types.NewField(src.NoXPos, Lookup("pad"), typs[104]), types.NewField(src.NoXPos, Lookup("needed"), typs[6]), types.NewField(src.NoXPos, Lookup("cgo"), typs[6]), types.NewField(src.NoXPos, Lookup("alignme"), typs[24])})
typs[106] = newSig(params(typs[1], typs[3], typs[3]), nil)
typs[107] = newSig(params(typs[1], typs[3]), nil)
typs[108] = newSig(params(typs[1], typs[3], typs[15], typs[3], typs[15]), params(typs[15]))
recv1 = declareParam(ir.PPARAM, -1, recv)
}
- typ := types.NewSignature(types.LocalPkg, recv1, nil, declareParams(ir.PPARAM, params), declareParams(ir.PPARAMOUT, results))
+ typ := types.NewSignature(recv1, declareParams(ir.PPARAM, params), declareParams(ir.PPARAMOUT, results))
checkdupfields("argument", typ.Recvs().FieldSlice(), typ.Params().FieldSlice(), typ.Results().FieldSlice())
fn.Nname.SetType(typ)
fn.Nname.SetTypecheck(1)
results[i] = types.NewField(base.Pos, nil, t.Type)
}
- return types.NewSignature(types.LocalPkg, nil, nil, params, results)
+ return types.NewSignature(nil, params, results)
}
}
fields = append(fields, types.NewField(base.Pos, v.Sym(), typ))
}
- typ := types.NewStruct(types.NoPkg, fields)
+ typ := types.NewStruct(fields)
typ.SetNoalg(true)
return typ
}
// needed in the closure for a OMETHVALUE node. The address of a variable of
// the returned type can be cast to a func.
func MethodValueType(n *ir.SelectorExpr) *types.Type {
- t := types.NewStruct(types.NoPkg, []*types.Field{
+ t := types.NewStruct([]*types.Field{
types.NewField(base.Pos, Lookup("F"), types.Types[types.TUINTPTR]),
types.NewField(base.Pos, Lookup("R"), n.X.Type()),
})
// Not inlining this function removes a significant chunk of init code.
//go:noinline
func newSig(params, results []*types.Field) *types.Type {
- return types.NewSignature(types.NoPkg, nil, nil, params, results)
+ return types.NewSignature(nil, params, results)
}
func params(tlist ...*types.Type) []*types.Field {
case *ast.StarExpr:
return fmt.Sprintf("types.NewPtr(%s)", i.subtype(t.X))
case *ast.StructType:
- return fmt.Sprintf("types.NewStruct(types.NoPkg, %s)", i.fields(t.Fields, true))
+ return fmt.Sprintf("types.NewStruct(%s)", i.fields(t.Fields, true))
default:
log.Fatalf("unhandled type: %#v", t)
}
b.WriteString("func")
}
- if t.NumTParams() > 0 {
- tconv2(b, t.TParams(), 0, mode, visited)
- }
tconv2(b, t.Params(), 0, mode, visited)
switch t.NumResults() {
_64bit uintptr // size on 64bit platforms
}{
{Sym{}, 32, 64},
- {Type{}, 60, 104},
+ {Type{}, 56, 96},
{Map{}, 20, 40},
{Forward{}, 20, 32},
- {Func{}, 28, 48},
- {Struct{}, 16, 32},
- {Interface{}, 8, 16},
+ {Func{}, 20, 32},
+ {Struct{}, 12, 24},
+ {Interface{}, 0, 0},
{Chan{}, 8, 16},
{Array{}, 12, 16},
{FuncArgs{}, 4, 8},
// instantiated from a generic type, and is otherwise set to nil.
// TODO(danscales): choose a better name.
rparams *[]*Type
-
- // For an instantiated generic type, the base generic type.
- // This backpointer is useful, because the base type is the type that has
- // the method bodies.
- origType *Type
}
func (*Type) CanBeAnSSAAux() {}
return nil
}
-// OrigType returns the original generic type that t is an
-// instantiation of, if any.
-func (t *Type) OrigType() *Type { return t.origType }
-func (t *Type) SetOrigType(orig *Type) { t.origType = orig }
-
// Underlying returns the underlying type of type t.
func (t *Type) Underlying() *Type { return t.underlying }
return len(t.RParams()) > 0
}
-// NoPkg is a nil *Pkg value for clarity.
-// It's intended for use when constructing types that aren't exported
-// and thus don't need to be associated with any package.
-var NoPkg *Pkg = nil
-
-// Pkg returns the package that t appeared in.
-//
-// Pkg is only defined for function, struct, and interface types
-// (i.e., types with named elements). This information isn't used by
-// cmd/compile itself, but we need to track it because it's exposed by
-// the go/types API.
-//
-// Deprecated: Pkg exists only for iexport, which will go away after
-// Go 1.20. It should not be used by other code.
-func (t *Type) Pkg() *Pkg {
- switch t.kind {
- case TFUNC:
- return t.extra.(*Func).pkg
- case TSTRUCT:
- return t.extra.(*Struct).pkg
- case TINTER:
- return t.extra.(*Interface).pkg
- default:
- base.Fatalf("Pkg: unexpected kind: %v", t)
- return nil
- }
-}
-
// Map contains Type fields specific to maps.
type Map struct {
Key *Type // Key type
Receiver *Type // function receiver
Results *Type // function results
Params *Type // function params
- TParams *Type // type params of receiver (if method) or function
-
- pkg *Pkg
// Argwid is the total width of the function receiver, params, and results.
// It gets calculated via a temporary TFUNCARGS type.
// StructType contains Type fields specific to struct types.
type Struct struct {
fields Fields
- pkg *Pkg
// Maps have three associated internal structs (see struct MapType).
// Map links such structs back to their map type.
// Interface contains Type fields specific to interface types.
type Interface struct {
- pkg *Pkg
- implicit bool
}
// Ptr contains Type fields specific to pointer types.
}
func (t *Type) Recvs() *Type { return t.FuncType().Receiver }
-func (t *Type) TParams() *Type { return t.FuncType().TParams }
func (t *Type) Params() *Type { return t.FuncType().Params }
func (t *Type) Results() *Type { return t.FuncType().Results }
func (t *Type) NumRecvs() int { return t.FuncType().Receiver.NumFields() }
-func (t *Type) NumTParams() int { return t.FuncType().TParams.NumFields() }
func (t *Type) NumParams() int { return t.FuncType().Params.NumFields() }
func (t *Type) NumResults() int { return t.FuncType().Results.NumFields() }
// NewInterface returns a new interface for the given methods and
// embedded types. Embedded types are specified as fields with no Sym.
-func NewInterface(pkg *Pkg, methods []*Field, implicit bool) *Type {
+func NewInterface(methods []*Field) *Type {
t := newType(TINTER)
t.SetInterface(methods)
for _, f := range methods {
break
}
}
- t.extra.(*Interface).pkg = pkg
- t.extra.(*Interface).implicit = implicit
return t
}
-// IsImplicit reports whether an interface is implicit (i.e. elided from a type
-// parameter constraint).
-func (t *Type) IsImplicit() bool {
- t.wantEtype(TINTER)
- return t.extra.(*Interface).implicit
-}
-
-// MarkImplicit marks the interface as implicit.
-func (t *Type) MarkImplicit() {
- t.wantEtype(TINTER)
- t.extra.(*Interface).implicit = true
-}
-
const BOGUS_FUNARG_OFFSET = -1000000000
func unzeroFieldOffsets(f []*Field) {
}
// NewSignature returns a new function type for the given receiver,
-// parameters, results, and type parameters, any of which may be nil.
-func NewSignature(pkg *Pkg, recv *Field, tparams, params, results []*Field) *Type {
+// parameters, and results, any of which may be nil.
+func NewSignature(recv *Field, params, results []*Field) *Type {
var recvs []*Field
if recv != nil {
recvs = []*Field{recv}
ft := t.FuncType()
funargs := func(fields []*Field, funarg Funarg) *Type {
- s := NewStruct(NoPkg, fields)
+ s := NewStruct(fields)
s.StructType().Funarg = funarg
return s
}
unzeroFieldOffsets(params)
unzeroFieldOffsets(results)
ft.Receiver = funargs(recvs, FunargRcvr)
- // TODO(danscales): just use nil here (save memory) if no tparams
- ft.TParams = funargs(tparams, FunargTparams)
ft.Params = funargs(params, FunargParams)
ft.Results = funargs(results, FunargResults)
- ft.pkg = pkg
if fieldsHasShape(recvs) || fieldsHasShape(params) || fieldsHasShape(results) {
t.SetHasShape(true)
}
}
// NewStruct returns a new struct with the given fields.
-func NewStruct(pkg *Pkg, fields []*Field) *Type {
+func NewStruct(fields []*Field) *Type {
t := newType(TSTRUCT)
t.SetFields(fields)
- t.extra.(*Struct).pkg = pkg
if fieldsHasShape(fields) {
t.SetHasShape(true)
}
}
Types[TANY] = newType(TANY) // note: an old placeholder type, NOT the new builtin 'any' alias for interface{}
- Types[TINTER] = NewInterface(LocalPkg, nil, false)
+ Types[TINTER] = NewInterface(nil)
CheckSize(Types[TINTER])
defBasic := func(kind Kind, pkg *Pkg, name string) *Type {
// any type (interface)
DeferCheckSize()
AnyType = defBasic(TFORW, BuiltinPkg, "any")
- AnyType.SetUnderlying(NewInterface(BuiltinPkg, []*Field{}, false))
+ AnyType.SetUnderlying(NewInterface(nil))
ResumeCheckSize()
Types[TUNSAFEPTR] = defBasic(TUNSAFEPTR, UnsafePkg, "Pointer")
}
func makeErrorInterface() *Type {
- sig := NewSignature(NoPkg, FakeRecv(), nil, nil, []*Field{
+ sig := NewSignature(FakeRecv(), nil, []*Field{
NewField(src.NoXPos, nil, Types[TSTRING]),
})
method := NewField(src.NoXPos, LocalPkg.Lookup("Error"), sig)
- return NewInterface(NoPkg, []*Field{method}, false)
+ return NewInterface([]*Field{method})
}
// makeComparableInterface makes the predefined "comparable" interface in the
// built-in package. It has a unique name, but no methods.
func makeComparableInterface() *Type {
- return NewInterface(NoPkg, nil, false)
+ return NewInterface(nil)
}
// Create new function type with parameters prepended, and
// then update type and declarations.
- typ = types.NewSignature(typ.Pkg(), nil, nil, append(params, typ.Params().FieldSlice()...), typ.Results().FieldSlice())
+ typ = types.NewSignature(nil, append(params, typ.Params().FieldSlice()...), typ.Results().FieldSlice())
f.SetType(typ)
clofn.Dcl = append(decls, clofn.Dcl...)
// TODO(austin): This creates an ir.Name with a nil Func.
n := typecheck.NewName(sym)
ir.MarkFunc(n)
- n.SetType(types.NewSignature(types.NoPkg, nil, nil, []*types.Field{
+ n.SetType(types.NewSignature(nil, []*types.Field{
types.NewField(base.Pos, nil, types.NewPtr(t)),
types.NewField(base.Pos, nil, types.NewPtr(t)),
}, []*types.Field{
// Keep in sync with src/runtime/select.go.
func scasetype() *types.Type {
if scase == nil {
- scase = types.NewStruct(types.NoPkg, []*types.Field{
+ scase = types.NewStruct([]*types.Field{
types.NewField(base.Pos, typecheck.Lookup("c"), types.Types[types.TUNSAFEPTR]),
types.NewField(base.Pos, typecheck.Lookup("elem"), types.Types[types.TUNSAFEPTR]),
})