title: Swift error: Generic parameter 'T' is not used in function signature
body: <p>I'm trying to use generics to simplify some XML deserialization, however, Swift 2.0 is choking saying that I'm not using the generic in my method signature. I'm confused as to why it is throwing this error since I'm directly instantiating the class type passed in. Any suggestions as to the cause of this error? The exact error is:</p>
  
  <blockquote>
    <p>Generic parameter 'T' is not used in function signature</p>
  </blockquote>
  
  <p>MTXMLDeserializable is the base class I'm using and has the method: <code>init(properties: Dictionary&lt;String, String&gt;?, propertyMap: Dictionary&lt;String, String&gt;?)</code></p>
  
  <p>Here is the offending method:</p>
  
  <pre><code>func transformResponse&lt;T: MTXMLDeserializable&gt;(responseData: XMLIndexer?) -&gt; [MTXMLDeserializable]? {
    if let data = responseData {
      let properties = data["body"].children
      return properties.map {
        (xmlProps) -&gt; MTXMLDeserializable in
        let objProps = xmlProps.element!.attributes
        return (T.self as T.Type).init(properties: objProps, propertyMap: self.propertyMap)
      }
    } else {
      return .None
    }
  </code></pre>
  
  <p>Thinking that it may be choking on using the generic inside of the closure passed to <code>properties.map</code> I rewrote the method like so:</p>
  
  <pre><code>func transformResponse&lt;T: MTXMLDeserializable&gt;(responseData: XMLIndexer?) -&gt; [MTXMLDeserializable]? {
    if let data = responseData {
      let properties = data["body"].children
      let objs = NSMutableArray()
      for xmlProps in properties {
        let objProps = xmlProps.element!.attributes
        let obj = (T.self as T.Type).init(properties: objProps, propertyMap: self.propertyMap)
        objs.addObject(obj)
      }
      return objs as! NSArray
      } else {
    return .None
  }
  </code></pre>
  
  <p>Even switching from <code>(T.self as T.Type).init(properties: objProps, propertyMap: self.propertyMap)</code> to just using <code>T(properties: objProps, propertyMap: self.propertyMap)</code> doesn't fix the issue.</p>
  
  <p>I've done battle with the swift compiler over this and upgraded to Swift 2.0 hoping I can get around this issue with limited success (in Swift 1.2 it crashed the compiler, at least now it throws an error instead).</p>
  
  <p>I could have subclasses of this class pass their own closure for instantiating the type they are expecting and ditch using a generic for this, but I think this is nice and clean and saves writing all those overridden methods.</p>
  
  <p>Thanks for taking a look and any help is appreciated!</p>