Skip to content

Commit

Permalink
Fix non-nullable type w/ ? warnings (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 authored Apr 18, 2024
1 parent fa0f3dc commit 02f350f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,16 @@ private class KTypeDomainConverter(
val elementIsKotlinPrimitive = isKotlinPrimitive(element)
val elementKotlinName = element.identifier.snakeToCamelCase()
when (element.typeReference.arity) {
is Arity.Required, Arity.Optional -> {
is Arity.Required -> {
KConstructorArgument(
kotlinName = elementKotlinName,
value = elementKotlinName + when {
elementIsKotlinPrimitive && useKotlinPrimitives -> ".asPrimitive()"
else -> ""
}
)
}
is Arity.Optional -> {
KConstructorArgument(
kotlinName = elementKotlinName,
value = elementKotlinName + when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ class ${t.kotlinName}(
[#if p.variadic]
if(${p.kotlinName}.any()) { ionSexpOf(ionSymbol("${p.tag}"), *${p.kotlinName}.map { it.toIonElement() }.toTypedArray()) } else { null }[#sep],[/#sep]
[#else]
[#if p.nullable]
${p.kotlinName}?.let { ionSexpOf(ionSymbol("${p.tag}"), it.toIonElement()) }[#sep],[/#sep]
[#else]
ionSexpOf(ionSymbol("${p.tag}"), ${p.kotlinName}.toIonElement())[#sep],[/#sep]
[/#if]
[/#if]
[/#list]
)
Expand Down

0 comments on commit 02f350f

Please sign in to comment.