]> Cypherpunks repositories - gostls13.git/commitdiff
spec: disallow recursive embedded interfaces
authorRuss Cox <rsc@golang.org>
Wed, 8 Feb 2012 19:35:00 +0000 (14:35 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 8 Feb 2012 19:35:00 +0000 (14:35 -0500)
Fixes #1814.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5647054

doc/go_spec.html

index ff7ce325ca7adf6128d72ce4f723b2ad9e3a56da..8b2d515df0eb3f9cb0f022d0f4ea2d428785ef7e 100644 (file)
@@ -1120,9 +1120,10 @@ they implement the <code>Lock</code> interface as well
 as the <code>File</code> interface.
 </p>
 <p>
-An interface may contain an interface type name <code>T</code>
+An interface may use an interface type name <code>T</code>
 in place of a method specification.
-The effect is equivalent to enumerating the methods of <code>T</code> explicitly
+The effect, called embedding an interface,
+is equivalent to enumerating the methods of <code>T</code> explicitly
 in the interface.
 </p>
 
@@ -1139,6 +1140,26 @@ type File interface {
 }
 </pre>
 
+<p>
+An interface definition for type <code>T</code> may not embed itself,
+nor any interface type that embeds <code>T</code> directly or indirectly.
+</p>
+
+<pre>
+// illegal: Bad cannot embed itself
+type Bad interface {
+       Bad
+}
+
+// illegal: Bad1 cannot embed itself using Bad2
+type Bad1 interface {
+       Bad2
+}
+type Bad2 interface {
+       Bad1
+}
+</pre>
+
 <h3 id="Map_types">Map types</h3>
 
 <p>