Commit d9414c7
authored
Enforce composable target diagnostics for menu applier boundaries (JetBrains#2777)
[CMP-7106](https://youtrack.jetbrains.com/issue/CMP-7106) Use separate
`ComposableTargetMarker` for desktop menu API
Invalid API mixing such as putting UI composables into menu DSL (or vice
versa) can fail at runtime due to applier mismatch. This change improves
compile-time detection and reduces runtime-only failures.
- Added desktop-specific marker annotations: `MenuComposable`
- Marked menu APIs with `MenuComposable` where menu applier is expected
- Kept applier-creating entrypoints open where appropriate with
`@ComposableOpenTarget(-1)`.
- Refactored menu bar composition internals: replaced list adapter usage
with direct `JMenuBar` applier (`SwingApplier`-based path)
## Testing
```kt
Window(onCloseRequest = ::exitApplication) {
MenuBar {
Text("Label 1")
}
}
Tray(icon) {
Text("Label 2")
}
```
Now produces
```
Calling a UI Composable composable function where a Menu Composable composable was expected
```
## Release Notes
### Features - Desktop
- New compile-time warnings for invalid ui/menu composable mixing that
previously failed only at runtime.1 parent 0555020 commit d9414c7
10 files changed
Lines changed: 106 additions & 68 deletions
File tree
- compose/ui/ui
- api/desktop
- src/desktopMain/kotlin/androidx/compose/ui
- awt
- window
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4440 | 4440 | | |
4441 | 4441 | | |
4442 | 4442 | | |
| 4443 | + | |
| 4444 | + | |
| 4445 | + | |
4443 | 4446 | | |
4444 | 4447 | | |
4445 | 4448 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
114 | | - | |
| 116 | + | |
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| 185 | + | |
183 | 186 | | |
184 | 187 | | |
185 | 188 | | |
| |||
330 | 333 | | |
331 | 334 | | |
332 | 335 | | |
333 | | - | |
| 336 | + | |
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| |||
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| 177 | + | |
175 | 178 | | |
176 | 179 | | |
177 | 180 | | |
| |||
320 | 323 | | |
321 | 324 | | |
322 | 325 | | |
323 | | - | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
| 64 | + | |
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
| 170 | + | |
167 | 171 | | |
168 | 172 | | |
169 | 173 | | |
| |||
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
| 268 | + | |
264 | 269 | | |
265 | 270 | | |
266 | 271 | | |
| |||
306 | 311 | | |
307 | 312 | | |
308 | 313 | | |
| 314 | + | |
309 | 315 | | |
310 | 316 | | |
311 | 317 | | |
| |||
372 | 378 | | |
373 | 379 | | |
374 | 380 | | |
| 381 | + | |
375 | 382 | | |
376 | 383 | | |
377 | 384 | | |
| |||
437 | 444 | | |
438 | 445 | | |
439 | 446 | | |
440 | | - | |
| 447 | + | |
0 commit comments