|
44 | 44 |
|
45 | 45 | Here is an example of lint warnings produced by this check:
|
46 | 46 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
|
47 |
| -src/androidx/compose/runtime/foo/test.kt:9:Error: Calls to async should |
| 47 | +src/androidx/compose/runtime/foo/test.kt:10:Error: Calls to async should |
48 | 48 | happen inside a LaunchedEffect and not composition
|
49 | 49 | [CoroutineCreationDuringComposition]
|
50 | 50 |
|
51 | 51 | CoroutineScope.async {}
|
52 | 52 | -----
|
53 | 53 |
|
54 | 54 |
|
55 |
| -src/androidx/compose/runtime/foo/test.kt:10:Error: Calls to launch |
| 55 | +src/androidx/compose/runtime/foo/test.kt:11:Error: Calls to launch |
56 | 56 | should happen inside a LaunchedEffect and not composition
|
57 | 57 | [CoroutineCreationDuringComposition]
|
58 | 58 |
|
59 | 59 | CoroutineScope.launch {}
|
60 | 60 | ------
|
61 | 61 |
|
62 | 62 |
|
63 |
| -src/androidx/compose/runtime/foo/test.kt:14:Error: Calls to async should |
| 63 | +src/androidx/compose/runtime/foo/test.kt:12:Error: Calls to launchIn |
| 64 | +should happen inside a LaunchedEffect and not composition |
| 65 | +[CoroutineCreationDuringComposition] |
| 66 | + |
| 67 | + flowOf(Unit).launchIn(CoroutineScope) |
| 68 | + -------- |
| 69 | + |
| 70 | + |
| 71 | +src/androidx/compose/runtime/foo/test.kt:16:Error: Calls to async should |
64 | 72 | happen inside a LaunchedEffect and not composition
|
65 | 73 | [CoroutineCreationDuringComposition]
|
66 | 74 |
|
67 | 75 | CoroutineScope.async {}
|
68 | 76 | -----
|
69 | 77 |
|
70 | 78 |
|
71 |
| -src/androidx/compose/runtime/foo/test.kt:15:Error: Calls to launch |
| 79 | +src/androidx/compose/runtime/foo/test.kt:17:Error: Calls to launch |
72 | 80 | should happen inside a LaunchedEffect and not composition
|
73 | 81 | [CoroutineCreationDuringComposition]
|
74 | 82 |
|
75 | 83 | CoroutineScope.launch {}
|
76 | 84 | ------
|
77 | 85 |
|
78 | 86 |
|
79 |
| -src/androidx/compose/runtime/foo/test.kt:19:Error: Calls to async should |
| 87 | +src/androidx/compose/runtime/foo/test.kt:18:Error: Calls to launchIn |
| 88 | +should happen inside a LaunchedEffect and not composition |
| 89 | +[CoroutineCreationDuringComposition] |
| 90 | + |
| 91 | + flowOf(Unit).launchIn(CoroutineScope) |
| 92 | + -------- |
| 93 | + |
| 94 | + |
| 95 | +src/androidx/compose/runtime/foo/test.kt:22:Error: Calls to async should |
80 | 96 | happen inside a LaunchedEffect and not composition
|
81 | 97 | [CoroutineCreationDuringComposition]
|
82 | 98 |
|
83 | 99 | CoroutineScope.async {}
|
84 | 100 | -----
|
85 | 101 |
|
86 | 102 |
|
87 |
| -src/androidx/compose/runtime/foo/test.kt:20:Error: Calls to launch |
| 103 | +src/androidx/compose/runtime/foo/test.kt:23:Error: Calls to launch |
88 | 104 | should happen inside a LaunchedEffect and not composition
|
89 | 105 | [CoroutineCreationDuringComposition]
|
90 | 106 |
|
91 | 107 | CoroutineScope.launch {}
|
92 | 108 | ------
|
93 | 109 |
|
94 | 110 |
|
95 |
| -src/androidx/compose/runtime/foo/test.kt:29:Error: Calls to async should |
| 111 | +src/androidx/compose/runtime/foo/test.kt:24:Error: Calls to launchIn |
| 112 | +should happen inside a LaunchedEffect and not composition |
| 113 | +[CoroutineCreationDuringComposition] |
| 114 | + |
| 115 | + flowOf(Unit).launchIn(CoroutineScope) |
| 116 | + -------- |
| 117 | + |
| 118 | + |
| 119 | +src/androidx/compose/runtime/foo/test.kt:33:Error: Calls to async should |
96 | 120 | happen inside a LaunchedEffect and not composition
|
97 | 121 | [CoroutineCreationDuringComposition]
|
98 | 122 |
|
99 | 123 | CoroutineScope.async {}
|
100 | 124 | -----
|
101 | 125 |
|
102 | 126 |
|
103 |
| -src/androidx/compose/runtime/foo/test.kt:30:Error: Calls to launch |
| 127 | +src/androidx/compose/runtime/foo/test.kt:34:Error: Calls to launch |
104 | 128 | should happen inside a LaunchedEffect and not composition
|
105 | 129 | [CoroutineCreationDuringComposition]
|
106 | 130 |
|
107 | 131 | CoroutineScope.launch {}
|
108 | 132 | ------
|
109 | 133 |
|
110 | 134 |
|
111 |
| -src/androidx/compose/runtime/foo/test.kt:33:Error: Calls to async should |
| 135 | +src/androidx/compose/runtime/foo/test.kt:35:Error: Calls to launchIn |
| 136 | +should happen inside a LaunchedEffect and not composition |
| 137 | +[CoroutineCreationDuringComposition] |
| 138 | + |
| 139 | + flowOf(Unit).launchIn(CoroutineScope) |
| 140 | + -------- |
| 141 | + |
| 142 | + |
| 143 | +src/androidx/compose/runtime/foo/test.kt:38:Error: Calls to async should |
112 | 144 | happen inside a LaunchedEffect and not composition
|
113 | 145 | [CoroutineCreationDuringComposition]
|
114 | 146 |
|
115 | 147 | CoroutineScope.async {}
|
116 | 148 | -----
|
117 | 149 |
|
118 | 150 |
|
119 |
| -src/androidx/compose/runtime/foo/test.kt:34:Error: Calls to launch |
| 151 | +src/androidx/compose/runtime/foo/test.kt:39:Error: Calls to launch |
120 | 152 | should happen inside a LaunchedEffect and not composition
|
121 | 153 | [CoroutineCreationDuringComposition]
|
122 | 154 |
|
123 | 155 | CoroutineScope.launch {}
|
124 | 156 | ------
|
125 | 157 |
|
126 | 158 |
|
127 |
| -src/androidx/compose/runtime/foo/test.kt:40:Error: Calls to async should |
| 159 | +src/androidx/compose/runtime/foo/test.kt:40:Error: Calls to launchIn |
| 160 | +should happen inside a LaunchedEffect and not composition |
| 161 | +[CoroutineCreationDuringComposition] |
| 162 | + |
| 163 | + flowOf(Unit).launchIn(CoroutineScope) |
| 164 | + -------- |
| 165 | + |
| 166 | + |
| 167 | +src/androidx/compose/runtime/foo/test.kt:46:Error: Calls to async should |
128 | 168 | happen inside a LaunchedEffect and not composition
|
129 | 169 | [CoroutineCreationDuringComposition]
|
130 | 170 |
|
131 | 171 | CoroutineScope.async {}
|
132 | 172 | -----
|
133 | 173 |
|
134 | 174 |
|
135 |
| -src/androidx/compose/runtime/foo/test.kt:41:Error: Calls to launch |
| 175 | +src/androidx/compose/runtime/foo/test.kt:47:Error: Calls to launch |
136 | 176 | should happen inside a LaunchedEffect and not composition
|
137 | 177 | [CoroutineCreationDuringComposition]
|
138 | 178 |
|
139 | 179 | CoroutineScope.launch {}
|
140 | 180 | ------
|
141 | 181 |
|
142 | 182 |
|
143 |
| -src/androidx/compose/runtime/foo/test.kt:45:Error: Calls to async should |
| 183 | +src/androidx/compose/runtime/foo/test.kt:48:Error: Calls to launchIn |
| 184 | +should happen inside a LaunchedEffect and not composition |
| 185 | +[CoroutineCreationDuringComposition] |
| 186 | + |
| 187 | + flowOf(Unit).launchIn(CoroutineScope) |
| 188 | + -------- |
| 189 | + |
| 190 | + |
| 191 | +src/androidx/compose/runtime/foo/test.kt:52:Error: Calls to async should |
144 | 192 | happen inside a LaunchedEffect and not composition
|
145 | 193 | [CoroutineCreationDuringComposition]
|
146 | 194 |
|
147 | 195 | CoroutineScope.async {}
|
148 | 196 | -----
|
149 | 197 |
|
150 | 198 |
|
151 |
| -src/androidx/compose/runtime/foo/test.kt:46:Error: Calls to launch |
| 199 | +src/androidx/compose/runtime/foo/test.kt:53:Error: Calls to launch |
152 | 200 | should happen inside a LaunchedEffect and not composition
|
153 | 201 | [CoroutineCreationDuringComposition]
|
154 | 202 |
|
155 | 203 | CoroutineScope.launch {}
|
156 | 204 | ------
|
157 | 205 |
|
158 | 206 |
|
| 207 | +src/androidx/compose/runtime/foo/test.kt:54:Error: Calls to launchIn |
| 208 | +should happen inside a LaunchedEffect and not composition |
| 209 | +[CoroutineCreationDuringComposition] |
| 210 | + |
| 211 | + flowOf(Unit).launchIn(CoroutineScope) |
| 212 | + -------- |
| 213 | + |
| 214 | + |
159 | 215 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
160 | 216 |
|
161 | 217 | Here is the source file referenced above:
|
|
166 | 222 |
|
167 | 223 | import androidx.compose.runtime.Composable
|
168 | 224 | import kotlinx.coroutines.*
|
| 225 | +import kotlinx.coroutines.flow.* |
169 | 226 |
|
170 | 227 | @Composable
|
171 | 228 | fun Test() {
|
172 | 229 | CoroutineScope.async {}
|
173 | 230 | CoroutineScope.launch {}
|
| 231 | + flowOf(Unit).launchIn(CoroutineScope) |
174 | 232 | }
|
175 | 233 |
|
176 | 234 | val lambda = @Composable {
|
177 | 235 | CoroutineScope.async {}
|
178 | 236 | CoroutineScope.launch {}
|
| 237 | + flowOf(Unit).launchIn(CoroutineScope) |
179 | 238 | }
|
180 | 239 |
|
181 | 240 | val lambda2: @Composable () -> Unit = {
|
182 | 241 | CoroutineScope.async {}
|
183 | 242 | CoroutineScope.launch {}
|
| 243 | + flowOf(Unit).launchIn(CoroutineScope) |
184 | 244 | }
|
185 | 245 |
|
186 | 246 | @Composable
|
|
191 | 251 | LambdaParameter(content = {
|
192 | 252 | CoroutineScope.async {}
|
193 | 253 | CoroutineScope.launch {}
|
| 254 | + flowOf(Unit).launchIn(CoroutineScope) |
194 | 255 | })
|
195 | 256 | LambdaParameter {
|
196 | 257 | CoroutineScope.async {}
|
197 | 258 | CoroutineScope.launch {}
|
| 259 | + flowOf(Unit).launchIn(CoroutineScope) |
198 | 260 | }
|
199 | 261 | }
|
200 | 262 |
|
201 | 263 | fun test3() {
|
202 | 264 | val localLambda1 = @Composable {
|
203 | 265 | CoroutineScope.async {}
|
204 | 266 | CoroutineScope.launch {}
|
| 267 | + flowOf(Unit).launchIn(CoroutineScope) |
205 | 268 | }
|
206 | 269 |
|
207 | 270 | val localLambda2: @Composable () -> Unit = {
|
208 | 271 | CoroutineScope.async {}
|
209 | 272 | CoroutineScope.launch {}
|
| 273 | + flowOf(Unit).launchIn(CoroutineScope) |
210 | 274 | }
|
211 | 275 | }
|
212 | 276 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
0 commit comments