diff --git a/stone/backends/swift_client.py b/stone/backends/swift_client.py index f580aa39..95c32087 100644 --- a/stone/backends/swift_client.py +++ b/stone/backends/swift_client.py @@ -251,15 +251,10 @@ def _generate_request_boxes(self, api): template = self._jinja_template("ObjCRequestBox.jinja") template.globals = template_globals - # don't include the default case in the generated switch statement if it's unreachable - include_default_in_switch = True - # TODO(jlocke): implement this to eliminate the unreachable code warning - output = template.render( background_compatible_routes=background_compatible_routes, background_objc_routes=background_objc_routes, - class_name=swift_class_name, - include_default_in_switch=include_default_in_switch + class_name=swift_class_name ) file_name = 'DBX{}RequestBox.swift'.format(self.args.class_name) diff --git a/stone/backends/swift_rsrc/ObjCRequestBox.jinja b/stone/backends/swift_rsrc/ObjCRequestBox.jinja index 4ca3cb32..735adae1 100644 --- a/stone/backends/swift_rsrc/ObjCRequestBox.jinja +++ b/stone/backends/swift_rsrc/ObjCRequestBox.jinja @@ -9,18 +9,16 @@ import SwiftyDropbox extension {{ class_name }} { var objc: DBXRequest { - switch self { - {% for route_args_data in background_objc_routes %} - {% set namespace = route_args_data[0] %} - {% set route = route_args_data[1] %} - {% set args_data = route_args_data[2] %} - case .{{ fmt_func_namespace(route.name, route.version, namespace.name) }}(let swift): - return {{ fmt_route_objc_class(namespace, route, args_data) }}(swift: swift) - {% endfor %} - {% if include_default_in_switch %} - default: - fatalError("For Obj-C compatibility, add this route to the Objective-C compatibility module allow-list") - {% endif %} + {% for route_args_data in background_objc_routes %} + {% set namespace = route_args_data[0] %} + {% set route = route_args_data[1] %} + {% set args_data = route_args_data[2] %} + if case .{{ fmt_func_namespace(route.name, route.version, namespace.name) }}(let swift) = self { + return {{ fmt_route_objc_class(namespace, route, args_data) }}(swift: swift) + } + {% endfor %} + else { + fatalError("For Obj-C compatibility, add this route to the Objective-C compatibility module allow-list") } } }