title: Swift generic class type both subclass and conforms to protocol
body: <p>I'm trying to write a generic class in Swift who's generic type both inherits from a class and conforms to a protocol. However, the following code results in a compiler crash with Segmentation fault: 11.</p>
  
  <pre><code>protocol Protocol {
      var protocolProperty: Any? { get }
  }
  
  class Class {
      var classProperty: Any?
  }
  
  class GenericClass&lt;T: Class where T: Protocol&gt; {
  
      var genericProperty: T?
  
      func foo() {
          let classProperty: Any? = genericProperty!.classProperty
          // This is the culprit
          let protocolProperty: Any? = genericProperty!.protocolProperty
      }
  
  }
  </code></pre>
  
  <p>Commenting out the access to the protocol property allows the program to compile. There is no way to access anything from the protocol without the compiler crashing. Is there a workaround to creating a generic class that works like this?</p>