title: Swift generics: Non-nominal type does not support explicit initialization
body: <p>So I'm trying to understand generic protocols and classes:</p>
  
  <pre><code>protocol ListPresenterType where View.PDO.SW == Dispatcher.SW {
      associatedtype Dispatcher: ListDispatcherType
      associatedtype View: ListViewType
  
      init(dispatcher: Dispatcher, state: @escaping (_ state: AppState)-&gt;(ListState&lt;Dispatcher.SW&gt;))
  
      func attachView(_ view: View)
      ...
  }
  </code></pre>
  
  <p>And I'm initiating it from another generic class:</p>
  
  <pre><code>class AbstractListViewController&lt;Presenter: ListPresenterType, PDO: ListPDOCommonType, ...&gt;: ListViewType, ... where PDO.SW == Presenter.Dispatcher.SW, ... {
      func configure(withBla: bla) {
          ...
          presenter = Presenter(dispatcher: dispatcher, state: state)
      }
  
      func someFunc() {
          presenter.attachView(self) // ERROR: Cannot invoke 'attachView' with an argument list of type ...
  }
  </code></pre>
  
  <p>As I understand, I'm trying to initialize a type conforming to a generic protocol, which works just fine, but the type of View must be inconsistent with what I'm trying to feed it in <code>attachView(:)</code>.</p>
  
  <p>Then I try to initialize it with concrete view, changing <code>init</code>:</p>
  
  <pre><code>init(dispatcher: Dispatcher, view: View, state: @escaping (_ state: AppState)-&gt;(ListState&lt;Dispatcher.SW&gt;)) { 
      self.view = view 
      ... 
  }
  </code></pre>
  
  <p>And in <code>AbstractListViewController</code>:</p>
  
  <pre><code>presenter = Presenter(dispatcher: dispatcher, view: self, state: state)
  </code></pre>
  
  <p>And getting this infamous error:</p>
  
  <pre><code>Non-nominal type 'Presenter' does not support explicit initialization
  </code></pre>
  
  <p>Here're gists with relevant playgrounds:</p>
  
  <ol>
  <li>Successful init (though cannot invoke <code>attachView(:)</code>) <a href="https://gist.github.com/nikans/0fde838846ffa9ff2da48c923f850625" rel="nofollow noreferrer">https://gist.github.com/nikans/0fde838846ffa9ff2da48c923f850625</a></li>
  <li>Init failing with aforementioned error: <a href="https://gist.github.com/nikans/53c3ea146ceb12dc8461f7ba8a81793d" rel="nofollow noreferrer">https://gist.github.com/nikans/53c3ea146ceb12dc8461f7ba8a81793d</a></li>
  </ol>
  
  <p>Please notice that every empty protocol there is in fact a generic protocol, I've just removed the unnecessary details.</p>
  
  <hr>
  
  <p>I'd like to understand:</p>
  
  <ol>
  <li>What makes a "nominal" type "non-nominal" all of a sudden (nothing to be surprised of, it's a generic parameter conforming to a generic protocol, but I don't understand the causation).</li>
  <li>I heard something about type erasure, but didn't quite get if it is applicable here.</li>
  </ol>
  
  <p>Thanks.</p>