From 696515ee396566ba02da145cf71fe5913d65b9a6 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 23 Nov 2021 20:56:33 -0800 Subject: [PATCH] spec: type assertions and switches don't operate on type parameters Change-Id: I11111b3617673be94508128489aed6488d518537 Reviewed-on: https://go-review.googlesource.com/c/go/+/366834 Trust: Robert Griesemer Reviewed-by: Ian Lance Taylor --- doc/go_spec.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 0fc5b4590f..b8e6aceee9 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -3884,8 +3884,9 @@ If the indices are out of range at run time, a run-ti

Type assertions

-For an expression x of interface type -and a type T, the primary expression +For an expression x of interface type, +but not a type parameter, and a type T, +the primary expression

@@ -5677,7 +5678,8 @@ switch x.(type) {
 

Cases then match actual types T against the dynamic type of the expression x. As with type assertions, x must be of -interface type, and each non-interface type +interface type, but not a +type parameter, and each non-interface type T listed in a case must implement the type of x. The types listed in the cases of a type switch must all be different.