Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kotlinx-coroutines-test/api/kotlinx-coroutines-test.api
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class kotlinx/coroutines/test/TestBuildersKt {
public static final fun runTest (Lkotlinx/coroutines/test/TestScope;JLkotlin/jvm/functions/Function2;)V
public static synthetic fun runTest$default (Lkotlin/coroutines/CoroutineContext;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
public static synthetic fun runTest$default (Lkotlinx/coroutines/test/TestCoroutineScope;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
public static final synthetic fun runTest$default (Lkotlinx/coroutines/test/TestScope;Ljava/lang/Long;Lkotlin/jvm/functions/Function2;Ljava/lang/Integer;Ljava/lang/Object;)V
public static final synthetic fun runTest$default (Lkotlinx/coroutines/test/TestScope;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
public static final fun runTest-8Mi8wO0 (Lkotlin/coroutines/CoroutineContext;JLkotlin/jvm/functions/Function2;)V
public static final fun runTest-8Mi8wO0 (Lkotlinx/coroutines/test/TestScope;JLkotlin/jvm/functions/Function2;)V
public static synthetic fun runTest-8Mi8wO0$default (Lkotlin/coroutines/CoroutineContext;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
Expand Down
6 changes: 3 additions & 3 deletions kotlinx-coroutines-test/common/src/TestBuilders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ internal expect fun dumpCoroutines()
@JvmName("runTest\$default")
@Suppress("DEPRECATION", "UNUSED_PARAMETER")
public fun TestScope.runTestLegacy(
dispatchTimeoutMs: Long?,
dispatchTimeoutMs: Long,
testBody: suspend TestScope.() -> Unit,
unused1: Int?,
unused1: Int,
unused2: Any?,
): TestResult = runTest(dispatchTimeoutMs ?: 60_000, testBody)
): TestResult = runTest(dispatchTimeoutMs, testBody)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
): TestResult = runTest(dispatchTimeoutMs, testBody)
): TestResult = runTest(if (unused1 and 1 != 0) DEFAULT_DISPATCH_TIMEOUT_MS else dispatchTimeoutMs, testBody)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no need: if somebody did actually provide dispatchTimeoutMs, the $default overload wouldn't be chosen.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that the wrong way around? We're in this function because they didn't supply all the parameters, therefore we need to fill them in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, you're right, it is the other way around. Let me think about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're fully correct, by decompiling this method in 1.6.4, we get

   // $FF: synthetic method
   public static void runTest$default(TestScope var0, long var1, Function2 var3, int var4, Object var5) {
      if ((var4 & 1) != 0) {
         var1 = 60000L;
      }

      TestBuildersKt.runTest(var0, var1, var3);
   }

Thanks for saving us from one more potential bugfix release!