Commit 426425d
Treat dot-qualified scoping functions as block-like
Summary:
# AI generated
`val fn = scope.launch { doThing() }` was reformatted by ktfmt, but `val fn = launch { doThing() }` was not. Both patterns should be stable (idempotent).
`isLambdaOrScopingFunction()` only recognized `KtCallExpression` (e.g., `launch { }`), not `KtQualifiedExpression` (e.g., `scope.launch { }`). Added unwrapping for dot-qualified expressions with simple name receivers so `scope.launch { }` and `scope?.launch { }` are treated as block-like, consistent with `launch { }`.
Guarded with `receiverExpression is KtSimpleNameExpression` to avoid catching multi-part chains like `items.toMutableList.apply { }` or `if (...) { }.mapFailure { }`.
Reviewed By: cgrushko
Differential Revision: D96184015
fbshipit-source-id: 36eb699782766e523fb19cddbb8350232a3331cf1 parent c2678a3 commit 426425d
3 files changed
Lines changed: 88 additions & 0 deletions
File tree
- core/src
- main/java/com/facebook/ktfmt/format
- test/java/com/facebook/ktfmt/format
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1553 | 1553 | | |
1554 | 1554 | | |
1555 | 1555 | | |
| 1556 | + | |
1556 | 1557 | | |
1557 | 1558 | | |
1558 | 1559 | | |
| |||
1565 | 1566 | | |
1566 | 1567 | | |
1567 | 1568 | | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1568 | 1572 | | |
1569 | 1573 | | |
1570 | 1574 | | |
| |||
1592 | 1596 | | |
1593 | 1597 | | |
1594 | 1598 | | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
1595 | 1604 | | |
1596 | 1605 | | |
1597 | 1606 | | |
| |||
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6807 | 6807 | | |
6808 | 6808 | | |
6809 | 6809 | | |
| 6810 | + | |
| 6811 | + | |
| 6812 | + | |
| 6813 | + | |
| 6814 | + | |
| 6815 | + | |
| 6816 | + | |
| 6817 | + | |
| 6818 | + | |
| 6819 | + | |
| 6820 | + | |
| 6821 | + | |
| 6822 | + | |
| 6823 | + | |
| 6824 | + | |
| 6825 | + | |
| 6826 | + | |
| 6827 | + | |
| 6828 | + | |
| 6829 | + | |
| 6830 | + | |
| 6831 | + | |
| 6832 | + | |
| 6833 | + | |
| 6834 | + | |
| 6835 | + | |
| 6836 | + | |
| 6837 | + | |
| 6838 | + | |
| 6839 | + | |
| 6840 | + | |
| 6841 | + | |
| 6842 | + | |
| 6843 | + | |
| 6844 | + | |
| 6845 | + | |
| 6846 | + | |
| 6847 | + | |
| 6848 | + | |
| 6849 | + | |
| 6850 | + | |
| 6851 | + | |
| 6852 | + | |
| 6853 | + | |
| 6854 | + | |
| 6855 | + | |
| 6856 | + | |
| 6857 | + | |
| 6858 | + | |
| 6859 | + | |
| 6860 | + | |
| 6861 | + | |
| 6862 | + | |
| 6863 | + | |
| 6864 | + | |
| 6865 | + | |
| 6866 | + | |
| 6867 | + | |
| 6868 | + | |
| 6869 | + | |
| 6870 | + | |
| 6871 | + | |
| 6872 | + | |
| 6873 | + | |
| 6874 | + | |
| 6875 | + | |
| 6876 | + | |
| 6877 | + | |
| 6878 | + | |
| 6879 | + | |
| 6880 | + | |
| 6881 | + | |
| 6882 | + | |
| 6883 | + | |
| 6884 | + | |
| 6885 | + | |
| 6886 | + | |
| 6887 | + | |
6810 | 6888 | | |
6811 | 6889 | | |
6812 | 6890 | | |
| |||
0 commit comments