From 388816ae078ed93ec409dca8024638eb7ca774d7 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Feb 2012 14:35:00 -0500 Subject: [PATCH] spec: disallow recursive embedded interfaces Fixes #1814. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5647054 --- doc/go_spec.html | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index ff7ce325ca..8b2d515df0 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1120,9 +1120,10 @@ they implement the Lock interface as well as the File interface.

-An interface may contain an interface type name T +An interface may use an interface type name T in place of a method specification. -The effect is equivalent to enumerating the methods of T explicitly +The effect, called embedding an interface, +is equivalent to enumerating the methods of T explicitly in the interface.

@@ -1139,6 +1140,26 @@ type File interface { } +

+An interface definition for type T may not embed itself, +nor any interface type that embeds T directly or indirectly. +

+ +
+// illegal: Bad cannot embed itself
+type Bad interface {
+	Bad
+}
+
+// illegal: Bad1 cannot embed itself using Bad2
+type Bad1 interface {
+	Bad2
+}
+type Bad2 interface {
+	Bad1
+}
+
+

Map types

-- 2.50.0