Skip to content

Commit be203d7

Browse files
committed
fix: optional issue with enums in android
1 parent 8b5b334 commit be203d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/SDK/Language/Kotlin.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,14 @@ protected function getPropertyAssignment(array $property, array $spec): string
593593
$enumClass = $this->toPascalCase($enumName);
594594
$nullCheck = $property['required'] ? '!!' : ' ?: null';
595595

596+
if ($property['required']) {
597+
return "$enumClass.values().find { " .
598+
"it.value == $mapKey as String " .
599+
"}$nullCheck";
600+
}
601+
596602
return "$enumClass.values().find { " .
597-
"it.value == $mapKey as String " .
603+
"it.value == ($mapKey as? String) " .
598604
"}$nullCheck";
599605
}
600606

0 commit comments

Comments
 (0)