@@ -20,7 +20,7 @@ class StackTraceRecoveryTest : TestBase() {
2020 fun testAsync () = runTest {
2121 fun createDeferred (depth : Int ): Deferred <* > {
2222 return if (depth == 0 ) {
23- async(coroutineContext + NonCancellable ) {
23+ async< Unit > (coroutineContext + NonCancellable ) {
2424 throw ExecutionException (null )
2525 }
2626 } else {
@@ -47,7 +47,7 @@ class StackTraceRecoveryTest : TestBase() {
4747
4848 @Test
4949 fun testCompletedAsync () = runTest {
50- val deferred = async(coroutineContext + NonCancellable ) {
50+ val deferred = async< Unit > (coroutineContext + NonCancellable ) {
5151 throw ExecutionException (null )
5252 }
5353
@@ -133,7 +133,7 @@ class StackTraceRecoveryTest : TestBase() {
133133
134134 @Test
135135 fun testWithContext () = runTest {
136- val deferred = async(NonCancellable , start = CoroutineStart .LAZY ) {
136+ val deferred = async< Unit > (NonCancellable , start = CoroutineStart .LAZY ) {
137137 throw RecoverableTestException ()
138138 }
139139
@@ -152,25 +152,26 @@ class StackTraceRecoveryTest : TestBase() {
152152 deferred.join()
153153 }
154154
155- private suspend fun outerMethod (deferred : Deferred <Nothing >, vararg traces : String ) {
155+ private suspend fun outerMethod (deferred : Deferred <* >, vararg traces : String ) {
156156 withContext(Dispatchers .IO ) {
157157 innerMethod(deferred, * traces)
158158 }
159159
160160 assertTrue(true )
161161 }
162162
163- private suspend fun innerMethod (deferred : Deferred <Nothing >, vararg traces : String ) {
163+ private suspend fun innerMethod (deferred : Deferred <* >, vararg traces : String ) {
164164 try {
165165 deferred.await()
166+ expectUnreached()
166167 } catch (e: RecoverableTestException ) {
167168 verifyStackTrace(e, * traces)
168169 }
169170 }
170171
171172 @Test
172173 fun testCoroutineScope () = runTest {
173- val deferred = async(NonCancellable , start = CoroutineStart .LAZY ) {
174+ val deferred = async< Unit > (NonCancellable , start = CoroutineStart .LAZY ) {
174175 throw RecoverableTestException ()
175176 }
176177
@@ -203,7 +204,7 @@ class StackTraceRecoveryTest : TestBase() {
203204
204205 @Test
205206 fun testThrowingInitCause () = runTest {
206- val deferred = async(NonCancellable ) {
207+ val deferred = async< Unit > (NonCancellable ) {
207208 expect(2 )
208209 throw TrickyException ()
209210 }
@@ -217,7 +218,7 @@ class StackTraceRecoveryTest : TestBase() {
217218 }
218219 }
219220
220- private suspend fun outerScopedMethod (deferred : Deferred <Nothing >, vararg traces : String ) = coroutineScope {
221+ private suspend fun outerScopedMethod (deferred : Deferred <* >, vararg traces : String ) = coroutineScope {
221222 supervisorScope {
222223 innerMethod(deferred, * traces)
223224 assertTrue(true )
@@ -228,7 +229,7 @@ class StackTraceRecoveryTest : TestBase() {
228229 @Test
229230 fun testSelect () = runTest {
230231 expect(1 )
231- val result = kotlin. runCatching { doSelect() }
232+ val result = runCatching { doSelect() }
232233 expect(3 )
233234 verifyStackTrace(result.exceptionOrNull()!! ,
234235 " kotlinx.coroutines.RecoverableTestException\n " +
@@ -251,4 +252,23 @@ class StackTraceRecoveryTest : TestBase() {
251252 }
252253 }
253254 }
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+ }
254274}
0 commit comments