Update to Kotlin 1.5 (and associated deps) (#1339)

This commit is contained in:
Zac Sweers
2021-05-07 12:51:33 -04:00
committed by GitHub
parent 45c8595bfa
commit e343751593
12 changed files with 156 additions and 135 deletions

View File

@@ -26,8 +26,7 @@ tasks.withType<KotlinCompile>().configureEach {
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf(
"-Werror",
"-Xopt-in=kotlin.ExperimentalStdlibApi",
"-Xinline-classes"
"-Xopt-in=kotlin.ExperimentalStdlibApi"
)
}
}

View File

@@ -285,9 +285,9 @@ class DualKotlinTest(useReflection: Boolean) {
}
@Test fun inlineClass() {
val adapter = moshi.adapter<InlineClass>()
val adapter = moshi.adapter<ValueClass>()
val inline = InlineClass(5)
val inline = ValueClass(5)
val expectedJson =
"""{"i":5}"""
@@ -300,12 +300,12 @@ class DualKotlinTest(useReflection: Boolean) {
}
@JsonClass(generateAdapter = true)
data class InlineConsumer(val inline: InlineClass)
data class InlineConsumer(val inline: ValueClass)
@Test fun inlineClassConsumer() {
val adapter = moshi.adapter<InlineConsumer>()
val consumer = InlineConsumer(InlineClass(23))
val consumer = InlineConsumer(ValueClass(23))
@Language("JSON")
val expectedJson =
@@ -622,9 +622,10 @@ typealias GenericTypeAlias = List<out GenericClass<in TypeAlias>?>?
@JsonClass(generateAdapter = true)
data class GenericClass<T>(val value: T)
// Has to be outside since inline classes are only allowed on top level
// Has to be outside since value classes are only allowed on top level
@JvmInline
@JsonClass(generateAdapter = true)
inline class InlineClass(val i: Int)
value class ValueClass(val i: Int)
typealias A = Int
typealias NullableA = A?

View File

@@ -1191,11 +1191,14 @@ class GeneratedAdaptersTest {
annotation class Uppercase(val inFrench: Boolean, val onSundays: Boolean = false)
class UppercaseJsonAdapter {
@ToJson fun toJson(@Uppercase(inFrench = true) s: String): String {
return s.toUpperCase(Locale.US)
@ToJson
fun toJson(@Uppercase(inFrench = true) s: String): String {
return s.uppercase(Locale.US)
}
@FromJson @Uppercase(inFrench = true) fun fromJson(s: String): String {
return s.toLowerCase(Locale.US)
@FromJson
@Uppercase(inFrench = true)
fun fromJson(s: String): String {
return s.lowercase(Locale.US)
}
}

View File

@@ -24,10 +24,13 @@ import java.util.Locale
annotation class UppercaseInAnnotationPackage
class UppercaseInAnnotationPackageJsonAdapter {
@ToJson fun toJson(@UppercaseInAnnotationPackage s: String): String {
return s.toUpperCase(Locale.US)
@ToJson
fun toJson(@UppercaseInAnnotationPackage s: String): String {
return s.uppercase(Locale.US)
}
@FromJson @UppercaseInAnnotationPackage fun fromJson(s: String): String {
return s.toLowerCase(Locale.US)
@FromJson
@UppercaseInAnnotationPackage
fun fromJson(s: String): String {
return s.lowercase(Locale.US)
}
}

View File

@@ -916,11 +916,14 @@ class KotlinJsonAdapterTest {
annotation class Uppercase
class UppercaseJsonAdapter {
@ToJson fun toJson(@Uppercase s: String): String {
return s.toUpperCase(Locale.US)
@ToJson
fun toJson(@Uppercase s: String): String {
return s.uppercase(Locale.US)
}
@FromJson @Uppercase fun fromJson(s: String): String {
return s.toLowerCase(Locale.US)
@FromJson
@Uppercase
fun fromJson(s: String): String {
return s.lowercase(Locale.US)
}
}