go/printer: print pointer designation of type parameters in contracts

Also: Align start or methods and type lists.
Change-Id: Icae3be0ebcbc633d2ed88ff6f620dc078a7c698e
This commit is contained in:
Robert Griesemer 2020-03-31 22:11:48 -07:00
parent 49c8636998
commit e03920500c
3 changed files with 33 additions and 8 deletions

View File

@ -1107,13 +1107,16 @@ func (p *printer) expr(x ast.Expr) {
func (p *printer) constraint(x *ast.Constraint) {
p.print(x.Pos())
if x.Star.IsValid() {
p.print(token.MUL)
}
if x.Param == nil {
// embedded contract
p.expr(x.Types[0])
return
}
// method or list of types
p.print(x.Param, blank)
p.print(x.Param, vtab)
if len(x.MNames) > 0 && x.MNames[0] != nil {
// single method
// For now we only support a single method

View File

@ -13,23 +13,34 @@ contract (
)
contract _(T) {
T int
T float32, string, struct{}
T int
T float32, string, struct{}
(C0)
C0()
C1(T)
C2(T, T, T)
T m()
T int
T m()
T int
}
contract _(A, B, C) {
A a() // only a will be printed for now
B a()
A a() // only a will be printed for now
B a()
// a 1st comment
// a 2nd comment
C a()
C a()
}
contract _(A, Aa, Aaaa, Aaaaa) {
A m()
Aa m()
*Aaa m()
*Aaaa m()
Aaaaa int
A string
Aaaaa float32
}
type _(type T) interface{}

View File

@ -32,6 +32,17 @@ contract _(A, B, C) {
C a()
}
contract _(A, Aa, Aaaa, Aaaaa) {
A m()
Aa m()
*Aaa m()
*Aaaa m()
Aaaaa int
A string
Aaaaa float32
}
type _(type T) interface{}
type _(type T) interface{
m(T)