Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Number instead of Int for choice arguments #220

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal fun resolveArgumentType(tokenTypes: List<TokenType>): KClass<*>? =
when (resolveCompatibleTokenType(tokenTypes)) {
null -> null
None -> Any::class
Number, Plural, SpellOut -> KotlinNumber::class
Choice, Number, Plural, SpellOut -> KotlinNumber::class
Date -> LocalDate::class
Time -> LocalTime::class
TimeWithOffset -> OffsetTime::class
Expand All @@ -65,7 +65,7 @@ internal fun resolveArgumentType(tokenTypes: List<TokenType>): KClass<*>? =
DateTimeWithZone -> ZonedDateTime::class
Offset -> ZoneOffset::class
Duration -> KotlinDuration::class
Choice, Ordinal, SelectOrdinal -> Int::class
Ordinal, SelectOrdinal -> Int::class
Select -> String::class
NoArg -> Nothing::class
}
Expand Down Expand Up @@ -109,11 +109,11 @@ private val compatibleTokenTypes: Map<TokenType, List<TokenType>> = mapOf(
DateTimeWithZone to emptyList(),
Offset to listOf(TimeWithOffset, DateTimeWithOffset, DateTimeWithZone),
SpellOut to listOf(Choice, Number, Ordinal, Plural, SelectOrdinal),
Ordinal to listOf(Choice, SelectOrdinal),
Ordinal to listOf(SelectOrdinal),
Duration to emptyList(),
Choice to listOf(Ordinal, SelectOrdinal),
Choice to listOf(Number, Ordinal, Plural, SelectOrdinal, SpellOut),
Plural to listOf(Choice, Number, Ordinal, SelectOrdinal, SpellOut),
Select to emptyList(),
SelectOrdinal to listOf(Choice, Ordinal),
SelectOrdinal to listOf(Ordinal),
NoArg to emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class ArgumentTypeResolverTest {
fun resolveNumber() {
Number.assertArgumentTypes { other ->
when (other) {
None, Number, Plural, SpellOut -> KotlinNumber::class
Choice, Ordinal, SelectOrdinal -> Int::class
None, Choice, Number, Plural, SpellOut -> KotlinNumber::class
Ordinal, SelectOrdinal -> Int::class
else -> null
}
}
Expand Down Expand Up @@ -158,8 +158,8 @@ class ArgumentTypeResolverTest {
fun resolveSpellOut() {
SpellOut.assertArgumentTypes { other ->
when (other) {
None, Number, Plural, SpellOut -> KotlinNumber::class
Choice, Ordinal, SelectOrdinal -> Int::class
None, Choice, Number, Plural, SpellOut -> KotlinNumber::class
Ordinal, SelectOrdinal -> Int::class
else -> null
}
}
Expand Down Expand Up @@ -189,7 +189,8 @@ class ArgumentTypeResolverTest {
fun resolveChoice() {
Choice.assertArgumentTypes { other ->
when (other) {
None, Choice, Number, Ordinal, Plural, SelectOrdinal, SpellOut -> Int::class
None, Choice, Number, Plural, SpellOut -> KotlinNumber::class
Ordinal, SelectOrdinal -> Int::class
else -> null
}
}
Expand All @@ -199,8 +200,8 @@ class ArgumentTypeResolverTest {
fun resolvePlural() {
Plural.assertArgumentTypes { other ->
when (other) {
None, Number, Plural, SpellOut -> KotlinNumber::class
Choice, Ordinal, SelectOrdinal -> Int::class
None, Choice, Number, Plural, SpellOut -> KotlinNumber::class
Ordinal, SelectOrdinal -> Int::class
else -> null
}
}
Expand Down