Skip to content

Commit f91ec8e

Browse files
committed
[swift] delete redundant proto3 enum check for default value
1 parent ecf1211 commit f91ec8e

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -292,28 +292,6 @@ class SwiftGenerator private constructor(
292292
return field.type in referenceCycleIndirections.getOrDefault(type.type, emptySet())
293293
}
294294

295-
/**
296-
* Checks that every enum in a proto3 message contains a value with tag 0.
297-
*
298-
* @throws NoSuchElementException if the case doesn't exist
299-
*/
300-
@Throws(NoSuchElementException::class)
301-
private fun validateProto3DefaultsExist(type: MessageType) {
302-
// TODO: Remove when we support unknown cases
303-
if (type.syntax == PROTO_2) { return }
304-
305-
// validate each enum field
306-
type
307-
.fields
308-
.mapNotNull { schema.getType(it.type!!) as? EnumType }
309-
.forEach { enum ->
310-
// ensure that a protoDefaultedName case exists
311-
if (enum.protoDefaultedName == null) {
312-
throw NoSuchElementException("Missing a zero value for ${enum.name}")
313-
}
314-
}
315-
}
316-
317295
@OptIn(ExperimentalStdlibApi::class) // TODO move to build flag
318296
private fun generateMessage(
319297
type: MessageType,
@@ -332,8 +310,6 @@ class SwiftGenerator private constructor(
332310

333311
val typeSpecs = mutableListOf<TypeSpec>()
334312

335-
validateProto3DefaultsExist(type)
336-
337313
typeSpecs += TypeSpec.structBuilder(structType)
338314
.addModifiers(PUBLIC)
339315
.apply {

0 commit comments

Comments
 (0)