Update KotlinPoet to 1.3.0 (#915)

* Update to KotlinPoet 1.3.0

* Add hotwords test case

* Use %N for toJson parameter names to ensure escaping
This commit is contained in:
Zac Sweers
2019-09-12 14:13:23 -04:00
committed by GitHub
parent 1978581b3d
commit 98092d0727
3 changed files with 8 additions and 2 deletions

View File

@@ -25,7 +25,7 @@
<dependency>
<groupId>com.squareup</groupId>
<artifactId>kotlinpoet</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>net.ltgt.gradle.incap</groupId>

View File

@@ -332,7 +332,7 @@ internal class AdapterGenerator(
result.addStatement("%N.beginObject()", writerParam)
nonTransientProperties.forEach { property ->
result.addStatement("%N.name(%S)", writerParam, property.jsonName)
result.addStatement("%N.toJson(%N, %N.%L)",
result.addStatement("%N.toJson(%N, %N.%N)",
nameAllocator[property.delegateKey], writerParam, valueParam, property.name)
}
result.addStatement("%N.endObject()", writerParam)

View File

@@ -1223,5 +1223,11 @@ data class SmokeTestType(
val genericAlias: GenericTypeAlias = listOf("Woah")
)
// Compile only, regression test for https://github.com/square/moshi/issues/848
@JsonClass(generateAdapter = true)
data class Hotwords(
val `class`: List<String>?
)
typealias TypeAliasName = String
typealias GenericTypeAlias = List<String>