title: Can't get Codable to work with inheritance
body: <p>I want to be able to convert classes to dictionaries, but I'm having an issue when one class derives from another. Here's an example illustrating the issue:</p>
  <pre><code>class Base: Codable {
      var b = &quot;base&quot;
  }
  
  class Derived: Base {
      var d = &quot;derived&quot;
  
      func serializeToDictionary() -&gt; [String: Any]? {
          if let data = (try? JSONEncoder().encode(self)) {
              return (try? JSONSerialization.jsonObject(with: data, options: .fragmentsAllowed) as? [String: Any]) ?? [:]
          } else {
              return nil
          }
      }
  }
  
  let d = Derived()
  let dict = d.serializeToDictionary()
  </code></pre>
  <p><code>dict</code> only contains one key/value pair -  b/&quot;base&quot;</p>
  <p>Why does <code>dict</code> not contain two pairs? Why does it not contain a dictionary item for d/&quot;derived&quot;?</p>