title: Dynamic member lookup with multiple keypaths for enums with associated values
body: <p>Implementing dynamic member lookup on an enum with associated values leads to build errors when there is more than one keypath function.</p>
  <p>I have an enum with multiple associates values, as described below:</p>
  <pre><code>@dynamicMemberLookup
  enum Media {
      case movie(Movie)
      case book(Book)
      
      subscript&lt;T&gt;(dynamicMember keyPath: KeyPath&lt;Entertainment, T&gt;) -&gt; T {
          switch self {
              case .movie(let movie):
                  return movie[keyPath: keyPath]
              case .book(let book):
                  return book[keyPath: keyPath]
          }
      }
  }
  </code></pre>
  <p>The structs <code>Movie</code> and <code>Book</code> inherit protocols <code>Filmed</code> and <code>Written</code>, which themselves inherit from the more generic protocol <code>Entertainment</code>:</p>
  <pre><code>protocol Entertainment {
      var isbn: Int { get }
      var title: String { get }
      var sales: Int { get set }
  }
  
  protocol Written: Entertainment {
      var author: String { get }
  }
  
  protocol Filmed: Entertainment {
      var actors: [String] { get set }
  }
  
  struct Movie: Filmed {
      var isbn: Int
      var title: String
      var sales: Int
      var actors: [String]
  }
  
  struct Book: Written {
      var isbn: Int
      var title: String
      var sales: Int
      var author: String
  }
  </code></pre>
  <p>So far, this works and has allowed me to access variables such as <code>isbn</code> and <code>title</code>, which are defined in <code>Entertainment</code>, from the top-level <code>Media</code> object through the subscript keypath lookup.</p>
  <pre><code>let media: Media = .movie(Movie(isbn: 1011, title: &quot;Top Gun&quot;, sales: 1000, actors: [&quot;Tom Cruise&quot;, &quot;Miles Teller&quot;]))
  
  print(media.title)
  print(media.sales)
  </code></pre>
  <p>Now, when I try to add the subscript function below in <code>Media</code> so that I can optionally access variables conforming to either <code>Filmed</code> or <code>Written</code>, I receive an error for the above print statements stating <code>Ambiguous use of 'subscript(dynamicMember:)'</code></p>
  <pre><code>subscript&lt;T&gt;(dynamicMember keyPath: KeyPath&lt;Filmed, T&gt;) -&gt; T? {
      switch self {
          case .movie(let movie):
              return movie[keyPath: keyPath]
          default:
              return nil
      }
  }
  </code></pre>
  <p>In this example, the build errors are as follows:</p>
  <pre><code>let media: Media = .movie(Movie(isbn: 1011, title: &quot;Top Gun&quot;, sales: 1000, actors: [&quot;Tom Cruise&quot;, &quot;Miles Teller&quot;]))
  
  print(media.title) // BUILD ERROR: Ambiguous use of 'subscript(dynamicMember:)'
  print(media.sales) // BUILD ERROR: Ambiguous use of 'subscript(dynamicMember:)'
  print(media.actors) // This doesn't throw an error and successfully logs
  </code></pre>
  <p>When I remove the second subscript function, the build errors are gone.</p>
  <p>Please let me know if I'm doing anything wrong in my implementation here.</p>