[Bug][CLI]: match does not narrow nested attribute types
Describe the Bug
https://pyrefly.org/sandbox/?code=MQAg6gpgNgxg9gWwiALnVALZAFAngJwgDMpcQBlAQwDsATAIzgA8AaTASwGcQuRKQADpQDmEAFCgA7lkIhccAK4gYNEJPzsUENpwyVZNWiCgR91PowUpUuAe2rCe5vCgxxqAOgkSQACQgGBsqKAiYgRKYoCoTccEQc3JyGjEwAXD4AtCAA4hDWhJRQGSjsSDYCyDBYMADW9o4REAyUtZkgAKqcyIQAbqZQAPoothAAFACUqOj2nBUw1vYR+IRGwxWcbRBMFRpI1NaSmhiYyACSACIAouGR0RDcrpQHyJwKAgJw+NajEB7CHnwrHB4AhQnltCBhHBitDaMR7Jp2O42G4+vg2HkYOM2mANFo+HQQPgFM5cK53ME4SBaOxCPNSE45Ip8CB6Pg4JIuvgxER2QhyvUeKDPvkIH1CkMRmIYFBKJxuABBdIgFUgNJOawAHxAnBQ3Lh8S0utGlFSIAV42VqoQTyqfCtqtVKi65tGTAAvPYUBNLWJHf7Vb1+pKKiaPExsQGA36o0A
Codebase
No response
Other Attempts
No response
There are two issues:
first is that if x: A | B and we match x with some pattern A() it doesn't actually narrow x to A
second is that the nested attribute patterns B(int()), etc. do not narrow the properties for x. There are two kinds, positional and named attr patterns. The keyword one is easier, but the positional one could be tricky because it requires looking up __match_args__
the latter point also applies for keys in mapping patterns & indices in sequence patterns