mirror of
https://github.com/golang/go
synced 2024-11-25 02:07:58 -07:00
spec: disallow recursive embedded interfaces
Fixes #1814. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5647054
This commit is contained in:
parent
fd2a511253
commit
388816ae07
@ -1120,9 +1120,10 @@ they implement the <code>Lock</code> interface as well
|
|||||||
as the <code>File</code> interface.
|
as the <code>File</code> interface.
|
||||||
</p>
|
</p>
|
||||||
<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.
|
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.
|
in the interface.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -1139,6 +1140,26 @@ type File interface {
|
|||||||
}
|
}
|
||||||
</pre>
|
</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>
|
<h3 id="Map_types">Map types</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user