title: Cannot convert value of type to expected argument type when the type is an associated type
body: <p>Here is the <strong>swift 4</strong> code:</p>
  
  <pre><code>protocol BarProtocol {
      associatedtype Bar
      var bar:Bar? {get set}
  }
  
  class FooClass : BarProtocol {
      //typealias Bar = (String) -&gt; ()
      typealias Bar = (String)
      var bar: Bar?
  }
  
  func configFooClass&lt;T:BarProtocol&gt;(fooClass:inout T, bar:T.Bar) {
      fooClass.bar = bar
  }
  func setupFooClass(fooClass:inout FooClass, bar:FooClass.Bar) {
      configFooClass(fooClass: &amp;fooClass, bar: bar)
  }
  
  var fooClass = FooClass()
  var barString = "barString"
  //let barAction:(String) -&gt; () = { text in
  //    print(text)
  //}
  
  setupFooClass(fooClass:&amp;fooClass, bar:barString)
  print(fooClass.bar) // print: Optional("barString")
  </code></pre>
  
  <p>So far so good, it will print "Optional("barString")" in console. The associatedtype in class FooClass in String type now, so it can store string value "barString".</p>
  
  <p>But if I change this code to :</p>
  
  <pre><code>protocol BarProtocol {
      associatedtype Bar
      var bar:Bar? {get set}
  }
  
  class FooClass : BarProtocol {
      typealias Bar = (String) -&gt; ()
  //    typealias Bar = (String)
      var bar: Bar?
  }
  
  func configFooClass&lt;T:BarProtocol&gt;(fooClass:inout T, bar:T.Bar) {
      fooClass.bar = bar
  }
  func setupFooClass(fooClass:inout FooClass, bar:FooClass.Bar) {
      configFooClass(fooClass: &amp;fooClass, bar: bar) 
  // Error here: Cannot convert value of type '(String) -&gt; ()' to expected argument type '_.Bar'
  }
  
  var fooClass = FooClass()
  var barString = "barString"
  let barAction:(String) -&gt; () = { text in
      print(text)
  }
  
  //setupFooClass(fooClass:&amp;fooClass, bar:barString)
  //print(fooClass.bar)
  setupFooClass(fooClass:&amp;fooClass, bar:barAction)
  fooClass.bar!("lalalalala")
  </code></pre>
  
  <p>Actually, I just change the FooClass's associatedtype from String to (String) -> (), it will have an arror: Cannot convert value of type '(String) -> ()' to expected argument type '_.Bar'</p>
  
  <p>I don't understand, it seems closure can pass as parameter of function. But why 'String' type work well but '(String) -> ()' does not?</p>