cmd/compile/internal/syntax, types2: remove ability to handle type lists

The type set notation has been accepted a while ago.
We're not going back to supporting the original
type list notation. Remove support for it in the
parser and type checker.

Change-Id: I860651f80b89fa43a3a5a2a02cf823ec0dae583c
Reviewed-on: https://go-review.googlesource.com/c/go/+/354131
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2021-10-05 14:03:47 -07:00
parent 6487b1573e
commit f05c67f182
13 changed files with 29 additions and 162 deletions

View file

@ -1450,30 +1450,6 @@ func (p *parser) interfaceType() *InterfaceType {
return false
}
case _Type:
// TODO(gri) remove TypeList syntax if we accept #45346
if p.allowGenerics() && p.mode&AllowTypeLists != 0 {
type_ := NewName(p.pos(), "type") // cannot have a method named "type"
p.next()
if p.tok != _Semi && p.tok != _Rbrace {
f := new(Field)
f.pos = p.pos()
f.Name = type_
f.Type = p.type_()
typ.MethodList = append(typ.MethodList, f)
for p.got(_Comma) {
f := new(Field)
f.pos = p.pos()
f.Name = type_
f.Type = p.type_()
typ.MethodList = append(typ.MethodList, f)
}
} else {
p.syntaxError("expecting type")
}
return false
}
default:
if p.allowGenerics() {
pos := p.pos()
@ -1488,13 +1464,8 @@ func (p *parser) interfaceType() *InterfaceType {
}
if p.allowGenerics() {
if p.mode&AllowTypeLists != 0 {
p.syntaxError("expecting method, type list, or embedded element")
p.advance(_Semi, _Rbrace, _Type)
} else {
p.syntaxError("expecting method or embedded element")
p.advance(_Semi, _Rbrace)
}
p.syntaxError("expecting method or embedded element")
p.advance(_Semi, _Rbrace)
return false
}