Merge pull request #1731 from cpovirk/bangbang

Insert `!!` to make some types in generated code non-nullable.
This commit is contained in:
Jake Wharton
2023-08-30 13:33:24 -04:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -58,9 +58,9 @@ public class AdapterGenerator(
) {
private companion object {
private val INT_TYPE_BLOCK = CodeBlock.of("%T::class.javaPrimitiveType", INT)
private val INT_TYPE_BLOCK = CodeBlock.of("%T::class.javaPrimitiveType!!", INT)
private val DEFAULT_CONSTRUCTOR_MARKER_TYPE_BLOCK = CodeBlock.of(
"%M",
"%M!!",
MemberName(MOSHI_UTIL_PACKAGE, "DEFAULT_CONSTRUCTOR_MARKER"),
)
private val CN_MOSHI = Moshi::class.asClassName()

View File

@@ -118,7 +118,7 @@ internal fun TypeName.asTypeBlock(): CodeBlock {
// Remove nullable but keep the java object type
CodeBlock.of("%T::class.javaObjectType", copy(nullable = false))
} else {
CodeBlock.of("%T::class.javaPrimitiveType", this)
CodeBlock.of("%T::class.javaPrimitiveType!!", this)
}
}
UNIT, Void::class.asTypeName(), NOTHING -> throw IllegalStateException("Parameter with void, Unit, or Nothing type is illegal")