Access control for enum cases

Has exhaustivity of nested patterns been discussed? It would be a shame to have to nest switch statements just to get public exhaustivity. For example, if I wanted to switch on an instance of this:

enum Parent {
  case child(Child)

  enum Child {
    case tap
    internal case response
  }
}

I must nest switches to ensure a warning when new public cases are added:

switch parent {
case let .child(child):
  switch child {
  case .tap:
    break
  }
}

I'd like to flatten that nesting, but I imagine the warning will be lost in the following:

switch parent {
case .child(.tap):
  break
case .child:
  break
}

It'd be nice if @unknown could be used as a sub-pattern:

switch parent {
case .child(.tap):
  break
case .child(@unknown):
  break
}
6 Likes