Skip to content

Commit 4c4eb5d

Browse files
committed
Fixes from pr feedback
1 parent aea9c0c commit 4c4eb5d

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

interop/ksp/src/main/kotlin/com/squareup/kotlinpoet/ksp/Annotations.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ public fun KSAnnotation.toAnnotationSpec(omitDefaultValues: Boolean = false): An
5353
if (isDefaultValue(value, defaultValue)) { continue }
5454
}
5555
if (type?.isVararg == true) {
56-
// wait to add varargs to end
56+
// Wait to add varargs to end.
5757
varargValues = value as List<*>
5858
} else {
5959
val member = CodeBlock.builder()
6060
member.add("%N = ", name)
6161
addValueToBlock(value, member, omitDefaultValues)
6262
builder.addMember(member.build())
6363
}
64-
if (varargValues != null) {
65-
for (item in varargValues) {
66-
val member = CodeBlock.builder()
67-
addValueToBlock(item!!, member, omitDefaultValues)
68-
builder.addMember(member.build())
69-
}
64+
}
65+
if (varargValues != null) {
66+
for (item in varargValues) {
67+
val member = CodeBlock.builder()
68+
addValueToBlock(item!!, member, omitDefaultValues)
69+
builder.addMember(member.build())
7070
}
7171
}
7272
return builder.build()

interop/ksp/test-processor/src/main/kotlin/com/squareup/kotlinpoet/ksp/test/processor/exampleAnnotations.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ enum class AnnotationEnumValue {
8080
ONE, TWO, THREE
8181
}
8282

83-
annotation class AnnotationWithVararg(vararg val args: String)
83+
annotation class AnnotationWithVararg(val simpleArg: Int, vararg val args: String)

interop/ksp/test-processor/src/test/kotlin/com/squareup/kotlinpoet/ksp/test/processor/TestProcessorTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,10 @@ class TestProcessorTest {
636636
637637
@ExampleAnnotation
638638
@OptIn(MyOptIn::class)
639-
@AnnotationWithVararg("one", "two")
639+
@AnnotationWithVararg(0, "one", "two")
640640
interface Example
641-
""".trimIndent()
642-
)
641+
""".trimIndent(),
642+
),
643643
)
644644

645645
val result = compilation.compile()
@@ -656,12 +656,13 @@ class TestProcessorTest {
656656
657657
@OptIn(MyOptIn::class)
658658
@AnnotationWithVararg(
659+
simpleArg = 0,
659660
"one",
660661
"two",
661662
)
662663
public class TestExample
663664
664-
""".trimIndent()
665+
""".trimIndent(),
665666
)
666667
}
667668

0 commit comments

Comments
 (0)