Update to Kotlin 1.3 (#254)
This commit is contained in:
Родитель
df77d08c83
Коммит
4490117b05
|
@ -28,7 +28,7 @@ allprojects {
|
|||
version VERSION
|
||||
|
||||
project.ext {
|
||||
kotlin_version = '1.2.71'
|
||||
kotlin_version = '1.3.0'
|
||||
|
||||
libraries = [
|
||||
clikt: [
|
||||
|
@ -85,7 +85,7 @@ buildscript {
|
|||
|
||||
dependencies {
|
||||
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.14'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.0"
|
||||
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:0.9.17'
|
||||
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
|
||||
}
|
||||
|
|
|
@ -131,10 +131,3 @@ compileTestJava {
|
|||
tasks['javadoc'].configure {
|
||||
exclude '**/generated-src/**'
|
||||
}
|
||||
|
||||
kotlin {
|
||||
experimental {
|
||||
coroutines "enable"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ import com.microsoft.thrifty.transport.SocketTransport
|
|||
import com.microsoft.thrifty.transport.Transport
|
||||
import io.kotlintest.fail
|
||||
import io.kotlintest.shouldBe
|
||||
import kotlinx.coroutines.experimental.async
|
||||
import kotlinx.coroutines.experimental.awaitAll
|
||||
import kotlinx.coroutines.experimental.runBlocking
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okio.ByteString
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
|
|
|
@ -37,9 +37,3 @@ dependencies {
|
|||
|
||||
testImplementation 'com.google.testing.compile:compile-testing:0.9'
|
||||
}
|
||||
|
||||
kotlin {
|
||||
experimental {
|
||||
coroutines "enable"
|
||||
}
|
||||
}
|
|
@ -84,7 +84,6 @@ import com.squareup.kotlinpoet.asClassName
|
|||
import com.squareup.kotlinpoet.asTypeName
|
||||
import com.squareup.kotlinpoet.jvm.jvmField
|
||||
import com.squareup.kotlinpoet.jvm.jvmStatic
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
import okio.ByteString
|
||||
import java.io.IOException
|
||||
import javax.annotation.Generated
|
||||
|
@ -281,7 +280,7 @@ class KotlinCodeGenerator(
|
|||
}
|
||||
|
||||
OutputStyle.FILE_PER_TYPE -> {
|
||||
buildSequence {
|
||||
sequence {
|
||||
|
||||
val types = specsByNamespace.entries().asSequence()
|
||||
for ((ns, type) in types) {
|
||||
|
@ -1594,7 +1593,8 @@ class KotlinCodeGenerator(
|
|||
|
||||
// suspendCoroutine is obviously not a class, but until kotlinpoet supports
|
||||
// importing fully-qualified fun names, we can pun and use a ClassName.
|
||||
val suspendCoroFn = ClassName("kotlin.coroutines.experimental", "suspendCoroutine")
|
||||
val suspendCoroFn = ClassName("kotlin.coroutines", "suspendCoroutine")
|
||||
val coroResultClass = ClassName("kotlin", "Result")
|
||||
|
||||
for ((index, interfaceFun) in serviceInterface.funSpecs.withIndex()) {
|
||||
val method = serviceType.methods[index]
|
||||
|
@ -1614,16 +1614,16 @@ class KotlinCodeGenerator(
|
|||
//
|
||||
// It's a bit ungainly, but as an implementation detail it's acceptable.
|
||||
if (method.oneWay) {
|
||||
addStatement("cont.resume(Unit)")
|
||||
addStatement("cont.resumeWith(%T.success(Unit))", coroResultClass)
|
||||
} else {
|
||||
addStatement("cont.resume(result)")
|
||||
addStatement("cont.resumeWith(%T.success(result))", coroResultClass)
|
||||
}
|
||||
}
|
||||
.build())
|
||||
.addFunction(FunSpec.builder("onError")
|
||||
.addModifiers(KModifier.OVERRIDE)
|
||||
.addParameter("error", Throwable::class)
|
||||
.addStatement("cont.resumeWithException(error)")
|
||||
.addStatement("cont.resumeWith(%T.failure(error))", coroResultClass)
|
||||
.build())
|
||||
.build()
|
||||
|
||||
|
|
|
@ -340,11 +340,11 @@ class KotlinCodeGeneratorTest {
|
|||
| override suspend fun doSomething(foo: Int): Int = suspendCoroutine { cont ->
|
||||
| this.enqueue(DoSomethingCall(foo, object : ServiceMethodCallback<Int> {
|
||||
| override fun onSuccess(result: Int) {
|
||||
| cont.resume(result)
|
||||
| cont.resumeWith(Result.success(result))
|
||||
| }
|
||||
|
|
||||
| override fun onError(error: Throwable) {
|
||||
| cont.resumeWithException(error)
|
||||
| cont.resumeWith(Result.failure(error))
|
||||
| }
|
||||
| }))
|
||||
| }
|
||||
|
|
|
@ -25,11 +25,5 @@ apply plugin: 'kotlin'
|
|||
dependencies {
|
||||
api project(':thrifty-runtime')
|
||||
api libraries.kotlin
|
||||
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.24.0'
|
||||
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0'
|
||||
}
|
||||
|
||||
kotlin {
|
||||
experimental {
|
||||
coroutines "enable"
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче