Commit a45d7f0
Fix metaclass lookup for class object __class__
Summary:
Pyrefly could infer `C.__class__` as `type[type[C]]` when `C` was represented as a `ClassDef`, but attribute-base conversion had no case for `type[ClassDef]`. That caused ordinary metaclass method lookups such as `C.__class__.__setattr__` to report an internal `attribute base undefined` error. Treat `type[ClassDef(C)]` as `C`'s metaclass viewed as a class object, preserving custom metaclass method signatures while leaving the broader `type[ClassType]` / generic alias behavior as the existing known bug.
Fixes #4093
Reviewed By: kinto0
Differential Revision: D111341385
fbshipit-source-id: b610104a8e39887b7cda66f3c608832d00b2cd721 parent 654b1f8 commit a45d7f0
2 files changed
Lines changed: 35 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2356 | 2356 | | |
2357 | 2357 | | |
2358 | 2358 | | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
2359 | 2370 | | |
2360 | 2371 | | |
2361 | 2372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1730 | 1730 | | |
1731 | 1731 | | |
1732 | 1732 | | |
1733 | | - | |
| 1733 | + | |
1734 | 1734 | | |
1735 | 1735 | | |
1736 | 1736 | | |
| |||
1744 | 1744 | | |
1745 | 1745 | | |
1746 | 1746 | | |
1747 | | - | |
| 1747 | + | |
1748 | 1748 | | |
1749 | 1749 | | |
1750 | 1750 | | |
1751 | 1751 | | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
1752 | 1773 | | |
1753 | 1774 | | |
1754 | 1775 | | |
| |||
1762 | 1783 | | |
1763 | 1784 | | |
1764 | 1785 | | |
1765 | | - | |
| 1786 | + | |
1766 | 1787 | | |
1767 | 1788 | | |
1768 | 1789 | | |
| |||
0 commit comments