Fix a crash when processing a parameter annotated with an annotation that placed in annotation package (#1287)

* Update KotlinPoet to 1.7.2

* Fix a Java NPE crash when processing a parameter annotated with an annotation that placed in annotation package

This problem happens with KotlinPoet 1.7.x.
From KotlinPoet 1.7.x, `TypeName.toString()` is escaped with backquotes if the package name contains keywords.
So NPE will be thrown if an annotation is placed in `annotation` package because `elements.getTypeElement(it.typeName.toString())` returns `null`.

* Reformat imports

* Use rawType().canonicalName instead of toString()

* Fix test case

* Require getTypeElement

* Exclude com.google.guava from shadowJar

* Move a test case of processing a qualifier placed in `annotation` package

* Use checkNull instead
This commit is contained in:
Masatoshi Kubode
2021-02-22 16:43:04 +09:00
committed by GitHub
parent 7f1e7e229e
commit 156b1f0365
5 changed files with 58 additions and 2 deletions

View File

@@ -44,7 +44,7 @@ object Dependencies {
}
object KotlinPoet {
private const val version = "1.6.0"
private const val version = "1.7.2"
const val kotlinPoet = "com.squareup:kotlinpoet:$version"
const val metadata = "com.squareup:kotlinpoet-metadata-specs:$version"
const val metadataSpecs = "com.squareup:kotlinpoet-metadata-specs:$version"