Skip to content

Commit 704d358

Browse files
authored
chore: upgrade crt-kotlin to 0.6.2; fix allStringsEqual waiter generation (#669)
* chore: upgrade crt-kotlin to 0.6.2 * fix(codegen): generate allStringsEqual acceptor compatible with kotlin 1.7
1 parent 20d2827 commit 704d358

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ kotlinLoggingVersion=2.1.21
4646
slf4jVersion=1.7.36
4747

4848
# crt
49-
crtKotlinVersion=0.6.0
49+
crtKotlinVersion=0.6.2

smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/waiters/AcceptorGenerator.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ private fun KotlinWriter.renderPathAcceptor(directive: String, includeInput: Boo
8383
PathComparator.STRING_EQUALS -> "$actual?.toString() == ${expected.dq()}"
8484
PathComparator.BOOLEAN_EQUALS -> "$actual == ${expected.toBoolean()}"
8585
PathComparator.ANY_STRING_EQUALS -> "$actual?.any { it?.toString() == ${expected.dq()} } ?: false"
86+
87+
// NOTE: the size > 0 check is necessary because the waiter spec says that `allStringEquals` requires
88+
// at least one value unlike Kotlin's `all` which returns true if the collection is empty
8689
PathComparator.ALL_STRING_EQUALS ->
87-
"($actual?.size ?: 0) > 1 && $actual?.all { it?.toString() == ${expected.dq()} }"
90+
"$actual != null && $actual.size > 0 && $actual.all { it?.toString() == ${expected.dq()} }"
8891
}
8992
write(comparison)
9093
}

smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/waiters/AcceptorGeneratorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AcceptorGeneratorTest {
7777
InputOutputAcceptor(RetryDirective.TerminateAndSucceed) {
7878
val output = it?.output
7979
val tags = output?.tags
80-
(tags?.size ?: 0) > 1 && tags?.all { it?.toString() == "foo" }
80+
tags != null && tags.size > 0 && tags.all { it?.toString() == "foo" }
8181
},
8282
InputOutputAcceptor(RetryDirective.TerminateAndSucceed) {
8383
val output = it?.output

0 commit comments

Comments
 (0)