title: Self.Type cannot be directly converted to AnyClass in extension to objective-c class in swift
body: <p>I'm trying to create fabric method to create UIViewController with correct nib name (to fix iOS8 default initialiser issue). To do it I have added extension:</p>
  
  <pre><code>extension UIViewController {    
      class func create() -&gt; Self {
          if #available(iOS 9.0, *) {
              return self.init()
          } else {
              let clsName = NSStringFromClass(self).componentsSeparatedByString(".").last!
              return self.init(nibName: clsName, bundle: nil)
          }
      }
  }
  </code></pre>
  
  <p>However compiler issues error: <code>Cannot convert value of type 'Self.Type' to expected argument type 'AnyClass' (aka 'AnyObject.Type')</code> in <code>NSStringFromClass(self)</code>. </p>
  
  <p>To fix it another extension method can be added and code rewritten to:</p>
  
  <pre><code>extension UIViewController {
      private class var nibNameForInitializer:String {
          return NSStringFromClass(self).componentsSeparatedByString(".").last!
      }
      class func create_() -&gt; Self {
          if #available(iOS 9.0, *) {
              return self.init()
          } else {
              return self.init(nibName: self.nibNameForInitializer, bundle: nil)
          }
      }
  }
  </code></pre>
  
  <p>However I want to understand the problem with first variant. </p>
  
  <p>As I understand, method returning <code>Self</code> is a kind of generic method. <code>Self</code> can be used in many contexts (e.g. class, struct, protocol, etc), however <code>Self.Type</code> matches <code>AnyClass</code> only for classes. </p>
  
  <p>In my case, compiler should know that <code>Self</code> refers to <code>UIViewController</code> and all its subclasses (since it is inside <code>UIViewController</code> extension), so <code>Self.Type</code> must be convertible to <code>AnyClass</code>. </p>
  
  <p>Do I miss anything, or it is correct behaviour, since compiler doesn't perform any additional type analysis for <code>Self</code>?</p>