title: 'Self' is only available in a protocol or as the result of a class method
body: <p><strong>Update</strong>: Swift 3 permits <code>Self</code> to be used from other types, thanks to <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md" rel="nofollow">SE-0068 – Expanding Swift Self to class members and value types</a>.</p>
  
  <p>You can return "Self" from a class function:</p>
  
  <pre><code>extension NSObject {
      class func makeOne() -&gt; Self {
          return self()
      }
  }
  </code></pre>
  
  <p>So you can do:</p>
  
  <pre><code>let set : NSCountedSet = NSCountedSet.makeOne()
  </code></pre>
  
  <p>However, the following two don't compile:</p>
  
  <pre><code>extension NSObject {
      class func makeTwo() -&gt; (Self, Self) {
          return (self(), self())
      }
  
      class func makeMany() -&gt; [Self] {
          return [self(), self(), self(), self(), self()]
      }
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>&lt;REPL&gt;:11:34: error: 'Self' is only available in a protocol or as the result of a class method; did you mean 'NSObject'?
          class func makeTwo() -&gt; (Self, Self) {
                                   ^~~~
                                   NSObject
  &lt;REPL&gt;:11:40: error: 'Self' is only available in a protocol or as the result of a class method; did you mean 'NSObject'?
          class func makeTwo() -&gt; (Self, Self) {
                                         ^~~~
                                         NSObject
  &lt;REPL&gt;:15:35: error: 'Self' is only available in a protocol or as the result of a class method; did you mean 'NSObject'?
          class func makeMany() -&gt; [Self] {
                                    ^~~~
                                    NSObject
  </code></pre>
  
  <p>Does anyone know of any way to declare that a class function returns multiple instances of the class itself?</p>