Enable strict explicit mode (#1877)

diff --git a/benchmarks/src/main/kotlin/benchmarks/common/BenchmarkUtils.kt b/benchmarks/src/main/kotlin/benchmarks/common/BenchmarkUtils.kt
index 0057573..27bc6b7 100644
--- a/benchmarks/src/main/kotlin/benchmarks/common/BenchmarkUtils.kt
+++ b/benchmarks/src/main/kotlin/benchmarks/common/BenchmarkUtils.kt
@@ -6,7 +6,7 @@
 
 import java.util.concurrent.*
 
-fun doGeomDistrWork(work: Int) {
+public fun doGeomDistrWork(work: Int) {
     // We use geometric distribution here. We also checked on macbook pro 13" (2017) that the resulting work times
     // are distributed geometrically, see https://github.com/Kotlin/kotlinx.coroutines/pull/1464#discussion_r355705325
     val p = 1.0 / work
diff --git a/gradle/compile-common.gradle b/gradle/compile-common.gradle
index 403c334..bee61429 100644
--- a/gradle/compile-common.gradle
+++ b/gradle/compile-common.gradle
@@ -12,3 +12,8 @@
         api "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
     }
 }
+
+
+kotlin.sourceSets.matching({ it.name.contains("Main") }).all { srcSet ->
+    project.ext.set("kotlin.mpp.freeCompilerArgsForSourceSet.${srcSet.name}", "-Xexplicit-api=strict")
+}
diff --git a/gradle/compile-jvm.gradle b/gradle/compile-jvm.gradle
index 261136b..a811659 100644
--- a/gradle/compile-jvm.gradle
+++ b/gradle/compile-jvm.gradle
@@ -23,6 +23,12 @@
     maven { url "https://dl.bintray.com/devexperts/Maven/" }
 }
 
