mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 23:49:21 +08:00
Merge pull request #1731 from cpovirk/bangbang
Insert `!!` to make some types in generated code non-nullable.
This commit is contained in:
@@ -58,9 +58,9 @@ public class AdapterGenerator(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
private companion object {
|
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(
|
private val DEFAULT_CONSTRUCTOR_MARKER_TYPE_BLOCK = CodeBlock.of(
|
||||||
"%M",
|
"%M!!",
|
||||||
MemberName(MOSHI_UTIL_PACKAGE, "DEFAULT_CONSTRUCTOR_MARKER"),
|
MemberName(MOSHI_UTIL_PACKAGE, "DEFAULT_CONSTRUCTOR_MARKER"),
|
||||||
)
|
)
|
||||||
private val CN_MOSHI = Moshi::class.asClassName()
|
private val CN_MOSHI = Moshi::class.asClassName()
|
||||||
|
@@ -118,7 +118,7 @@ internal fun TypeName.asTypeBlock(): CodeBlock {
|
|||||||
// Remove nullable but keep the java object type
|
// Remove nullable but keep the java object type
|
||||||
CodeBlock.of("%T::class.javaObjectType", copy(nullable = false))
|
CodeBlock.of("%T::class.javaObjectType", copy(nullable = false))
|
||||||
} else {
|
} 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")
|
UNIT, Void::class.asTypeName(), NOTHING -> throw IllegalStateException("Parameter with void, Unit, or Nothing type is illegal")
|
||||||
|
Reference in New Issue
Block a user