mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
Check against non-nullable known primitives when rendering class… (#993)
* Check against non-nullable known primitives when rendering class blocks `Int?` will not equal `Int` in KotlinPoet, so this was always falling through to the default `::class.java` code. Resolves #991 * Nix comment * Flesh out test to include all primitives
This commit is contained in:
@@ -71,7 +71,9 @@ internal fun TypeName.asTypeBlock(): CodeBlock {
|
||||
return bound.asTypeBlock()
|
||||
}
|
||||
is ClassName -> {
|
||||
return when (this) {
|
||||
// Check against the non-nullable version for equality, but we'll keep the nullability in
|
||||
// consideration when creating the CodeBlock if needed.
|
||||
return when (copy(nullable = false)) {
|
||||
BOOLEAN, CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE -> {
|
||||
if (isNullable) {
|
||||
// Remove nullable but keep the java object type
|
||||
|
Reference in New Issue
Block a user