title: How to get list of fields and subfields of a Scala case class
body: <p>I have a nested data structure in case classes, like</p>
  
  <p><strong>Update2</strong> All vals are optional</p>
  
  <pre><code>case class A(b:Option[B] = None,c:Option[C] = None,d:Option[D] = None)
  case class B(id:Option[String] = None, name:Option[String] = None)
  case class C(cNode:Option[String] = None, cuser:Option[String] = None)
  case class D(dData:Option[String] = None, dField:Option[String] = None)
  </code></pre>
  
  <p>I'm looking for a regex to track all fields from the Class A, through all of it's subclasses.</p>
  
  <p>The code from <a href="https://stackoverflow.com/a/31190112/1791289" title="this">this</a> answer solve the first step of my problem. It list all of the fields of the first level (class A). I tried to change it to recursive call the same method but I can't get the TypeTag information of a MethodSymbol.</p>
  
  <p>The result I'm expecting for this is a method that receives A as argument, and returns</p>
  
  <blockquote>
    <p>(b.id, b.name,c.cNode, c.cUser,d.dData, d.dFile)</p>
  </blockquote>
  
  <p>How can I get the subfields attribute names from a case class?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I'm using scala 2.11</p>
  
  <p>I also want it to be generated by reflection/macros because the data structure is complex and I want it to be updated when the case class are updated.</p>