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:
Zac Sweers
2019-10-26 15:04:51 -04:00
committed by Jesse Wilson
parent 870fee4332
commit 01b7ea4ba2
3 changed files with 25 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ import com.squareup.moshi.Types
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import com.squareup.moshi.kotlin.reflect.adapter
import org.assertj.core.api.Assertions.assertThat
import org.intellij.lang.annotations.Language
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
@@ -273,13 +274,34 @@ class DualKotlinTest(useReflection: Boolean) {
val consumer = InlineConsumer(InlineClass(23))
val expectedJson= """{"inline":{"i":23}}"""
@Language("JSON")
val expectedJson = """{"inline":{"i":23}}"""
assertThat(adapter.toJson(consumer)).isEqualTo(expectedJson)
@Language("JSON")
val testJson = """{"inline":{"i":42}}"""
val result = adapter.fromJson(testJson)!!
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