Skip to content

Commit

Permalink
Forward oneof properties to backing storage
Browse files Browse the repository at this point in the history
When we have a storage type present.
  • Loading branch information
JakeWharton committed Aug 19, 2020
1 parent ea2d9f1 commit 72c5e30
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,13 @@ class SwiftGenerator private constructor(
val enumName = oneOfEnumNames.getValue(oneOf)

addProperty(PropertySpec.varBuilder(oneOf.name, enumName.makeOptional(), PUBLIC)
.getter(FunctionSpec.getterBuilder()
.addStatement("%N.%N", storageName, oneOf.name)
.build())
.setter(FunctionSpec.setterBuilder()
.addStatement("copyStorage()")
.addStatement("%N.%N = newValue", storageName, oneOf.name)
.build())
.apply {
if (oneOf.documentation.isNotBlank()) {
addKdoc("%N\n", oneOf.documentation.sanitizeDoc())
Expand Down

0 comments on commit 72c5e30

Please sign in to comment.