mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Update to KotlinPoet 1.4.1/Kotlin 1.3.50 (#956)
* KotlinPoet 1.4.1 & Kotlin 1.3.50 KotlinPoet uses 1.3.50, so this just matches that now * Remove now-unnecessary custom shade This uses the same common package prefix in kotlinpoet now * Add backwardReferencingTypeVars() regression test Coverage for #955
This commit is contained in:
@@ -217,10 +217,6 @@
|
|||||||
<pattern>com.squareup.kotlinpoet.classinspector</pattern>
|
<pattern>com.squareup.kotlinpoet.classinspector</pattern>
|
||||||
<shadedPattern>com.squareup.moshi.kotlinpoet.classinspector</shadedPattern>
|
<shadedPattern>com.squareup.moshi.kotlinpoet.classinspector</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
|
||||||
<pattern>kotlinpoet.classinspector.elements.shaded</pattern>
|
|
||||||
<shadedPattern>com.squareup.moshi.kotlinpoet.classinspector.elements.shaded</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>kotlinx.metadata</pattern>
|
<pattern>kotlinx.metadata</pattern>
|
||||||
<shadedPattern>com.squareup.moshi.kotlinx.metadata</shadedPattern>
|
<shadedPattern>com.squareup.moshi.kotlinx.metadata</shadedPattern>
|
||||||
|
@@ -12,6 +12,7 @@ import com.squareup.moshi.Types
|
|||||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
import com.squareup.moshi.kotlin.reflect.adapter
|
import com.squareup.moshi.kotlin.reflect.adapter
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
|
import org.intellij.lang.annotations.Language
|
||||||
import org.junit.Assert.fail
|
import org.junit.Assert.fail
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@@ -273,13 +274,34 @@ class DualKotlinTest(useReflection: Boolean) {
|
|||||||
|
|
||||||
val consumer = InlineConsumer(InlineClass(23))
|
val consumer = InlineConsumer(InlineClass(23))
|
||||||
|
|
||||||
val expectedJson= """{"inline":{"i":23}}"""
|
@Language("JSON")
|
||||||
|
val expectedJson = """{"inline":{"i":23}}"""
|
||||||
assertThat(adapter.toJson(consumer)).isEqualTo(expectedJson)
|
assertThat(adapter.toJson(consumer)).isEqualTo(expectedJson)
|
||||||
|
|
||||||
|
@Language("JSON")
|
||||||
val testJson = """{"inline":{"i":42}}"""
|
val testJson = """{"inline":{"i":42}}"""
|
||||||
val result = adapter.fromJson(testJson)!!
|
val result = adapter.fromJson(testJson)!!
|
||||||
assertThat(result.inline.i).isEqualTo(42)
|
assertThat(result.inline.i).isEqualTo(42)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression test for https://github.com/square/moshi/issues/955
|
||||||
|
@Test fun backwardReferencingTypeVars() {
|
||||||
|
val adapter = moshi.adapter<TextAssetMetaData>()
|
||||||
|
|
||||||
|
@Language("JSON")
|
||||||
|
val testJson = """{"text":"text"}"""
|
||||||
|
|
||||||
|
assertThat(adapter.toJson(TextAssetMetaData("text"))).isEqualTo(testJson)
|
||||||
|
|
||||||
|
val result = adapter.fromJson(testJson)!!
|
||||||
|
assertThat(result.text).isEqualTo("text")
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
class TextAssetMetaData(val text: String) : AssetMetaData<TextAsset>()
|
||||||
|
class TextAsset : Asset<TextAsset>()
|
||||||
|
abstract class Asset<A : Asset<A>>
|
||||||
|
abstract class AssetMetaData<A : Asset<A>>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has to be outside since inline classes are only allowed on top level
|
// Has to be outside since inline classes are only allowed on top level
|
||||||
|
4
pom.xml
4
pom.xml
@@ -36,8 +36,8 @@
|
|||||||
<incap.version>0.2</incap.version>
|
<incap.version>0.2</incap.version>
|
||||||
<okio.version>1.16.0</okio.version>
|
<okio.version>1.16.0</okio.version>
|
||||||
<okio2.version>2.1.0</okio2.version>
|
<okio2.version>2.1.0</okio2.version>
|
||||||
<kotlin.version>1.3.40</kotlin.version>
|
<kotlin.version>1.3.50</kotlin.version>
|
||||||
<kotlinpoet.version>1.4.0</kotlinpoet.version>
|
<kotlinpoet.version>1.4.1</kotlinpoet.version>
|
||||||
<kotlinx-metadata.version>0.1.0</kotlinx-metadata.version>
|
<kotlinx-metadata.version>0.1.0</kotlinx-metadata.version>
|
||||||
<maven-assembly.version>3.1.0</maven-assembly.version>
|
<maven-assembly.version>3.1.0</maven-assembly.version>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user