Skip to content

Commit

Permalink
Kotlin 1.3 - Step 2: Fix warnings.
Browse files Browse the repository at this point in the history
Closes #35.
  • Loading branch information
zach-klippenstein committed Mar 17, 2019
1 parent 98db997 commit d4c3caf
Show file tree
Hide file tree
Showing 32 changed files with 80 additions and 16 deletions.
2 changes: 0 additions & 2 deletions kotlin/legacy/legacy-workflow-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'com.vanniktech.maven.publish'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

kotlin.experimental.coroutines 'enable'

dependencies {
compileOnly deps.annotations.intellij

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import kotlinx.coroutines.CoroutineScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import kotlinx.coroutines.CancellationException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -113,6 +115,7 @@ fun <S : Any, E : Any, O1 : Any, O2 : Any> Workflow<S, E, O1>.mapResult(
// Propagate cancellation upstream.
transformedResult.invokeOnCompletion { cause ->
if (cause != null) {
@Suppress("DEPRECATION")
this@mapResult.cancel(cause)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import com.squareup.workflow.legacy.WorkflowPool.Handle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import kotlinx.coroutines.CancellationException
Expand Down Expand Up @@ -172,6 +174,23 @@ class CoroutineWorkflowTest : CoroutineScope {
}

@Test fun `block gets original cancellation reason`() {
lateinit var cancelReason: Throwable
val workflow = workflow<Nothing, Nothing, Nothing> { _, _ ->
suspendCancellableCoroutine<Nothing> { continuation ->
continuation.invokeOnCancellation {
cancelReason = it!!
}
}
}
testContext.triggerActions()
workflow.cancel()

assertTrue(cancelReason is CancellationException)
assertNull(cancelReason.cause)
}

@Suppress("DEPRECATION")
@Test fun `block gets original cancellation reason - deprecated cancel`() {
lateinit var cancelReason: Throwable
val workflow = workflow<Nothing, Nothing, Nothing> { _, _ ->
suspendCancellableCoroutine<Nothing> { continuation ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import com.squareup.workflow.legacy.TestState.FirstState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import kotlinx.coroutines.CancellationException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import kotlinx.coroutines.CancellationException
Expand Down Expand Up @@ -79,6 +81,7 @@ class WorkflowOperatorsTest {
it.toString()
}

@Suppress("DEPRECATION")
withAdaptedEvents.cancel(ExpectedException())

assertTrue(sourceCancellation is CancellationException)
Expand Down Expand Up @@ -157,6 +160,7 @@ class WorkflowOperatorsTest {
val withMappedStates = source.mapState { it }

assertNull(sourceCancellation)
@Suppress("DEPRECATION")
withMappedStates.cancel(ExpectedException())
assertTrue(sourceCancellation is CancellationException)
}
Expand Down Expand Up @@ -314,7 +318,10 @@ class WorkflowOperatorsTest {
state.send(42)
}
val withMappedStates: Workflow<Int, Unit, Unit> = source.switchMapState {
Channel<Int>().apply { cancel(ExpectedException()) }
Channel<Int>().apply {
@Suppress("DEPRECATION")
cancel(ExpectedException())
}
}

withMappedStates.openSubscriptionToState()
Expand Down Expand Up @@ -361,6 +368,7 @@ class WorkflowOperatorsTest {
withMappedStates.sendEvent(Unit)

assertFalse(transformedChannel.isClosedForSend)
@Suppress("DEPRECATION")
this.cancel(ExpectedException())
assertTrue(transformedChannel.isClosedForSend)
}
Expand All @@ -378,6 +386,7 @@ class WorkflowOperatorsTest {
val withMappedStates = source.switchMapState { produce { send(it) } }

assertNull(sourceCancellation)
@Suppress("DEPRECATION")
withMappedStates.cancel(ExpectedException())
assertTrue(sourceCancellation is CancellationException)
}
Expand Down Expand Up @@ -436,6 +445,7 @@ class WorkflowOperatorsTest {
val withMappedResult = source.mapResult { it }

assertNull(sourceCancellation)
@Suppress("DEPRECATION")
withMappedResult.cancel(ExpectedException())
assertTrue(sourceCancellation is CancellationException)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy

import kotlinx.coroutines.CancellationException
Expand Down
2 changes: 0 additions & 2 deletions kotlin/legacy/legacy-workflow-rx2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'com.vanniktech.maven.publish'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

kotlin.experimental.coroutines 'enable'

dependencies {
compileOnly deps.annotations.intellij
compileOnly deps.annotations.androidSupport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("DeprecatedCallableAddReplaceWith")
@file:Suppress("DeprecatedCallableAddReplaceWith", "EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy.rx2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy.rx2

import com.squareup.workflow.legacy.Workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy.rx2

import com.squareup.workflow.legacy.Workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.legacy.rx2

import com.squareup.workflow.legacy.Finished
Expand Down
2 changes: 0 additions & 2 deletions kotlin/viewregistry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'com.vanniktech.maven.publish'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

kotlin.experimental.coroutines 'enable'

dependencies {
api deps.kotlin.stdLib.jdk6
api deps.okio
Expand Down
2 changes: 0 additions & 2 deletions kotlin/workflow-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'com.vanniktech.maven.publish'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

kotlin.experimental.coroutines 'enable'

dependencies {
compileOnly deps.annotations.intellij

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow

import okio.Buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow

import com.squareup.workflow.ChannelUpdate.Value
Expand Down
2 changes: 0 additions & 2 deletions kotlin/workflow-host/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'com.vanniktech.maven.publish'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

kotlin.experimental.coroutines 'enable'

dependencies {
compileOnly deps.annotations.intellij

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow

import com.squareup.workflow.WorkflowHost.Factory
Expand Down Expand Up @@ -139,6 +141,7 @@ internal fun <I : Any, S : Any, O : Any, R : Any> WorkflowNode<I, S, O, R>.start
} catch (e: Throwable) {
// For some reason the exception gets masked if we don't explicitly pass it to cancel the
// producer coroutine ourselves here.
@Suppress("DEPRECATION")
coroutineContext.cancel(e)
throw e
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.internal

import com.squareup.workflow.ChannelUpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.internal

import com.squareup.workflow.ChannelUpdate
Expand Down Expand Up @@ -80,6 +82,7 @@ class ChannelUpdatesTest {

@Test fun handlesError() {
val channel = Channel<String>()
@Suppress("DEPRECATION")
channel.cancel(ExpectedException())

assertFailsWith<ExpectedException> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.internal

import com.squareup.workflow.Snapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.internal

import com.squareup.workflow.Snapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.internal

import com.squareup.workflow.Snapshot
Expand Down
2 changes: 0 additions & 2 deletions kotlin/workflow-rx2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'com.vanniktech.maven.publish'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

kotlin.experimental.coroutines 'enable'

dependencies {
compileOnly deps.annotations.intellij

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.rx2

import com.squareup.workflow.ChannelUpdate
Expand Down
2 changes: 0 additions & 2 deletions kotlin/workflow-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ apply plugin: 'com.vanniktech.maven.publish'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

kotlin.experimental.coroutines 'enable'

dependencies {
compileOnly deps.annotations.intellij

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.testing

import com.squareup.workflow.Snapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")

package com.squareup.workflow.testing

import com.squareup.workflow.Snapshot
Expand Down Expand Up @@ -102,6 +104,7 @@ private fun <O : Any, R : Any> test(
throw e
} finally {
if (error != null) {
@Suppress("DEPRECATION")
val cancelled = context.cancel(error)
if (!cancelled) {
val cancellationCause = context[Job]!!.getCancellationException()
Expand Down
Loading

0 comments on commit d4c3caf

Please sign in to comment.