Update to KotlinPoet 1.4.2 (#972)

* Unwrap typealiases

This was a change in 1.4.2 left over from moshi's prior metadata logic. We need the unwrapped type for class references

* Add toe-hold for testing shared adapter behavior

* Add regression test for abstractSuperProperties

* Kotlinpoet 1.4.2
This commit is contained in:
Zac Sweers
2019-10-29 07:51:17 -04:00
committed by Jesse Wilson
parent 73bc12735e
commit d5a43e35f3
4 changed files with 55 additions and 3 deletions

View File

@@ -302,6 +302,26 @@ class DualKotlinTest(useReflection: Boolean) {
class TextAsset : Asset<TextAsset>()
abstract class Asset<A : Asset<A>>
abstract class AssetMetaData<A : Asset<A>>
// Regression test for https://github.com/square/moshi/issues/968
@Test fun abstractSuperProperties() {
val adapter = moshi.adapter<InternalAbstractProperty>()
@Language("JSON")
val testJson = """{"test":"text"}"""
assertThat(adapter.toJson(InternalAbstractProperty("text"))).isEqualTo(testJson)
val result = adapter.fromJson(testJson)!!
assertThat(result.test).isEqualTo("text")
}
abstract class InternalAbstractPropertyBase {
internal abstract val test: String
}
@JsonClass(generateAdapter = true)
class InternalAbstractProperty(override val test: String) : InternalAbstractPropertyBase()
}
// Has to be outside since inline classes are only allowed on top level