@@ -20,7 +20,7 @@ class StackTraceRecoveryTest : TestBase() {
20
20
fun testAsync () = runTest {
21
21
fun createDeferred (depth : Int ): Deferred <* > {
22
22
return if (depth == 0 ) {
23
- async(coroutineContext + NonCancellable ) {
23
+ async< Unit > (coroutineContext + NonCancellable ) {
24
24
throw ExecutionException (null )
25
25
}
26
26
} else {
@@ -47,7 +47,7 @@ class StackTraceRecoveryTest : TestBase() {
47
47
48
48
@Test
49
49
fun testCompletedAsync () = runTest {
50
- val deferred = async(coroutineContext + NonCancellable ) {
50
+ val deferred = async< Unit > (coroutineContext + NonCancellable ) {
51
51
throw ExecutionException (null )
52
52
}
53
53
@@ -133,7 +133,7 @@ class StackTraceRecoveryTest : TestBase() {
133
133
134
134
@Test
135
135
fun testWithContext () = runTest {
136
- val deferred = async(NonCancellable , start = CoroutineStart .LAZY ) {
136
+ val deferred = async< Unit > (NonCancellable , start = CoroutineStart .LAZY ) {
137
137
throw RecoverableTestException ()
138
138
}
139
139
@@ -152,25 +152,26 @@ class StackTraceRecoveryTest : TestBase() {
152
152
deferred.join()
153
153
}
154
154
155
- private suspend fun outerMethod (deferred : Deferred <Nothing >, vararg traces : String ) {
155
+ private suspend fun outerMethod (deferred : Deferred <* >, vararg traces : String ) {
156
156
withContext(Dispatchers .IO ) {
157
157
innerMethod(deferred, * traces)
158
158
}
159
159
160
160
assertTrue(true )
161
161
}
162
162
163
- private suspend fun innerMethod (deferred : Deferred <Nothing >, vararg traces : String ) {
163
+ private suspend fun innerMethod (deferred : Deferred <* >, vararg traces : String ) {
164
164
try {
165
165
deferred.await()
166
+ expectUnreached()
166
167
} catch (e: RecoverableTestException ) {
167
168
verifyStackTrace(e, * traces)
168
169
}
169
170
}
170
171
171
172
@Test
172
173
fun testCoroutineScope () = runTest {
173
- val deferred = async(NonCancellable , start = CoroutineStart .LAZY ) {
174
+ val deferred = async< Unit > (NonCancellable , start = CoroutineStart .LAZY ) {
174
175
throw RecoverableTestException ()
175
176
}
176
177
@@ -203,7 +204,7 @@ class StackTraceRecoveryTest : TestBase() {
203
204
204
205
@Test
205
206
fun testThrowingInitCause () = runTest {
206
- val deferred = async(NonCancellable ) {
207
+ val deferred = async< Unit > (NonCancellable ) {
207
208
expect(2 )
208
209
throw TrickyException ()
209
210
}
@@ -217,7 +218,7 @@ class StackTraceRecoveryTest : TestBase() {
217
218
}
218
219
}
219
220
220
- private suspend fun outerScopedMethod (deferred : Deferred <Nothing >, vararg traces : String ) = coroutineScope {
221
+ private suspend fun outerScopedMethod (deferred : Deferred <* >, vararg traces : String ) = coroutineScope {
221
222
supervisorScope {
222
223
innerMethod(deferred, * traces)
223
224
assertTrue(true )
@@ -228,7 +229,7 @@ class StackTraceRecoveryTest : TestBase() {
228
229
@Test
229
230
fun testSelect () = runTest {
230
231
expect(1 )
231
- val result = kotlin. runCatching { doSelect() }
232
+ val result = runCatching { doSelect() }
232
233
expect(3 )
233
234
verifyStackTrace(result.exceptionOrNull()!! ,
234
235
" kotlinx.coroutines.RecoverableTestException\n " +
@@ -251,4 +252,23 @@ class StackTraceRecoveryTest : TestBase() {
251
252
}
252
253
}
253
254
}
255
+
256
+ @Test
257
+ fun testSelfSuppression () = runTest {
258
+ try {
259
+ runBlocking {
260
+ val job = launch {
261
+ coroutineScope<Unit > {
262
+ throw RecoverableTestException ()
263
+ }
264
+ }
265
+
266
+ job.join()
267
+ expectUnreached()
268
+ }
269
+ expectUnreached()
270
+ } catch (e: RecoverableTestException ) {
271
+ checkCycles(e)
272
+ }
273
+ }
254
274
}
0 commit comments