mirror of https://github.com/golang/go.git
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 <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
6ea17aa52c
commit
696515ee39
|
|
@ -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>
|
<h3 id="Type_assertions">Type assertions</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
For an expression <code>x</code> of <a href="#Interface_types">interface type</a>
|
For an expression <code>x</code> of <a href="#Interface_types">interface type</a>,
|
||||||
and a type <code>T</code>, the primary expression
|
but not a <a href="#Type_parameters">type parameter</a>, and a type <code>T</code>,
|
||||||
|
the primary expression
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
|
@ -5677,7 +5678,8 @@ switch x.(type) {
|
||||||
<p>
|
<p>
|
||||||
Cases then match actual types <code>T</code> against the dynamic type of the
|
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
|
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>.
|
<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
|
The types listed in the cases of a type switch must all be
|
||||||
<a href="#Type_identity">different</a>.
|
<a href="#Type_identity">different</a>.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue