]> Cypherpunks repositories - gostls13.git/commitdiff
spec: type assertions and switches don't operate on type parameters
authorRobert Griesemer <gri@golang.org>
Wed, 24 Nov 2021 04:56:33 +0000 (20:56 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 24 Nov 2021 20:54:12 +0000 (20:54 +0000)
Change-Id: I11111b3617673be94508128489aed6488d518537
Reviewed-on: https://go-review.googlesource.com/c/go/+/366834
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
doc/go_spec.html

index 0fc5b4590f9060a4fbf0d94616f75aa8bc40986a..b8e6aceee9cd21d54dd61718bbb94f7bf6c3a494 100644 (file)
@@ -3884,8 +3884,9 @@ If the indices are out of range at run time, a <a href="#Run_time_panics">run-ti
 <h3 id="Type_assertions">Type assertions</h3>
 
 <p>
-For an expression <code>x</code> of <a href="#Interface_types">interface type</a>
-and a type <code>T</code>, the primary expression
+For an expression <code>x</code> of <a href="#Interface_types">interface type</a>,
+but not a <a href="#Type_parameters">type parameter</a>, and a type <code>T</code>,
+the primary expression
 </p>
 
 <pre>
@@ -5677,7 +5678,8 @@ switch x.(type) {
 <p>
 Cases then match actual types <code>T</code> against the dynamic type of the
 expression <code>x</code>. As with type assertions, <code>x</code> must be of
-<a href="#Interface_types">interface type</a>, and each non-interface type
+<a href="#Interface_types">interface type</a>, but not a
+<a href="#Type_parameters">type parameter</a>, and each non-interface type
 <code>T</code> listed in a case must implement the type of <code>x</code>.
 The types listed in the cases of a type switch must all be
 <a href="#Type_identity">different</a>.