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>
// 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)
}
// 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
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]
}
}
}
- if t.TParams() == nil {
+ if t.TParams().Len() == 0 {
dump(">>> %s is not parameterized", t)
return t // type is not parameterized
}
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)
}
}
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)
}