Make nullable primitives in codegen use boxed type adapters.

This commit is contained in:
Eric Cochran
2018-08-17 13:41:43 -07:00
parent 83f60d6bd7
commit 1b17423343
3 changed files with 76 additions and 0 deletions

View File

@@ -43,6 +43,16 @@ abstract class TypeRenderer {
fun render(typeName: TypeName): CodeBlock {
if (typeName.nullable) {
if (typeName == BOOLEAN.asNullable()
|| typeName == BYTE.asNullable()
|| typeName == CHAR.asNullable()
|| typeName == DOUBLE.asNullable()
|| typeName == FLOAT.asNullable()
|| typeName == INT.asNullable()
|| typeName == LONG.asNullable()
|| typeName == SHORT.asNullable()) {
return CodeBlock.of("%T::class.javaObjectType", typeName.asNonNullable())
}
return render(typeName.asNonNullable())
}