aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@google.com>2026-01-20 11:31:37 -0800
committerGopher Robot <gobot@golang.org>2026-01-20 12:12:57 -0800
commitf07cd5e437d8fd17461645106a522516e5bee9a8 (patch)
treed00f60b04f5e026c373fe151356a2b90ad8112fe
parent9ff9e89742498021efc29959f0c648c0409b43f5 (diff)
downloadgo-x-website-f07cd5e437d8fd17461645106a522516e5bee9a8.tar.xz
_content/doc/go1.26: document removal of cycle restriction for type parameters
For golang/go#75005. For golang/go#75883. Change-Id: I5317913aecc82bd941067863c0a6ea7ae06451f3 Reviewed-on: https://go-review.googlesource.com/c/website/+/737600 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
-rw-r--r--_content/doc/go1.26.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/_content/doc/go1.26.md b/_content/doc/go1.26.md
index c8974122..b8c6c066 100644
--- a/_content/doc/go1.26.md
+++ b/_content/doc/go1.26.md
@@ -45,6 +45,28 @@ func yearsSince(t time.Time) int {
}
```
+<!-- https://go.dev/issue/75883 --->
+
+The restriction that a generic type may not refer to itself in its type parameter list
+has been lifted.
+It is now possible to specify type constraints that refer to the generic type being
+constrained.
+For instance, a generic type `Adder` may require that it be instantiated with a
+type that is like itself:
+
+```go
+type Adder[A Adder[A]] interface {
+ Add(A) A
+}
+
+func algo[A Adder[A]](x, y A) A {
+ return x.Add(y)
+}
+```
+
+Besides making type constraints more powerful, this change also simplifies the spec
+rules for type parameters ever so slightly.
+
## Tools {#tools}
### Go command {#go-command}