title: Can one use generic sub classes with function builders in Swift?
body: <p>While using function builders, i'm unable to use the variadic return builder closure on an object  in conjunction with subclassing + generics. The Swift Playground can be found here.</p>
  <p>First, lets define our function builder. In this case, I will be using one which supports both array + variadic initialization, as well as generics:</p>
  <pre><code>@_functionBuilder struct Builder&lt;T&gt; {
  
      static func buildBlock(_ items: T...) -&gt; [T] {
          items
      }
  
      static func buildBlock(_ items: [T]) -&gt; [T] {
          items
      }
  }
  </code></pre>
  <p>Next, I defined a generic container object which supports builder initialization, and retains an array of objects.</p>
  <pre><code>class Container&lt;T&gt; {
  
      let items: [T]
  
      init(@Builder&lt;T&gt; builder: () -&gt; [T]) {
          self.items = builder()
      }
  }
  </code></pre>
  <p>Finally, i've sub-classed this object to define a &quot;Navigation Controller&quot; abstraction:</p>
  <pre><code>  struct View { }
  
    final class NavigationController: Container&lt;View&gt; { }
  
    let nav = NavigationController {
        View()
    }
  </code></pre>
  <p>This is where the following error is produced by Xcode: <code>Cannot convert value of type 'View' to closure result type '[View]'</code>.</p>
  <p>This seems odd because the function builder should know to use the variadic initializer instead of the array initializer, but no.</p>
  <p>To test my theory, I defined an object which <em>did not</em> sub-class another, but used the builder syntax as it's defined in my generic <code>Container</code> implementation.</p>
  <pre><code>  class Nav {
  
        let views: [View]
  
        init(@Builder&lt;View&gt; builder: () -&gt; [View]) {
            views = builder()
        }
    }
  
    let y = Nav {
        View()
    }
  </code></pre>
  <p>This work's fine, and compiles and runs without issue. It would seem that subclassing combined with generics confuses the compiler about which function builder initialization definition to use, the one that returns an array or the one that returns a variadic list.</p>
  <p>Has anyone run into this before?</p>