1
0
mirror of https://github.com/golang/go synced 2024-11-11 23:50:22 -07:00

[dev.typeparams] cmd/compile/internal/types2: use the TParams API consistently

This is a clean port of CL 336251.

Change-Id: I08415c3e9b6cef33594e7d56c4115ddde8030381
Reviewed-on: https://go-review.googlesource.com/c/go/+/338193
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2021-07-28 15:38:28 -07:00
parent 27552e9172
commit 46cc686381
4 changed files with 6 additions and 6 deletions

View File

@ -57,7 +57,7 @@ func (check *Checker) funcInst(x *operand, inst *syntax.IndexExpr) {
// instantiate function signature
res := check.Instantiate(x.Pos(), sig, targs, poslist, true).(*Signature)
assert(res.tparams == nil) // signature is not generic anymore
assert(res.TParams().Len() == 0) // signature is not generic anymore
if inferred {
check.recordInferred(inst, targs, res)
}
@ -327,7 +327,7 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T
// compute result signature
rsig = check.Instantiate(call.Pos(), sig, targs, nil, true).(*Signature)
assert(rsig.tparams == nil) // signature is not generic anymore
assert(rsig.TParams().Len() == 0) // signature is not generic anymore
check.recordInferred(call, targs, rsig)
// Optimization: Only if the parameter list was adjusted do we

View File

@ -575,7 +575,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named
named.underlying = under(named)
// If the RHS is a type parameter, it must be from this type declaration.
if tpar, _ := named.underlying.(*TypeParam); tpar != nil && tparamIndex(named.tparams.list(), tpar) < 0 {
if tpar, _ := named.underlying.(*TypeParam); tpar != nil && tparamIndex(named.TParams().list(), tpar) < 0 {
check.errorf(tdecl.Type, "cannot use function type parameter %s as RHS in type declaration", tpar)
named.underlying = Typ[Invalid]
}

View File

@ -187,7 +187,7 @@ func (subst *subster) typ(typ Type) Type {
}
}
if t.TParams() == nil {
if t.TParams().Len() == 0 {
dump(">>> %s is not parameterized", t)
return t // type is not parameterized
}

View File

@ -278,7 +278,7 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) {
buf.WriteByte('[')
writeTypeList(buf, t.targs, qf, visited)
buf.WriteByte(']')
} else if t.TParams() != nil {
} else if t.TParams().Len() != 0 {
// parameterized type
writeTParamList(buf, t.TParams().list(), qf, visited)
}
@ -425,7 +425,7 @@ func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier) {
}
func writeSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier, visited []Type) {
if sig.tparams != nil {
if sig.TParams().Len() != 0 {
writeTParamList(buf, sig.TParams().list(), qf, visited)
}