title: Subclassing overloaded operators
body: <p>I have a class <code>A</code> overloading the <code>+</code> operator, and a class <code>B</code> inheriting from <code>A</code>. I'd like the sum of two instances of <code>B</code> to be an instance of <code>B</code>.</p>
  <p>I'm able to do that only by overload the <code>+</code> operator in <code>B</code>, which I'd like to avoid. Is there a way to achieve that in Swift ?</p>
  <pre class="lang-swift prettyprint-override"><code>class A {
      var a: Double
      init(_ a: Double = 0) { self.a = a }
      init(_ a: A) { self.a = a.a }
      static func +(_ lhs: A, _ rhs: A) -&gt; A {
          A(lhs.a + rhs.a)
      }
  }
  
  class B : A {
      static func +(_ lhs: B, _ rhs: B) -&gt; B {
          return B((lhs as A) + (rhs as A))   // I'd rather avoid this part
      }
  }
  
  func test() {
      let a1 = A(4)
      let a2 = A(2)
      let sa = a1 + a2   // typed to A
      
      let b1 = B(3)
      let b2 = B(2)
      let sb = b1 + b2  // typed to B
      
      let sa = a + b    // typed to A, which is OK
  }
  </code></pre>
  <p>I looked into <code>Self</code> but it appears it can't be used a function parameters.</p>