+compileKotlin {
+    kotlinOptions {
+        freeCompilerArgs += ['-Xexplicit-api=strict']
+    }
+}
+
 tasks.withType(Test) {
     testLogging {
         showStandardStreams = true
diff --git a/integration/kotlinx-coroutines-jdk8/src/time/Time.kt b/integration/kotlinx-coroutines-jdk8/src/time/Time.kt
index 56f1e26..807a3bb 100644
--- a/integration/kotlinx-coroutines-jdk8/src/time/Time.kt
+++ b/integration/kotlinx-coroutines-jdk8/src/time/Time.kt
@@ -12,25 +12,24 @@
 /**
  * "java.time" adapter method for [kotlinx.coroutines.delay].
  */
-public suspend fun delay(duration: Duration) =
-        kotlinx.coroutines.delay(duration.coerceToMillis())
+public suspend fun delay(duration: Duration): Unit = delay(duration.coerceToMillis())
 
 /**
  * "java.time" adapter method for [kotlinx.coroutines.flow.debounce].
  */
 @FlowPreview
-public fun <T> Flow<T>.debounce(timeout: Duration) = debounce(timeout.coerceToMillis())
+public fun <T> Flow<T>.debounce(timeout: Duration): Flow<T> = debounce(timeout.coerceToMillis())
 
 /**
  * "java.time" adapter method for [kotlinx.coroutines.flow.sample].
  */
 @FlowPreview
-public fun <T> Flow<T>.sample(period: Duration) = sample(period.coerceToMillis())
+public fun <T> Flow<T>.sample(period: Duration): Flow<T> = sample(period.coerceToMillis())
 
 /**
  * "java.time" adapter method for [SelectBuilder.onTimeout].
  */
-public fun <R> SelectBuilder<R>.onTimeout(duration: Duration, block: suspend () -> R) =
+public fun <R> SelectBuilder<R>.onTimeout(duration: Duration, block: suspend () -> R): Unit =
         onTimeout(duration.coerceToMillis(), block)
 
 /**
diff --git a/integration/kotlinx-coroutines-slf4j/src/MDCContext.kt b/integration/kotlinx-coroutines-slf4j/src/MDCContext.kt
index 6dbcef6..078800d 100644
--- a/integration/kotlinx-coroutines-slf4j/src/MDCContext.kt
+++ b/integration/kotlinx-coroutines-slf4j/src/MDCContext.kt
@@ -48,7 +48,7 @@
     /**
      * Key of [MDCContext] in [CoroutineContext].
      */
-    companion object Key : CoroutineContext.Key<MDCContext>
+    public companion object Key : CoroutineContext.Key<MDCContext>
 
     /** @suppress */
     override fun updateThreadContext(context: CoroutineContext): MDCContextMap {
diff --git a/js/js-stub/src/Performance.kt b/js/js-stub/src/Performance.kt
index 353a08f..0b85c93 100644
--- a/js/js-stub/src/Performance.kt
+++ b/js/js-stub/src/Performance.kt
@@ -5,5 +5,5 @@
 package org.w3c.performance
 
 public abstract class Performance {
-    abstract fun now(): Double
+    public abstract fun now(): Double
 }
diff --git a/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt b/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt
index 22111f0..742c967 100644
--- a/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt
+++ b/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt
@@ -113,7 +113,7 @@
         afterResume(state)
     }
 
-    protected open fun afterResume(state: Any?) = afterCompletion(state)
+    protected open fun afterResume(state: Any?): Unit = afterCompletion(state)
 
     internal final override fun handleOnCompletionException(exception: Throwable) {
         handleCoroutineException(context, exception)
diff --git a/kotlinx-coroutines-core/common/src/CancellableContinuation.kt b/kotlinx-coroutines-core/common/src/CancellableContinuation.kt
index fd5cd08..e01dc82 100644
--- a/kotlinx-coroutines-core/common/src/CancellableContinuation.kt
+++ b/kotlinx-coroutines-core/common/src/CancellableContinuation.kt
@@ -288,7 +288,7 @@
  * @suppress **This an internal API and should not be used from general code.**
  */
 @InternalCoroutinesApi
-public fun CancellableContinuation<*>.disposeOnCancellation(handle: DisposableHandle) =
+public fun CancellableContinuation<*>.disposeOnCancellation(handle: DisposableHandle): Unit =
     invokeOnCancellation(handler = DisposeOnCancel(handle).asHandler)
 
 // --------------- implementation details ---------------
diff --git a/kotlinx-coroutines-core/common/src/CompletableDeferred.kt b/kotlinx-coroutines-core/common/src/CompletableDeferred.kt
index f6cf90d..cba8a63 100644
--- a/kotlinx-coroutines-core/common/src/CompletableDeferred.kt
+++ b/kotlinx-coroutines-core/common/src/CompletableDeferred.kt
@@ -55,7 +55,8 @@
  * [CompletableDeferred.completeExceptionally].
  */
 @ExperimentalCoroutinesApi // since 1.3.2, tentatively until 1.4.0
-public fun <T> CompletableDeferred<T>.completeWith(result: Result<T>) = result.fold({ complete(it) }, { completeExceptionally(it) })
+public fun <T> CompletableDeferred<T>.completeWith(result: Result<T>): Boolean =
+    result.fold({ complete(it) }, { completeExceptionally(it) })
 
 /**
  * Creates a [CompletableDeferred] in an _active_ state.
diff --git a/kotlinx-coroutines-core/common/src/CoroutineDispatcher.kt b/kotlinx-coroutines-core/common/src/CoroutineDispatcher.kt
index fe4c263..1b6e7eb 100644
--- a/kotlinx-coroutines-core/common/src/CoroutineDispatcher.kt
+++ b/kotlinx-coroutines-core/common/src/CoroutineDispatcher.kt
@@ -87,7 +87,7 @@
      * @suppress **This an internal API and should not be used from general code.**
      */
     @InternalCoroutinesApi
-    public open fun dispatchYield(context: CoroutineContext, block: Runnable) = dispatch(context, block)
+    public open fun dispatchYield(context: CoroutineContext, block: Runnable): Unit = dispatch(context, block)
 
     /**
      * Returns a continuation that wraps the provided [continuation], thus intercepting all resumptions.
@@ -115,7 +115,7 @@
             "The dispatcher to the right of `+` just replaces the dispatcher to the left.",
         level = DeprecationLevel.ERROR
     )
-    public operator fun plus(other: CoroutineDispatcher) = other
+    public operator fun plus(other: CoroutineDispatcher): CoroutineDispatcher = other
 
     /** @suppress for nicer debugging */
     override fun toString(): String = "$classSimpleName@$hexAddress"
diff --git a/kotlinx-coroutines-core/common/src/CoroutineStart.kt b/kotlinx-coroutines-core/common/src/CoroutineStart.kt
index 1272ce7..05e80e3 100644
--- a/kotlinx-coroutines-core/common/src/CoroutineStart.kt
+++ b/kotlinx-coroutines-core/common/src/CoroutineStart.kt
@@ -1,7 +1,7 @@
 /*
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
-
+@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 package kotlinx.coroutines
 
 import kotlinx.coroutines.CoroutineStart.*
@@ -85,12 +85,12 @@
      * @suppress **This an internal API and should not be used from general code.**
      */
     @InternalCoroutinesApi
-    public operator fun <T> invoke(block: suspend () -> T, completion: Continuation<T>) =
+    public operator fun <T> invoke(block: suspend () -> T, completion: Continuation<T>): Unit =
         when (this) {
-            CoroutineStart.DEFAULT -> block.startCoroutineCancellable(completion)
-            CoroutineStart.ATOMIC -> block.startCoroutine(completion)
-            CoroutineStart.UNDISPATCHED -> block.startCoroutineUndispatched(completion)
-            CoroutineStart.LAZY -> Unit // will start lazily
+            DEFAULT -> block.startCoroutineCancellable(completion)
+            ATOMIC -> block.startCoroutine(completion)
+            UNDISPATCHED -> block.startCoroutineUndispatched(completion)
+            LAZY -> Unit // will start lazily
         }
 
     /**
@@ -104,12 +104,12 @@
      * @suppress **This an internal API and should not be used from general code.**
      */
     @InternalCoroutinesApi
-    public operator fun <R, T> invoke(block: suspend R.() -> T, receiver: R, completion: Continuation<T>) =
+    public operator fun <R, T> invoke(block: suspend R.() -> T, receiver: R, completion: Continuation<T>): Unit =
         when (this) {
-            CoroutineStart.DEFAULT -> block.startCoroutineCancellable(receiver, completion)
-            CoroutineStart.ATOMIC -> block.startCoroutine(receiver, completion)
-            CoroutineStart.UNDISPATCHED -> block.startCoroutineUndispatched(receiver, completion)
-            CoroutineStart.LAZY -> Unit // will start lazily
+            DEFAULT -> block.startCoroutineCancellable(receiver, completion)
+            ATOMIC -> block.startCoroutine(receiver, completion)
+            UNDISPATCHED -> block.startCoroutineUndispatched(receiver, completion)
+            LAZY -> Unit // will start lazily
         }
 
     /**
diff --git a/kotlinx-coroutines-core/common/src/Delay.kt b/kotlinx-coroutines-core/common/src/Delay.kt
index cc205ec..ab80912 100644
--- a/kotlinx-coroutines-core/common/src/Delay.kt
+++ b/kotlinx-coroutines-core/common/src/Delay.kt
@@ -25,7 +25,7 @@
      * If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function
      * immediately resumes with [CancellationException].
      */
-    suspend fun delay(time: Long) {
+    public suspend fun delay(time: Long) {
         if (time <= 0) return // don't delay
         return suspendCancellableCoroutine { scheduleResumeAfterDelay(time, it) }
     }
@@ -45,7 +45,7 @@
      * with(continuation) { resumeUndispatchedWith(Unit) }
      * ```
      */
-    fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>)
+    public fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>)
 
     /**
      * Schedules invocation of a specified [block] after a specified delay [timeMillis].
@@ -54,7 +54,7 @@
      *
      * This implementation uses a built-in single-threaded scheduled executor service.
      */
-    fun invokeOnTimeout(timeMillis: Long, block: Runnable): DisposableHandle =
+    public fun invokeOnTimeout(timeMillis: Long, block: Runnable): DisposableHandle =
         DefaultDelay.invokeOnTimeout(timeMillis, block)
 }
 
@@ -87,7 +87,7 @@
  * Implementation note: how exactly time is tracked is an implementation detail of [CoroutineDispatcher] in the context.
  */
 @ExperimentalTime
-public suspend fun delay(duration: Duration) = delay(duration.toDelayMillis())
+public suspend fun delay(duration: Duration): Unit = delay(duration.toDelayMillis())
 
 /** Returns [Delay] implementation of the given context */
 internal val CoroutineContext.delay: Delay get() = get(ContinuationInterceptor) as? Delay ?: DefaultDelay
diff --git a/kotlinx-coroutines-core/common/src/Job.kt b/kotlinx-coroutines-core/common/src/Job.kt
index 4d4e37e..4dd783c 100644
--- a/kotlinx-coroutines-core/common/src/Job.kt
+++ b/kotlinx-coroutines-core/common/src/Job.kt
@@ -167,7 +167,7 @@
      * @suppress This method implements old version of JVM ABI. Use [cancel].
      */
     @Deprecated(level = DeprecationLevel.HIDDEN, message = "Since 1.2.0, binary compatibility with versions <= 1.1.x")
-    public fun cancel() = cancel(null)
+    public fun cancel(): Unit = cancel(null)
 
     /**
      * @suppress This method has bad semantics when cause is not a [CancellationException]. Use [cancel].
@@ -337,7 +337,7 @@
         "Job is a coroutine context element and `+` is a set-sum operator for coroutine contexts. " +
         "The job to the right of `+` just replaces the job the left of `+`.",
         level = DeprecationLevel.ERROR)
-    public operator fun plus(other: Job) = other
+    public operator fun plus(other: Job): Job = other
 }
 
 /**
@@ -382,7 +382,7 @@
  */
 @Suppress("FunctionName")
 @InternalCoroutinesApi
-public inline fun DisposableHandle(crossinline block: () -> Unit) =
+public inline fun DisposableHandle(crossinline block: () -> Unit): DisposableHandle =
     object : DisposableHandle {
         override fun dispose() {
             block()
@@ -496,7 +496,7 @@
  * @suppress This method implements old version of JVM ABI. Use [cancel].
  */
 @Deprecated(level = DeprecationLevel.HIDDEN, message = "Since 1.2.0, binary compatibility with versions <= 1.1.x")
-public fun Job.cancelChildren() = cancelChildren(null)
+public fun Job.cancelChildren(): Unit = cancelChildren(null)
 
 /**
  * @suppress This method has bad semantics when cause is not a [CancellationException]. Use [Job.cancelChildren].
@@ -539,7 +539,7 @@
  * @suppress This method implements old version of JVM ABI. Use [CoroutineContext.cancel].
  */
 @Deprecated(level = DeprecationLevel.HIDDEN, message = "Since 1.2.0, binary compatibility with versions <= 1.1.x")
-public fun CoroutineContext.cancel() = cancel(null)
+public fun CoroutineContext.cancel(): Unit = cancel(null)
 
 /**
  * Ensures that current job is [active][Job.isActive].
@@ -605,7 +605,7 @@
  * @suppress This method implements old version of JVM ABI. Use [CoroutineContext.cancelChildren].
  */
 @Deprecated(level = DeprecationLevel.HIDDEN, message = "Since 1.2.0, binary compatibility with versions <= 1.1.x")
-public fun CoroutineContext.cancelChildren() = cancelChildren(null)
+public fun CoroutineContext.cancelChildren(): Unit = cancelChildren(null)
 
 /**
  * @suppress This method has bad semantics when cause is not a [CancellationException]. Use [CoroutineContext.cancelChildren].
diff --git a/kotlinx-coroutines-core/common/src/JobSupport.kt b/kotlinx-coroutines-core/common/src/JobSupport.kt
index e52aaea..020d00a 100644
--- a/kotlinx-coroutines-core/common/src/JobSupport.kt
+++ b/kotlinx-coroutines-core/common/src/JobSupport.kt
@@ -652,7 +652,7 @@
      * Makes this [Job] cancelled with a specified [cause].
      * It is used in [AbstractCoroutine]-derived classes when there is an internal failure.
      */
-    public fun cancelCoroutine(cause: Throwable?) = cancelImpl(cause)
+    public fun cancelCoroutine(cause: Throwable?): Boolean = cancelImpl(cause)
 
     // cause is Throwable or ParentJob when cancelChild was invoked
     // returns true is exception was handled, false otherwise
diff --git a/kotlinx-coroutines-core/common/src/channels/Broadcast.kt b/kotlinx-coroutines-core/common/src/channels/Broadcast.kt
index e2891c9..863d138 100644
--- a/kotlinx-coroutines-core/common/src/channels/Broadcast.kt
+++ b/kotlinx-coroutines-core/common/src/channels/Broadcast.kt
@@ -39,7 +39,7 @@
  *
  * @param start coroutine start option. The default value is [CoroutineStart.LAZY].
  */
-fun <E> ReceiveChannel<E>.broadcast(
+public fun <E> ReceiveChannel<E>.broadcast(
     capacity: Int = 1,
     start: CoroutineStart = CoroutineStart.LAZY
 ): BroadcastChannel<E> {
diff --git a/kotlinx-coroutines-core/common/src/channels/Channel.kt b/kotlinx-coroutines-core/common/src/channels/Channel.kt
index 8dff4ec..c4b4a9b 100644
--- a/kotlinx-coroutines-core/common/src/channels/Channel.kt
+++ b/kotlinx-coroutines-core/common/src/channels/Channel.kt
@@ -7,15 +7,15 @@
 package kotlinx.coroutines.channels
 
 import kotlinx.coroutines.*
+import kotlinx.coroutines.channels.Channel.Factory.BUFFERED
+import kotlinx.coroutines.channels.Channel.Factory.CHANNEL_DEFAULT_CAPACITY
 import kotlinx.coroutines.channels.Channel.Factory.CONFLATED
 import kotlinx.coroutines.channels.Channel.Factory.RENDEZVOUS
 import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
-import kotlinx.coroutines.channels.Channel.Factory.BUFFERED
-import kotlinx.coroutines.channels.Channel.Factory.CHANNEL_DEFAULT_CAPACITY
-import kotlinx.coroutines.internal.systemProp
+import kotlinx.coroutines.internal.*
 import kotlinx.coroutines.selects.*
-import kotlin.jvm.*
 import kotlin.internal.*
+import kotlin.jvm.*
 
 /**
  * Sender's interface to [Channel].
@@ -314,7 +314,7 @@
      * @suppress This method implements old version of JVM ABI. Use [cancel].
      */
     @Deprecated(level = DeprecationLevel.HIDDEN, message = "Since 1.2.0, binary compatibility with versions <= 1.1.x")
-    public fun cancel() = cancel(null)
+    public fun cancel(): Unit = cancel(null)
 
     /**
      * @suppress This method has bad semantics when cause is not a [CancellationException]. Use [cancel].
@@ -517,17 +517,17 @@
         /**
          * Requests a channel with an unlimited capacity buffer in the `Channel(...)` factory function
          */
-        public const val UNLIMITED = Int.MAX_VALUE
+        public const val UNLIMITED: Int = Int.MAX_VALUE
 
         /**
          * Requests a rendezvous channel in the `Channel(...)` factory function &mdash; a `RendezvousChannel` gets created.
          */
-        public const val RENDEZVOUS = 0
+        public const val RENDEZVOUS: Int = 0
 
         /**
          * Requests a conflated channel in the `Channel(...)` factory function &mdash; a `ConflatedChannel` gets created.
          */
-        public const val CONFLATED = -1
+        public const val CONFLATED: Int = -1
 
         /**
          * Requests a buffered channel with the default buffer capacity in the `Channel(...)` factory function &mdash;
@@ -535,7 +535,7 @@
          * The default capacity is 64 and can be overridden by setting
          * [DEFAULT_BUFFER_PROPERTY_NAME] on JVM.
          */
-        public const val BUFFERED = -2
+        public const val BUFFERED: Int = -2
 
         // only for internal use, cannot be used with Channel(...)
         internal const val OPTIONAL_CHANNEL = -3
@@ -544,7 +544,7 @@
          * Name of the property that defines the default channel capacity when
          * [BUFFERED] is used as parameter in `Channel(...)` factory function.
          */
-        public const val DEFAULT_BUFFER_PROPERTY_NAME = "kotlinx.coroutines.channels.defaultBuffer"
+        public const val DEFAULT_BUFFER_PROPERTY_NAME: String = "kotlinx.coroutines.channels.defaultBuffer"
 
         internal val CHANNEL_DEFAULT_CAPACITY = systemProp(DEFAULT_BUFFER_PROPERTY_NAME,
             64, 1, UNLIMITED - 1
diff --git a/kotlinx-coroutines-core/common/src/channels/Channels.common.kt b/kotlinx-coroutines-core/common/src/channels/Channels.common.kt
index 4a73d5d..8c61928 100644
--- a/kotlinx-coroutines-core/common/src/channels/Channels.common.kt
+++ b/kotlinx-coroutines-core/common/src/channels/Channels.common.kt
@@ -84,7 +84,7 @@
  *           See [issue #254](https://github.com/Kotlin/kotlinx.coroutines/issues/254).
  */
 @ObsoleteCoroutinesApi
-public suspend inline fun <E> BroadcastChannel<E>.consumeEach(action: (E) -> Unit) =
+public suspend inline fun <E> BroadcastChannel<E>.consumeEach(action: (E) -> Unit): Unit =
     consume {
         for (element in this) action(element)
     }
@@ -175,7 +175,7 @@
  * This function [consumes][ReceiveChannel.consume] all elements of the original [ReceiveChannel].
  */
 @ExperimentalCoroutinesApi // since 1.3.0, tentatively graduates in 1.4.0
-public suspend inline fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit) =
+public suspend inline fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit): Unit =
     consume {
         for (e in this) action(e)
     }
diff --git a/kotlinx-coroutines-core/common/src/channels/ConflatedBroadcastChannel.kt b/kotlinx-coroutines-core/common/src/channels/ConflatedBroadcastChannel.kt
index 4990c93..9e093b7 100644
--- a/kotlinx-coroutines-core/common/src/channels/ConflatedBroadcastChannel.kt
+++ b/kotlinx-coroutines-core/common/src/channels/ConflatedBroadcastChannel.kt
@@ -37,7 +37,7 @@
      * It is as a shortcut to creating an instance with a default constructor and
      * immediately sending an element: `ConflatedBroadcastChannel().apply { offer(value) }`.
      */
-    constructor(value: E) : this() {
+    public constructor(value: E) : this() {
         _state.lazySet(State<E>(value, null))
     }
 
diff --git a/kotlinx-coroutines-core/common/src/channels/Produce.kt b/kotlinx-coroutines-core/common/src/channels/Produce.kt
index 24fd399..1b1581a 100644
--- a/kotlinx-coroutines-core/common/src/channels/Produce.kt
+++ b/kotlinx-coroutines-core/common/src/channels/Produce.kt
@@ -22,7 +22,7 @@
      * All the [SendChannel] functions on this interface delegate to
      * the channel instance returned by this property.
      */
-    val channel: SendChannel<E>
+    public val channel: SendChannel<E>
 }
 
 /**
diff --git a/kotlinx-coroutines-core/common/src/flow/Channels.kt b/kotlinx-coroutines-core/common/src/flow/Channels.kt
index e3a64b9..130ffc7 100644
--- a/kotlinx-coroutines-core/common/src/flow/Channels.kt
+++ b/kotlinx-coroutines-core/common/src/flow/Channels.kt
@@ -24,7 +24,7 @@
  * See [consumeEach][ReceiveChannel.consumeEach].
  */
 @ExperimentalCoroutinesApi // since version 1.3.0
-public suspend fun <T> FlowCollector<T>.emitAll(channel: ReceiveChannel<T>) =
+public suspend fun <T> FlowCollector<T>.emitAll(channel: ReceiveChannel<T>): Unit =
     emitAllImpl(channel, consume = true)
 
 private suspend fun <T> FlowCollector<T>.emitAllImpl(channel: ReceiveChannel<T>, consume: Boolean) {
diff --git a/kotlinx-coroutines-core/common/src/flow/Migration.kt b/kotlinx-coroutines-core/common/src/flow/Migration.kt
index 16bde89..bdc205e 100644
--- a/kotlinx-coroutines-core/common/src/flow/Migration.kt
+++ b/kotlinx-coroutines-core/common/src/flow/Migration.kt
@@ -4,7 +4,7 @@
 
 @file:JvmMultifileClass
 @file:JvmName("FlowKt")
-@file:Suppress("unused", "DeprecatedCallableAddReplaceWith", "UNUSED_PARAMETER")
+@file:Suppress("unused", "DeprecatedCallableAddReplaceWith", "UNUSED_PARAMETER", "NO_EXPLICIT_RETURN_TYPE_IN_API_MODE")
 
 package kotlinx.coroutines.flow
 
diff --git a/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt b/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt
index 8a18bff..f2f748b 100644
--- a/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt
+++ b/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt
@@ -23,9 +23,9 @@
 @InternalCoroutinesApi
 public abstract class ChannelFlow<T>(
     // upstream context
-    @JvmField val context: CoroutineContext,
+    @JvmField public val context: CoroutineContext,
     // buffer capacity between upstream and downstream context
-    @JvmField val capacity: Int
+    @JvmField public val capacity: Int
 ) : Flow<T> {
 
     // shared code to create a suspend lambda from collectTo function in one place
@@ -65,7 +65,7 @@
 
     protected abstract suspend fun collectTo(scope: ProducerScope<T>)
 
-    open fun broadcastImpl(scope: CoroutineScope, start: CoroutineStart): BroadcastChannel<T> =
+    public open fun broadcastImpl(scope: CoroutineScope, start: CoroutineStart): BroadcastChannel<T> =
         scope.broadcast(context, produceCapacity, start, block = collectToFun)
 
     /**
@@ -76,15 +76,15 @@
      * handlers, while the pipeline before does not, because it was cancelled during its dispatch.
      * Thus `onCompletion` and `finally` blocks won't be executed and it may lead to a different kinds of memory leaks.
      */
-    open fun produceImpl(scope: CoroutineScope): ReceiveChannel<T> =
+    public open fun produceImpl(scope: CoroutineScope): ReceiveChannel<T> =
         scope.produce(context, produceCapacity, start = CoroutineStart.ATOMIC, block = collectToFun)
 
-    override suspend fun collect(collector: FlowCollector<T>) =
+    override suspend fun collect(collector: FlowCollector<T>): Unit =
         coroutineScope {
             collector.emitAll(produceImpl(this))
         }
 
-    open fun additionalToStringProps() = ""
+    public open fun additionalToStringProps(): String = ""
 
     // debug toString
     override fun toString(): String =
diff --git a/kotlinx-coroutines-core/common/src/flow/internal/SendingCollector.kt b/kotlinx-coroutines-core/common/src/flow/internal/SendingCollector.kt
index 1620a2a..c2abafd 100644
--- a/kotlinx-coroutines-core/common/src/flow/internal/SendingCollector.kt
+++ b/kotlinx-coroutines-core/common/src/flow/internal/SendingCollector.kt
@@ -16,5 +16,5 @@
 public class SendingCollector<T>(
     private val channel: SendChannel<T>
 ) : FlowCollector<T> {
-    override suspend fun emit(value: T) = channel.send(value)
+    override suspend fun emit(value: T): Unit = channel.send(value)
 }
diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt b/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt
index 9236fd2..d8016e0 100644
--- a/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt
+++ b/kotlinx-coroutines-core/common/src/flow/operators/Emitters.kt
@@ -164,7 +164,7 @@
 // It was only released in 1.3.0-M2, remove in 1.4.0
 /** @suppress */
 @Deprecated(level = DeprecationLevel.HIDDEN, message = "binary compatibility with a version w/o FlowCollector receiver")
-public fun <T> Flow<T>.onCompletion(action: suspend (cause: Throwable?) -> Unit) =
+public fun <T> Flow<T>.onCompletion(action: suspend (cause: Throwable?) -> Unit): Flow<T> =
     onCompletion { action(it) }
 
 private suspend fun <T> FlowCollector<T>.invokeSafely(
diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt b/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt
index 85fe90b..340d8e3 100644
--- a/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt
+++ b/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt
@@ -19,14 +19,14 @@
  * Name of the property that defines the value of [DEFAULT_CONCURRENCY].
  */
 @FlowPreview
-public const val DEFAULT_CONCURRENCY_PROPERTY_NAME = "kotlinx.coroutines.flow.defaultConcurrency"
+public const val DEFAULT_CONCURRENCY_PROPERTY_NAME: String = "kotlinx.coroutines.flow.defaultConcurrency"
 
 /**
  * Default concurrency limit that is used by [flattenMerge] and [flatMapMerge] operators.
  * It is 16 by default and can be changed on JVM using [DEFAULT_CONCURRENCY_PROPERTY_NAME] property.
  */
 @FlowPreview
-public val DEFAULT_CONCURRENCY = systemProp(DEFAULT_CONCURRENCY_PROPERTY_NAME,
+public val DEFAULT_CONCURRENCY: Int = systemProp(DEFAULT_CONCURRENCY_PROPERTY_NAME,
     16, 1, Int.MAX_VALUE
 )
 
diff --git a/kotlinx-coroutines-core/common/src/flow/terminal/Collect.kt b/kotlinx-coroutines-core/common/src/flow/terminal/Collect.kt
index 52d060f..9d463df 100644
--- a/kotlinx-coroutines-core/common/src/flow/terminal/Collect.kt
+++ b/kotlinx-coroutines-core/common/src/flow/terminal/Collect.kt
@@ -27,7 +27,7 @@
  *     .collect() // trigger collection of the flow
  * ```
  */
-public suspend fun Flow<*>.collect() = collect(NopCollector)
+public suspend fun Flow<*>.collect(): Unit = collect(NopCollector)
 
 /**
  * Terminal flow operator that [launches][launch] the [collection][collect] of the given flow in the [scope].
@@ -132,4 +132,4 @@
  */
 @BuilderInference
 @ExperimentalCoroutinesApi
-public suspend inline fun <T> FlowCollector<T>.emitAll(flow: Flow<T>) = flow.collect(this)
+public suspend inline fun <T> FlowCollector<T>.emitAll(flow: Flow<T>): Unit = flow.collect(this)
diff --git a/kotlinx-coroutines-core/common/src/internal/Atomic.kt b/kotlinx-coroutines-core/common/src/internal/Atomic.kt
index 56fd35b..94f6ab9 100644
--- a/kotlinx-coroutines-core/common/src/internal/Atomic.kt
+++ b/kotlinx-coroutines-core/common/src/internal/Atomic.kt
@@ -1,6 +1,7 @@
 /*
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
+@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 
 package kotlinx.coroutines.internal
 
diff --git a/kotlinx-coroutines-core/common/src/internal/DispatchedContinuation.kt b/kotlinx-coroutines-core/common/src/internal/DispatchedContinuation.kt
index 5075814..cf31fcf 100644
--- a/kotlinx-coroutines-core/common/src/internal/DispatchedContinuation.kt
+++ b/kotlinx-coroutines-core/common/src/internal/DispatchedContinuation.kt
@@ -245,7 +245,7 @@
  * @suppress **This an internal API and should not be used from general code.**
  */
 @InternalCoroutinesApi
-public fun <T> Continuation<T>.resumeCancellableWith(result: Result<T>) = when (this) {
+public fun <T> Continuation<T>.resumeCancellableWith(result: Result<T>): Unit = when (this) {
     is DispatchedContinuation -> resumeCancellableWith(result)
     else -> resumeWith(result)
 }
diff --git a/kotlinx-coroutines-core/common/src/internal/LockFreeLinkedList.common.kt b/kotlinx-coroutines-core/common/src/internal/LockFreeLinkedList.common.kt
index 216ce7b..f1663c3 100644
--- a/kotlinx-coroutines-core/common/src/internal/LockFreeLinkedList.common.kt
+++ b/kotlinx-coroutines-core/common/src/internal/LockFreeLinkedList.common.kt
@@ -1,6 +1,7 @@
 /*
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
+@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 
 package kotlinx.coroutines.internal
 
diff --git a/kotlinx-coroutines-core/common/src/internal/MainDispatcherFactory.kt b/kotlinx-coroutines-core/common/src/internal/MainDispatcherFactory.kt
index 93142df..c3587af 100644
--- a/kotlinx-coroutines-core/common/src/internal/MainDispatcherFactory.kt
+++ b/kotlinx-coroutines-core/common/src/internal/MainDispatcherFactory.kt
@@ -9,16 +9,16 @@
 /** @suppress */
 @InternalCoroutinesApi // Emulating DI for Kotlin object's
 public interface MainDispatcherFactory {
-    val loadPriority: Int // higher priority wins
+    public val loadPriority: Int // higher priority wins
 
     /**
      * Creates the main dispatcher. [allFactories] parameter contains all factories found by service loader.
      * This method is not guaranteed to be idempotent.
      */
-    fun createDispatcher(allFactories: List<MainDispatcherFactory>): MainCoroutineDispatcher
+    public fun createDispatcher(allFactories: List<MainDispatcherFactory>): MainCoroutineDispatcher
 
     /**
      * Hint used along with error message when the factory failed to create a dispatcher.
      */
-    fun hintOnError(): String? = null
+    public fun hintOnError(): String? = null
 }
diff --git a/kotlinx-coroutines-core/common/src/internal/ThreadSafeHeap.kt b/kotlinx-coroutines-core/common/src/internal/ThreadSafeHeap.kt
index 12d6a38..df55c28 100644
--- a/kotlinx-coroutines-core/common/src/internal/ThreadSafeHeap.kt
+++ b/kotlinx-coroutines-core/common/src/internal/ThreadSafeHeap.kt
@@ -32,7 +32,7 @@
 
     public val isEmpty: Boolean get() = size == 0
 
-    public fun clear() = synchronized(this) {
+    public fun clear(): Unit = synchronized(this) {
         a?.fill(null)
         _size.value = 0
     }
@@ -57,7 +57,7 @@
         }
     }
 
-    public fun addLast(node: T) = synchronized(this) { addImpl(node) }
+    public fun addLast(node: T): Unit = synchronized(this) { addImpl(node) }
 
     // @Synchronized // NOTE! NOTE! NOTE! inline fun cannot be @Synchronized
     // Condition also receives current first node in the heap
diff --git a/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt b/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt
index 0951349..1b1c389 100644
--- a/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt
+++ b/kotlinx-coroutines-core/common/src/intrinsics/Cancellable.kt
@@ -13,7 +13,7 @@
  * while waiting to be dispatched.
  */
 @InternalCoroutinesApi
-public fun <T> (suspend () -> T).startCoroutineCancellable(completion: Continuation<T>) = runSafely(completion) {
+public fun <T> (suspend () -> T).startCoroutineCancellable(completion: Continuation<T>): Unit = runSafely(completion) {
     createCoroutineUnintercepted(completion).intercepted().resumeCancellableWith(Result.success(Unit))
 }
 
diff --git a/kotlinx-coroutines-core/common/src/selects/Select.kt b/kotlinx-coroutines-core/common/src/selects/Select.kt
index 1b2be7b..0595341 100644
--- a/kotlinx-coroutines-core/common/src/selects/Select.kt
+++ b/kotlinx-coroutines-core/common/src/selects/Select.kt
@@ -39,7 +39,7 @@
      * Registers clause in this [select] expression with additional nullable parameter of type [P]
      * with the `null` value for this parameter that selects value of type [Q].
      */
-    public operator fun <P, Q> SelectClause2<P?, Q>.invoke(block: suspend (Q) -> R) = invoke(null, block)
+    public operator fun <P, Q> SelectClause2<P?, Q>.invoke(block: suspend (Q) -> R): Unit = invoke(null, block)
 
     /**
      * Clause that selects the given [block] after a specified timeout passes.
@@ -61,7 +61,7 @@
  */
 @ExperimentalCoroutinesApi
 @ExperimentalTime
-public fun <R> SelectBuilder<R>.onTimeout(timeout: Duration, block: suspend () -> R) =
+public fun <R> SelectBuilder<R>.onTimeout(timeout: Duration, block: suspend () -> R): Unit =
         onTimeout(timeout.toDelayMillis(), block)
 
 /**
diff --git a/kotlinx-coroutines-core/js/src/Exceptions.kt b/kotlinx-coroutines-core/js/src/Exceptions.kt
index 39b3344..c82199a 100644
--- a/kotlinx-coroutines-core/js/src/Exceptions.kt
+++ b/kotlinx-coroutines-core/js/src/Exceptions.kt
@@ -14,7 +14,7 @@
     message: String?,
     cause: Throwable?
 ) : IllegalStateException(message, cause) {
-    actual constructor(message: String?) : this(message, null)
+    public actual constructor(message: String?) : this(message, null)
 }
 
 /**
diff --git a/kotlinx-coroutines-core/js/src/internal/LinkedList.kt b/kotlinx-coroutines-core/js/src/internal/LinkedList.kt
index 7daeef2..342b11c 100644
--- a/kotlinx-coroutines-core/js/src/internal/LinkedList.kt
+++ b/kotlinx-coroutines-core/js/src/internal/LinkedList.kt
@@ -2,12 +2,11 @@
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
 
-@file:Suppress("unused")
+@file:Suppress("unused", "NO_EXPLICIT_RETURN_TYPE_IN_API_MODE", "NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 
 package kotlinx.coroutines.internal
 
 private typealias Node = LinkedListNode
-
 /** @suppress **This is unstable API and it is subject to change.** */
 @Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS") // :TODO: Remove when fixed: https://youtrack.jetbrains.com/issue/KT-23703
 public actual typealias LockFreeLinkedListNode = LinkedListNode
diff --git a/kotlinx-coroutines-core/jvm/src/Debug.kt b/kotlinx-coroutines-core/jvm/src/Debug.kt
index aac06ad..8108d23 100644
--- a/kotlinx-coroutines-core/jvm/src/Debug.kt
+++ b/kotlinx-coroutines-core/jvm/src/Debug.kt
@@ -33,7 +33,7 @@
  * Debugging facilities are implemented by [newCoroutineContext][CoroutineScope.newCoroutineContext] function that
  * is used in all coroutine builders to create context of a new coroutine.
  */
-public const val DEBUG_PROPERTY_NAME = "kotlinx.coroutines.debug"
+public const val DEBUG_PROPERTY_NAME: String = "kotlinx.coroutines.debug"
 
 /**
  * Name of the boolean property that controls stacktrace recovery (enabled by default) on JVM.
@@ -51,17 +51,17 @@
 /**
  * Automatic debug configuration value for [DEBUG_PROPERTY_NAME].
  */
-public const val DEBUG_PROPERTY_VALUE_AUTO = "auto"
+public const val DEBUG_PROPERTY_VALUE_AUTO: String = "auto"
 
 /**
  * Debug turned on value for [DEBUG_PROPERTY_NAME].
  */
-public const val DEBUG_PROPERTY_VALUE_ON = "on"
+public const val DEBUG_PROPERTY_VALUE_ON: String = "on"
 
 /**
  * Debug turned on value for [DEBUG_PROPERTY_NAME].
  */
-public const val DEBUG_PROPERTY_VALUE_OFF = "off"
+public const val DEBUG_PROPERTY_VALUE_OFF: String = "off"
 
 // @JvmField: Don't use JvmField here to enable R8 optimizations via "assumenosideeffects"
 internal val ASSERTIONS_ENABLED = CoroutineId::class.java.desiredAssertionStatus()
diff --git a/kotlinx-coroutines-core/jvm/src/Dispatchers.kt b/kotlinx-coroutines-core/jvm/src/Dispatchers.kt
index b9df7ab..8cd3bb1 100644
--- a/kotlinx-coroutines-core/jvm/src/Dispatchers.kt
+++ b/kotlinx-coroutines-core/jvm/src/Dispatchers.kt
@@ -14,7 +14,7 @@
 /**
  * Name of the property that defines the maximal number of threads that are used by [Dispatchers.IO] coroutines dispatcher.
  */
-public const val IO_PARALLELISM_PROPERTY_NAME = "kotlinx.coroutines.io.parallelism"
+public const val IO_PARALLELISM_PROPERTY_NAME: String = "kotlinx.coroutines.io.parallelism"
 
 /**
  * Groups various implementations of [CoroutineDispatcher].
diff --git a/kotlinx-coroutines-core/jvm/src/Future.kt b/kotlinx-coroutines-core/jvm/src/Future.kt
index 54825c3..bd16f49 100644
--- a/kotlinx-coroutines-core/jvm/src/Future.kt
+++ b/kotlinx-coroutines-core/jvm/src/Future.kt
@@ -29,7 +29,7 @@
  * invokeOnCancellation { future.cancel(false) }
  * ```
  */
-public fun CancellableContinuation<*>.cancelFutureOnCancellation(future: Future<*>) =
+public fun CancellableContinuation<*>.cancelFutureOnCancellation(future: Future<*>): Unit =
     invokeOnCancellation(handler = CancelFutureOnCancel(future))
 
 private class CancelFutureOnCompletion(
diff --git a/kotlinx-coroutines-core/jvm/src/ThreadPoolDispatcher.kt b/kotlinx-coroutines-core/jvm/src/ThreadPoolDispatcher.kt
index 7291f0c..a0e1ffa 100644
--- a/kotlinx-coroutines-core/jvm/src/ThreadPoolDispatcher.kt
+++ b/kotlinx-coroutines-core/jvm/src/ThreadPoolDispatcher.kt
@@ -27,7 +27,7 @@
  * @param name the base name of the created thread.
  */
 @ObsoleteCoroutinesApi
-fun newSingleThreadContext(name: String): ExecutorCoroutineDispatcher =
+public fun newSingleThreadContext(name: String): ExecutorCoroutineDispatcher =
     newFixedThreadPoolContext(1, name)
 
 /**
@@ -49,7 +49,7 @@
  * @param name the base name of the created threads.
  */
 @ObsoleteCoroutinesApi
-fun newFixedThreadPoolContext(nThreads: Int, name: String): ExecutorCoroutineDispatcher {
+public fun newFixedThreadPoolContext(nThreads: Int, name: String): ExecutorCoroutineDispatcher {
     require(nThreads >= 1) { "Expected at least one thread, but $nThreads specified" }
     return ThreadPoolDispatcher(nThreads, name)
 }
diff --git a/kotlinx-coroutines-core/jvm/src/channels/Actor.kt b/kotlinx-coroutines-core/jvm/src/channels/Actor.kt
index ea48630..a905426 100644
--- a/kotlinx-coroutines-core/jvm/src/channels/Actor.kt
+++ b/kotlinx-coroutines-core/jvm/src/channels/Actor.kt
@@ -25,7 +25,7 @@
      * All the [ReceiveChannel] functions on this interface delegate to
      * the channel instance returned by this function.
      */
-    val channel: Channel<E>
+    public val channel: Channel<E>
 }
 
 /**
diff --git a/kotlinx-coroutines-core/jvm/src/channels/TickerChannels.kt b/kotlinx-coroutines-core/jvm/src/channels/TickerChannels.kt
index 0f9321a..b9f39af 100644
--- a/kotlinx-coroutines-core/jvm/src/channels/TickerChannels.kt
+++ b/kotlinx-coroutines-core/jvm/src/channels/TickerChannels.kt
@@ -13,7 +13,8 @@
  * **Note: Ticker channels are not currently integrated with structured concurrency and their api will change in the future.**
  */
 @ObsoleteCoroutinesApi
-enum class TickerMode {
+@Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE")
+public enum class TickerMode {
     /**
      * Adjust delay to maintain fixed period if consumer cannot keep up or is otherwise slow.
      * **This is a default mode.**
diff --git a/kotlinx-coroutines-core/jvm/src/internal/LockFreeLinkedList.kt b/kotlinx-coroutines-core/jvm/src/internal/LockFreeLinkedList.kt
index f718df0..29f37da 100644
--- a/kotlinx-coroutines-core/jvm/src/internal/LockFreeLinkedList.kt
+++ b/kotlinx-coroutines-core/jvm/src/internal/LockFreeLinkedList.kt
@@ -1,6 +1,7 @@
 /*
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
+@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 
 package kotlinx.coroutines.internal
 
@@ -433,7 +434,7 @@
             return null
         }
 
-        public fun finishPrepare() = desc.finishPrepare(this)
+        public fun finishPrepare(): Unit = desc.finishPrepare(this)
 
         override fun toString(): String = "PrepareOp(op=$atomicOp)"
     }
diff --git a/kotlinx-coroutines-core/jvm/src/internal/StackTraceRecovery.kt b/kotlinx-coroutines-core/jvm/src/internal/StackTraceRecovery.kt
index f5c5c24..208d3f2 100644
--- a/kotlinx-coroutines-core/jvm/src/internal/StackTraceRecovery.kt
+++ b/kotlinx-coroutines-core/jvm/src/internal/StackTraceRecovery.kt
@@ -2,7 +2,7 @@
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
 
-@file:Suppress("UNCHECKED_CAST")
+@file:Suppress("UNCHECKED_CAST", "NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 
 package kotlinx.coroutines.internal
 
@@ -191,7 +191,7 @@
  * @suppress
  */
 @InternalCoroutinesApi
-public fun artificialFrame(message: String) = java.lang.StackTraceElement("\b\b\b($message", "\b", "\b", -1)
+public fun artificialFrame(message: String): StackTraceElement = java.lang.StackTraceElement("\b\b\b($message", "\b", "\b", -1)
 internal fun StackTraceElement.isArtificial() = className.startsWith("\b\b\b")
 private fun Array<StackTraceElement>.frameIndex(methodName: String) = indexOfFirst { methodName == it.className }
 
diff --git a/kotlinx-coroutines-core/jvm/src/scheduling/Dispatcher.kt b/kotlinx-coroutines-core/jvm/src/scheduling/Dispatcher.kt
index 7398f12..35ebf92 100644
--- a/kotlinx-coroutines-core/jvm/src/scheduling/Dispatcher.kt
+++ b/kotlinx-coroutines-core/jvm/src/scheduling/Dispatcher.kt
@@ -32,20 +32,20 @@
  */
 // TODO make internal (and rename) after complete integration
 @InternalCoroutinesApi
-open class ExperimentalCoroutineDispatcher(
+public open class ExperimentalCoroutineDispatcher(
     private val corePoolSize: Int,
     private val maxPoolSize: Int,
     private val idleWorkerKeepAliveNs: Long,
     private val schedulerName: String = "CoroutineScheduler"
 ) : ExecutorCoroutineDispatcher() {
-    constructor(
+    public constructor(
         corePoolSize: Int = CORE_POOL_SIZE,
         maxPoolSize: Int = MAX_POOL_SIZE,
         schedulerName: String = DEFAULT_SCHEDULER_NAME
     ) : this(corePoolSize, maxPoolSize, IDLE_WORKER_KEEP_ALIVE_NS, schedulerName)
 
     @Deprecated(message = "Binary compatibility for Ktor 1.0-beta", level = DeprecationLevel.HIDDEN)
-    constructor(
+    public constructor(
         corePoolSize: Int = CORE_POOL_SIZE,
         maxPoolSize: Int = MAX_POOL_SIZE
     ) : this(corePoolSize, maxPoolSize, IDLE_WORKER_KEEP_ALIVE_NS)
@@ -70,7 +70,7 @@
             DefaultExecutor.dispatchYield(context, block)
         }
 
-    override fun close() = coroutineScheduler.close()
+    override fun close(): Unit = coroutineScheduler.close()
 
     override fun toString(): String {
         return "${super.toString()}[scheduler = $coroutineScheduler]"
diff --git a/kotlinx-coroutines-core/jvm/src/test_/TestCoroutineContext.kt b/kotlinx-coroutines-core/jvm/src/test_/TestCoroutineContext.kt
index 8a0bd1a..e7c8b6b 100644
--- a/kotlinx-coroutines-core/jvm/src/test_/TestCoroutineContext.kt
+++ b/kotlinx-coroutines-core/jvm/src/test_/TestCoroutineContext.kt
@@ -33,7 +33,7 @@
 @Deprecated("This API has been deprecated to integrate with Structured Concurrency.",
         ReplaceWith("TestCoroutineScope", "kotlin.coroutines.test"),
         level = DeprecationLevel.WARNING)
-class TestCoroutineContext(private val name: String? = null) : CoroutineContext {
+public class TestCoroutineContext(private val name: String? = null) : CoroutineContext {
     private val uncaughtExceptions = mutableListOf<Throwable>()
 
     private val ctxDispatcher = Dispatcher()
@@ -80,7 +80,7 @@
      * @param unit The [TimeUnit] in which the clock-time must be returned.
      * @return The virtual clock-time
      */
-    public fun now(unit: TimeUnit = TimeUnit.MILLISECONDS)=
+    public fun now(unit: TimeUnit = TimeUnit.MILLISECONDS): Long=
         unit.convert(time, TimeUnit.NANOSECONDS)
 
     /**
@@ -105,7 +105,7 @@
      * @param targetTime The point in time to which to move the CoroutineContext's clock.
      * @param unit The [TimeUnit] in which [targetTime] is expressed.
      */
-    fun advanceTimeTo(targetTime: Long, unit: TimeUnit = TimeUnit.MILLISECONDS) {
+    public fun advanceTimeTo(targetTime: Long, unit: TimeUnit = TimeUnit.MILLISECONDS) {
         val nanoTime = unit.toNanos(targetTime)
         triggerActions(nanoTime)
         if (nanoTime > time) time = nanoTime
@@ -115,7 +115,7 @@
      * Triggers any actions that have not yet been triggered and that are scheduled to be triggered at or
      * before this CoroutineContext's present virtual clock-time.
      */
-    public fun triggerActions() = triggerActions(time)
+    public fun triggerActions(): Unit = triggerActions(time)
 
     /**
      * Cancels all not yet triggered actions. Be careful calling this, since it can seriously
diff --git a/kotlinx-coroutines-core/native/src/Debug.kt b/kotlinx-coroutines-core/native/src/Debug.kt
index 26787f8..1fa0ec7 100644
--- a/kotlinx-coroutines-core/native/src/Debug.kt
+++ b/kotlinx-coroutines-core/native/src/Debug.kt
@@ -13,6 +13,6 @@
 internal actual val Any.classSimpleName: String get() = this::class.simpleName ?: "Unknown"
 
 @SymbolName("Kotlin_Any_hashCode")
-external fun Any.id(): Int // Note: can return negative value on K/N
+public external fun Any.id(): Int // Note: can return negative value on K/N
 
 internal actual inline fun assert(value: () -> Boolean) {}
diff --git a/kotlinx-coroutines-core/native/src/Exceptions.kt b/kotlinx-coroutines-core/native/src/Exceptions.kt
index 39b3344..c82199a 100644
--- a/kotlinx-coroutines-core/native/src/Exceptions.kt
+++ b/kotlinx-coroutines-core/native/src/Exceptions.kt
@@ -14,7 +14,7 @@
     message: String?,
     cause: Throwable?
 ) : IllegalStateException(message, cause) {
-    actual constructor(message: String?) : this(message, null)
+    public actual constructor(message: String?) : this(message, null)
 }
 
 /**
diff --git a/kotlinx-coroutines-core/native/src/internal/LinkedList.kt b/kotlinx-coroutines-core/native/src/internal/LinkedList.kt
index 60d0857..9657830 100644
--- a/kotlinx-coroutines-core/native/src/internal/LinkedList.kt
+++ b/kotlinx-coroutines-core/native/src/internal/LinkedList.kt
@@ -1,6 +1,7 @@
 /*
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
+@file:Suppress("NO_EXPLICIT_RETURN_TYPE_IN_API_MODE", "NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 
 package kotlinx.coroutines.internal
 
diff --git a/kotlinx-coroutines-debug/src/CoroutineInfo.kt b/kotlinx-coroutines-debug/src/CoroutineInfo.kt
index d92d9b6..10540d1 100644
--- a/kotlinx-coroutines-debug/src/CoroutineInfo.kt
+++ b/kotlinx-coroutines-debug/src/CoroutineInfo.kt
@@ -2,7 +2,7 @@
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
 
-@file:Suppress("PropertyName")
+@file:Suppress("PropertyName", "NO_EXPLICIT_VISIBILITY_IN_API_MODE")
 
 package kotlinx.coroutines.debug
 
@@ -15,7 +15,7 @@
  */
 @ExperimentalCoroutinesApi
 public class CoroutineInfo internal constructor(
-    val context: CoroutineContext,
+    public val context: CoroutineContext,
     private val creationStackBottom: CoroutineStackFrame?,
     @JvmField internal val sequenceNumber: Long
 ) {
diff --git a/kotlinx-coroutines-debug/src/DebugProbes.kt b/kotlinx-coroutines-debug/src/DebugProbes.kt
index f164e7c..710300c 100644
--- a/kotlinx-coroutines-debug/src/DebugProbes.kt
+++ b/kotlinx-coroutines-debug/src/DebugProbes.kt
@@ -135,7 +135,7 @@
      * ...
      * ```
      */
-    public fun dumpCoroutines(out: PrintStream = System.out) = DebugProbesImpl.dumpCoroutines(out)
+    public fun dumpCoroutines(out: PrintStream = System.out): Unit = DebugProbesImpl.dumpCoroutines(out)
 }
 
 // Stubs which are injected as coroutine probes. Require direct match of signatures
diff --git a/kotlinx-coroutines-debug/src/junit4/CoroutinesTimeout.kt b/kotlinx-coroutines-debug/src/junit4/CoroutinesTimeout.kt
index 0f14ade..0510764 100644
--- a/kotlinx-coroutines-debug/src/junit4/CoroutinesTimeout.kt
+++ b/kotlinx-coroutines-debug/src/junit4/CoroutinesTimeout.kt
@@ -42,7 +42,11 @@
 ) : TestRule {
 
     @Suppress("UNUSED") // Binary compatibility
-    constructor(testTimeoutMs: Long, cancelOnTimeout: Boolean = false) : this(testTimeoutMs, cancelOnTimeout, true)
+    public constructor(testTimeoutMs: Long, cancelOnTimeout: Boolean = false) : this(
+        testTimeoutMs,
+        cancelOnTimeout,
+        true
+    )
 
     init {
         require(testTimeoutMs > 0) { "Expected positive test timeout, but had $testTimeoutMs" }
@@ -55,7 +59,7 @@
         DebugProbes.install()
     }
 
-    companion object {
+    public companion object {
         /**
          * Creates [CoroutinesTimeout] rule with the given timeout in seconds.
          */
diff --git a/kotlinx-coroutines-test/src/TestBuilders.kt b/kotlinx-coroutines-test/src/TestBuilders.kt
index 3b8efb9..88fa01b 100644
--- a/kotlinx-coroutines-test/src/TestBuilders.kt
+++ b/kotlinx-coroutines-test/src/TestBuilders.kt
@@ -69,13 +69,15 @@
  */
 // todo: need documentation on how this extension is supposed to be used
 @ExperimentalCoroutinesApi // Since 1.2.1, tentatively till 1.3.0
-public fun TestCoroutineScope.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) = runBlockingTest(coroutineContext, block)
+public fun TestCoroutineScope.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
+    runBlockingTest(coroutineContext, block)
 
 /**
  * Convenience method for calling [runBlockingTest] on an existing [TestCoroutineDispatcher].
  */
 @ExperimentalCoroutinesApi // Since 1.2.1, tentatively till 1.3.0
-public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) = runBlockingTest(this, block)
+public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
+    runBlockingTest(this, block)
 
 private fun CoroutineContext.checkArguments(): Pair<CoroutineContext, DelayController> {
     // TODO optimize it
diff --git a/kotlinx-coroutines-test/src/TestCoroutineDispatcher.kt b/kotlinx-coroutines-test/src/TestCoroutineDispatcher.kt
index aab869c..4706d62 100644
--- a/kotlinx-coroutines-test/src/TestCoroutineDispatcher.kt
+++ b/kotlinx-coroutines-test/src/TestCoroutineDispatcher.kt
@@ -105,7 +105,7 @@
     }
 
     /** @suppress */
-    override val currentTime get() = _time.value
+    override val currentTime: Long get() = _time.value
 
     /** @suppress */
     override fun advanceTimeBy(delayTimeMillis: Long): Long {
@@ -136,7 +136,7 @@
     }
 
     /** @suppress */
-    override fun runCurrent() = doActionsUntil(currentTime)
+    override fun runCurrent(): Unit  = doActionsUntil(currentTime)
 
     /** @suppress */
     override suspend fun pauseDispatcher(block: suspend () -> Unit) {
diff --git a/kotlinx-coroutines-test/src/TestCoroutineExceptionHandler.kt b/kotlinx-coroutines-test/src/TestCoroutineExceptionHandler.kt
index f585aa0..ed08fbc 100644
--- a/kotlinx-coroutines-test/src/TestCoroutineExceptionHandler.kt
+++ b/kotlinx-coroutines-test/src/TestCoroutineExceptionHandler.kt
@@ -48,7 +48,7 @@
     }
 
     /** @suppress **/
-    override val uncaughtExceptions
+    override val uncaughtExceptions: List<Throwable>
         get() = synchronized(_exceptions) { _exceptions.toList() }
 
     /** @suppress **/
diff --git a/reactive/kotlinx-coroutines-jdk9/src/ReactiveFlow.kt b/reactive/kotlinx-coroutines-jdk9/src/ReactiveFlow.kt
index 6568c73..89caf82 100644
--- a/reactive/kotlinx-coroutines-jdk9/src/ReactiveFlow.kt
+++ b/reactive/kotlinx-coroutines-jdk9/src/ReactiveFlow.kt
@@ -35,5 +35,5 @@
  * Subscribes to this [Publisher] and performs the specified action for each received element.
  * Cancels subscription if any exception happens during collect.
  */
-public suspend inline fun <T> JFlow.Publisher<T>.collect(action: (T) -> Unit) =
+public suspend inline fun <T> JFlow.Publisher<T>.collect(action: (T) -> Unit): Unit =
     FlowAdapters.toPublisher(this).collect(action)
diff --git a/reactive/kotlinx-coroutines-reactive/src/Channel.kt b/reactive/kotlinx-coroutines-reactive/src/Channel.kt
index 8c8187c..379fc4e 100644
--- a/reactive/kotlinx-coroutines-reactive/src/Channel.kt
+++ b/reactive/kotlinx-coroutines-reactive/src/Channel.kt
@@ -35,14 +35,14 @@
 
 // Will be promoted to error in 1.3.0, removed in 1.4.0
 @Deprecated(message = "Use collect instead", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("this.collect(action)"))
-public suspend inline fun <T> Publisher<T>.consumeEach(action: (T) -> Unit) =
+public suspend inline fun <T> Publisher<T>.consumeEach(action: (T) -> Unit): Unit =
     openSubscription().consumeEach(action)
 
 /**
  * Subscribes to this [Publisher] and performs the specified action for each received element.
  * Cancels subscription if any exception happens during collect.
  */
-public suspend inline fun <T> Publisher<T>.collect(action: (T) -> Unit) =
+public suspend inline fun <T> Publisher<T>.collect(action: (T) -> Unit): Unit =
     openSubscription().consumeEach(action)
 
 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "SubscriberImplementation")
diff --git a/reactive/kotlinx-coroutines-reactive/src/Publish.kt b/reactive/kotlinx-coroutines-reactive/src/Publish.kt
index 68c1702..ddfd7f8 100644
--- a/reactive/kotlinx-coroutines-reactive/src/Publish.kt
+++ b/reactive/kotlinx-coroutines-reactive/src/Publish.kt
@@ -93,7 +93,7 @@
     override val isClosedForSend: Boolean get() = isCompleted
     override val isFull: Boolean = mutex.isLocked
     override fun close(cause: Throwable?): Boolean = cancelCoroutine(cause)
-    override fun invokeOnClose(handler: (Throwable?) -> Unit) =
+    override fun invokeOnClose(handler: (Throwable?) -> Unit): Nothing =
         throw UnsupportedOperationException("PublisherCoroutine doesn't support invokeOnClose")
 
     override fun offer(element: T): Boolean {
diff --git a/reactive/kotlinx-coroutines-reactive/src/ReactiveFlow.kt b/reactive/kotlinx-coroutines-reactive/src/ReactiveFlow.kt
index 20e165e..20e59f6 100644
--- a/reactive/kotlinx-coroutines-reactive/src/ReactiveFlow.kt
+++ b/reactive/kotlinx-coroutines-reactive/src/ReactiveFlow.kt
@@ -163,8 +163,8 @@
 /** @suppress */
 @InternalCoroutinesApi
 public class FlowSubscription<T>(
-    @JvmField val flow: Flow<T>,
-    @JvmField val subscriber: Subscriber<in T>
+    @JvmField public val flow: Flow<T>,
+    @JvmField public val subscriber: Subscriber<in T>
 ) : Subscription, AbstractCoroutine<Unit>(Dispatchers.Unconfined, false) {
     private val requested = atomic(0L)
     private val producer = atomic<CancellableContinuation<Unit>?>(null)
diff --git a/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt b/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt
index 9f5eb23..69467ad 100644
--- a/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt
+++ b/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt
@@ -49,7 +49,7 @@
  */
 @ExperimentalCoroutinesApi
 public class ReactorContext(public val context: Context) : AbstractCoroutineContextElement(ReactorContext) {
-    companion object Key : CoroutineContext.Key<ReactorContext>
+    public companion object Key : CoroutineContext.Key<ReactorContext>
 }
 
 /**
diff --git a/reactive/kotlinx-coroutines-reactor/src/Scheduler.kt b/reactive/kotlinx-coroutines-reactor/src/Scheduler.kt
index 833ceb2..e176c07 100644
--- a/reactive/kotlinx-coroutines-reactor/src/Scheduler.kt
+++ b/reactive/kotlinx-coroutines-reactor/src/Scheduler.kt
@@ -13,7 +13,7 @@
 /**
  * Converts an instance of [Scheduler] to an implementation of [CoroutineDispatcher].
  */
-fun Scheduler.asCoroutineDispatcher(): SchedulerCoroutineDispatcher = SchedulerCoroutineDispatcher(this)
+public fun Scheduler.asCoroutineDispatcher(): SchedulerCoroutineDispatcher = SchedulerCoroutineDispatcher(this)
 
 /**
  * Implements [CoroutineDispatcher] on top of an arbitrary [Scheduler].
diff --git a/reactive/kotlinx-coroutines-rx2/src/RxChannel.kt b/reactive/kotlinx-coroutines-rx2/src/RxChannel.kt
index 9f31b2a..e253161 100644
--- a/reactive/kotlinx-coroutines-rx2/src/RxChannel.kt
+++ b/reactive/kotlinx-coroutines-rx2/src/RxChannel.kt
@@ -40,26 +40,26 @@
 
 // Will be promoted to error in 1.3.0, removed in 1.4.0
 @Deprecated(message = "Use collect instead", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("this.collect(action)"))
-public suspend inline fun <T> MaybeSource<T>.consumeEach(action: (T) -> Unit) =
+public suspend inline fun <T> MaybeSource<T>.consumeEach(action: (T) -> Unit): Unit =
     openSubscription().consumeEach(action)
 
 // Will be promoted to error in 1.3.0, removed in 1.4.0
 @Deprecated(message = "Use collect instead", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("this.collect(action)"))
-public suspend inline fun <T> ObservableSource<T>.consumeEach(action: (T) -> Unit) =
+public suspend inline fun <T> ObservableSource<T>.consumeEach(action: (T) -> Unit): Unit =
     openSubscription().consumeEach(action)
 
 /**
  * Subscribes to this [MaybeSource] and performs the specified action for each received element.
  * Cancels subscription if any exception happens during collect.
  */
-public suspend inline fun <T> MaybeSource<T>.collect(action: (T) -> Unit) =
+public suspend inline fun <T> MaybeSource<T>.collect(action: (T) -> Unit): Unit =
     openSubscription().consumeEach(action)
 
 /**
  * Subscribes to this [ObservableSource] and performs the specified action for each received element.
  * Cancels subscription if any exception happens during collect.
  */
-public suspend inline fun <T> ObservableSource<T>.collect(action: (T) -> Unit) =
+public suspend inline fun <T> ObservableSource<T>.collect(action: (T) -> Unit): Unit =
     openSubscription().consumeEach(action)
 
 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
diff --git a/stdlib-stubs/src/ContinuationInterceptor.kt b/stdlib-stubs/src/ContinuationInterceptor.kt
index 47935e3..ebf0a33 100644
--- a/stdlib-stubs/src/ContinuationInterceptor.kt
+++ b/stdlib-stubs/src/ContinuationInterceptor.kt
@@ -5,7 +5,7 @@
 
 // DOKKA STUB
 public interface ContinuationInterceptor : CoroutineContext.Element {
-    companion object Key : CoroutineContext.Key<ContinuationInterceptor>
+    public companion object Key : CoroutineContext.Key<ContinuationInterceptor>
     public fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T>
     public fun releaseInterceptedContinuation(continuation: Continuation<*>): Continuation<*> {
         return continuation
diff --git a/stdlib-stubs/src/Result.kt b/stdlib-stubs/src/Result.kt
index 6dc8d9c..611074a 100644
--- a/stdlib-stubs/src/Result.kt
+++ b/stdlib-stubs/src/Result.kt
@@ -4,7 +4,7 @@
 
 package kotlin
 
-interface Result<out T> {
+public interface Result<out T> {
     public val value: T
     public val isSuccess: Boolean
     public val isFailure: Boolean
diff --git a/ui/kotlinx-coroutines-javafx/src/JavaFxDispatcher.kt b/ui/kotlinx-coroutines-javafx/src/JavaFxDispatcher.kt
index ed74ad6..5f39bf7 100644
--- a/ui/kotlinx-coroutines-javafx/src/JavaFxDispatcher.kt
+++ b/ui/kotlinx-coroutines-javafx/src/JavaFxDispatcher.kt
@@ -31,7 +31,7 @@
 public sealed class JavaFxDispatcher : MainCoroutineDispatcher(), Delay {
 
     /** @suppress */
-    override fun dispatch(context: CoroutineContext, block: Runnable) = Platform.runLater(block)
+    override fun dispatch(context: CoroutineContext, block: Runnable): Unit = Platform.runLater(block)
 
     /** @suppress */
     override fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>) {
diff --git a/ui/kotlinx-coroutines-swing/src/SwingDispatcher.kt b/ui/kotlinx-coroutines-swing/src/SwingDispatcher.kt
index 3fad55f..50efe47 100644
--- a/ui/kotlinx-coroutines-swing/src/SwingDispatcher.kt
+++ b/ui/kotlinx-coroutines-swing/src/SwingDispatcher.kt
@@ -25,7 +25,7 @@
  */
 public sealed class SwingDispatcher : MainCoroutineDispatcher(), Delay {
     /** @suppress */
-    override fun dispatch(context: CoroutineContext, block: Runnable) = SwingUtilities.invokeLater(block)
+    override fun dispatch(context: CoroutineContext, block: Runnable): Unit = SwingUtilities.invokeLater(block)
 
     /** @suppress */
     override fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>) {