Two similar cases in pattern match

I’ve got a pattern match which works the same on an object when the object is at the top level or embedded within another class. The code that should be executed is the same for both cases.
I’ve tried to show an example of what I mean below where a string object is either top level or within an object of type A. Is this sort of thing possible (to reduce code duplication)? I ran it in Scastie but it says illegal variable in pattern alternative.

case class A(str: String)

object main {
  val something: Any = "sfdsd"
      
  something match {
     case A(str: String) | str: String => println("hello")  
  }
}

It’s simply not supported. You’ll need two separate patterns and “redundant” applications of the match code.

A pattern alternative p1 | … | pn consists of a number of alternative patterns pi. All alternative patterns are type checked with the expected type of the pattern. They may not bind variables other than wildcards.

Pattern Matching | Scala 2.13 [§8.1.12]

Adding to this, IMO this would make a great SIP for someone willing to also contribute an implementation (plausibly in dotty)