]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/syntax: allow eliding interface in constraint literals
authorRobert Griesemer <gri@golang.org>
Wed, 29 Sep 2021 18:14:05 +0000 (11:14 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 1 Oct 2021 17:18:20 +0000 (17:18 +0000)
commit5279e534b5ced1eaea19e8b75968498287ff6228
treece9feca68f08d6cff663f7d310e70046e717beaa
parentf19b2d50c6d9918c1c121ccd8cb2a4f4a2d3f30b
cmd/compile/internal/syntax: allow eliding interface in constraint literals

This CL permits an arbitrary type as well as the type sets  ~T and A|B
in constraint position, without the need of a surrrounding interface.
For instance, the type parameter list

[P interface{ ~map[K]V }, K comparable, V interface{ ~string }]

may be written as

[P ~map[K]V, K comparable, V ~string]

The feature must be enabled explicitly with the AllowTypeSets mode
and is only available if AllowGenerics is set as well.

For #48424.

Change-Id: Ic70bb97a49ff75e67e040853eac10e6aed0fef1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353133
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/syntax/error_test.go
src/cmd/compile/internal/syntax/parser.go
src/cmd/compile/internal/syntax/parser_test.go
src/cmd/compile/internal/syntax/printer_test.go
src/cmd/compile/internal/syntax/syntax.go
src/cmd/compile/internal/syntax/testdata/typeset.go2 [new file with mode: 0644]