Further refining pattern matches in switch statements

Given the following code:

enum FirstEnum {
  case firstCase(FirstStruct)
}

struct FirstStruct {
  let secondEnum: SecondEnum
}

enum SecondEnum {
  case secondCase(SecondStruct)
}

struct SecondStruct {
  let id: UUID
}

let someId: UUID = .init()  
let firstEnum: FirstEnum = .firstCase(.init(secondEnum: .secondCase(.init(id: someId))))

Then:

if
  case let .firstCase(firstStruct) = firstEnum,
  case let .secondCase(secondStruct) = firstStruct.secondEnum,
  secondStruct.id == someId
{
  ...
} else {
  ...  
}

Is it possible to turn that into a switch? The following code doesn't compile, for example:

switch firstEnum {
case let .firstCase(firstStruct) where 
case let .secondCase(secondStruct) = firstStruct.secondEnum, 
secondStruct.id == someId:
  ...
default:
  ...
}

Is there any way to express that?

3 Likes