title: Swift enum with custom initializer loses rawValue initializer
body: <p>I have tried to boil this issue down to its simplest form with the following.</p>
  
  <h2>Setup</h2>
  
  <p>Xcode Version 6.1.1 (6A2008a)</p>
  
  <p>An enum defined in <code>MyEnum.swift</code>:</p>
  
  <pre><code>internal enum MyEnum: Int {
      case Zero = 0, One, Two
  }
  
  extension MyEnum {
      init?(string: String) {
          switch string.lowercaseString {
          case "zero": self = .Zero
          case "one": self = .One
          case "two": self = .Two
          default: return nil
          }
      }
  }
  </code></pre>
  
  <p>and code that initializes the enum in another file, <code>MyClass.swift</code>:</p>
  
  <pre><code>internal class MyClass {
      let foo = MyEnum(rawValue: 0)  // Error
      let fooStr = MyEnum(string: "zero")
  
      func testFunc() {
          let bar = MyEnum(rawValue: 1)  // Error
          let barStr = MyEnum(string: "one")
      }
  }
  </code></pre>
  
  <h2>Error</h2>
  
  <p>Xcode gives me the following error when attempting to initialize <code>MyEnum</code> with its raw-value initializer:</p>
  
  <pre><code>Cannot convert the expression's type '(rawValue: IntegerLiteralConvertible)' to type 'MyEnum?'
  </code></pre>
  
  <h2>Notes</h2>
  
  <ol>
  <li><p>Per <a href="https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html#//apple_ref/doc/uid/TP40014097-CH12-XID_226" rel="noreferrer">the Swift Language Guide</a>:</p>
  
  <blockquote>
    <p>If you define an enumeration with a raw-value type, the enumeration automatically receives an initializer that takes a value of the raw value’s type (as a parameter called <code>rawValue</code>) and returns either an enumeration member or <code>nil</code>.</p>
  </blockquote></li>
  <li><p>The custom initializer for <code>MyEnum</code> was defined in an extension to test whether the enum's raw-value initializer was being removed because of the following case from <a href="https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-XID_321" rel="noreferrer">the Language Guide</a>. However, it achieves the same error result.</p>
  
  <blockquote>
    <p>Note that if you define a custom initializer for a value type, you will no longer have access to the default initializer (or the memberwise initializer, if it is a structure) for that type. [...]<br>
    If you want your custom value type to be initializable with the default initializer and memberwise initializer, and also with your own custom initializers, write your custom initializers in an extension rather than as part of the value type’s original implementation.</p>
  </blockquote></li>
  <li><p>Moving the enum definition to <code>MyClass.swift</code> resolves the error for <code>bar</code> but not for <code>foo</code>.</p></li>
  <li><p>Removing the custom initializer resolves both errors.</p></li>
  <li><p>One workaround is to include the following function in the enum definition and use it in place of the provided raw-value initializer. So it seems as if adding a custom initializer has a similar effect to marking the raw-value initializer <code>private</code>.</p>
  
  <pre><code>init?(raw: Int) {
      self.init(rawValue: raw)
  }
  </code></pre></li>
  <li><p>Explicitly declaring protocol conformance to <code>RawRepresentable</code> in <code>MyClass.swift</code> resolves the inline error for <code>bar</code>, but results in a linker error about duplicate symbols (because raw-value type enums implicitly conform to <code>RawRepresentable</code>).</p>
  
  <pre><code>extension MyEnum: RawRepresentable {}
  </code></pre></li>
  </ol>
  
  <p>Can anyone provide a little more insight into what's going on here? Why isn't the raw-value initializer accessible?</p>