title: Swift protocol extension self reference issues with init
body: <p>I'm looking for a way to add a default initializer to a protocol via protocol extensions.</p>
  
  <p>My protocol is:</p>
  
  <pre><code>protocol TestProtocol {
      var myVar : Double { get set }
      init(value: Double)
      init(existingStruct : TestProtocol)
  }
  </code></pre>
  
  <p>I've implemented a struct using this protocol as:</p>
  
  <pre><code>struct TestStruct : TestProtocol {
      var myVar : Double
  
      init(value : Double) {
          myVar = value
      }
  
      init (existingStruct : TestProtocol) {
          myVar = existingStruct.myVar
      }
  }
  </code></pre>
  
  <p>However if I try via <strong>extension</strong> to make a default initializer for this protocol I run into self issues:</p>
  
  <pre><code>extension TestProtocol {
      init(value : Double) {
          myVar = value
      }
  
      init(existingStruct : TestProtocol) {
          myVar = existingStruct.myVar
      }
  }
  </code></pre>
  
  <p>Where both assignment lines issue the error 
  <strong>Variable 'self' passed by reference before being initialized</strong></p>
  
  <p>Is there a way to make this work - or am i limited to using classes?</p>
  
  <p><img src="https://i.stack.imgur.com/Pvneu.png" alt="enter image description here"></p>