<p dir="auto">Should this program work?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main

type T interface {
    m() interface {T}
}

type foo struct {
}

func (f *foo) m() interface {T} {
  return &amp;foo{}
}

func main() {
    var t T
    t = &amp;foo{}
    t.m()
}"><pre class="notranslate"><code class="notranslate">package main

type T interface {
    m() interface {T}
}

type foo struct {
}

func (f *foo) m() interface {T} {
  return &amp;foo{}
}

func main() {
    var t T
    t = &amp;foo{}
    t.m()
}
</code></pre></div>
<p dir="auto">It seems to compile but panics when run:<br>
<a href="http://play.golang.org/p/swxTnFlwQI" rel="nofollow">http://play.golang.org/p/swxTnFlwQI</a></p>
<p dir="auto">By contrast this program works fine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main

type T interface {
    m() T
}

type foo struct {
}

func (f *foo) m() T {
    return &amp;foo{}
}

func main() {
    var t T
    t = &amp;foo{}
    t.m()
}"><pre class="notranslate"><code class="notranslate">package main

type T interface {
    m() T
}

type foo struct {
}

func (f *foo) m() T {
    return &amp;foo{}
}

func main() {
    var t T
    t = &amp;foo{}
    t.m()
}
</code></pre></div>
<p dir="auto"><a href="http://play.golang.org/p/Bxnf72xPsn" rel="nofollow">http://play.golang.org/p/Bxnf72xPsn</a></p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<ol dir="auto">
<li>What version of Go are you using (<code class="notranslate">go version</code>)?</li>
</ol>
<p dir="auto"><code class="notranslate">go1.6.2</code></p>
<ol dir="auto">
<li>What operating system and processor architecture are you using (<code class="notranslate">go env</code>)?</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GOARCH=&quot;amd64&quot;
GOHOSTARCH=&quot;amd64&quot;
GOHOSTOS=&quot;linux&quot;
GOOS=&quot;linux&quot;"><pre class="notranslate"><code class="notranslate">GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
</code></pre></div>
<ol dir="auto">
<li>What did you do?</li>
</ol>
<p dir="auto">I tried to define an interface that expects itself as the argument of one of its methods:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="type Nestable interface {
   AddChild(interface{Nestable})
}"><pre class="notranslate"><code class="notranslate">type Nestable interface {
   AddChild(interface{Nestable})
}
</code></pre></div>
<p dir="auto"><a href="https://play.golang.org/p/oB091DHIS2" rel="nofollow">https://play.golang.org/p/oB091DHIS2</a></p>
<ol dir="auto">
<li>What did you expect to see?</li>
</ol>
<p dir="auto">I would expect it to simply look for the desired signature of the argument passed in and accept it as valid</p>
<ol dir="auto">
<li>What did you see instead?</li>
</ol>
<p dir="auto">It seems it recursively walk the full interface definition so it enters som kind of loop</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="panic: interface conversion: *main.TreeNode is not interface { AddChild(interface { AddChild(interface { AddChild(interface { AddChild(interface { AddChild(interface { AddChild&lt;...&gt; }) }) }) }) }) }: missing method AddChild"><pre class="notranslate"><code class="notranslate">panic: interface conversion: *main.TreeNode is not interface { AddChild(interface { AddChild(interface { AddChild(interface { AddChild(interface { AddChild(interface { AddChild&lt;...&gt; }) }) }) }) }) }: missing method AddChild
</code></pre></div>