1616// along with this program. If not, see http://www.gnu.org/licenses/.
1717//
1818
19+ // This stencil file is copied from https://github.com/krzysztofzablocki/Sourcery (commit 645c16e9bf3cff2d268fb1a161ff88b0ba1a54bc) and slightly adjusted.
20+
1921// swiftlint:disable line_length
2022// swiftlint:disable variable_name
2123
@@ -252,9 +254,11 @@ public import {{ import }}
252254{% macro existentialVariableTypeName typeName isNotAllowedToBeImplicitlyUnwrappedOptional -%}
253255 {%- if typeName|contains:"<" and typeName|contains:">" -%}
254256 {{ typeName }}
257+ {%- elif typeName|contains:"[" and typeName|contains:"]" -%}
258+ {{ typeName }}
255259 {%- elif typeName|contains:"any " and typeName|contains:"!" -%}
256260 {{ typeName | replace:"any","(any" | replace:"!",")!" }}
257- {%- elif typeName|contains:"any " and typeName.isOptional -%}
261+ {%- elif typeName|contains:"any " and typeName.isOptional and not typeName|contains:"(" -%}
258262 {{ typeName | replace:"any","(any" | replace:"?",")?" }}
259263 {%- elif typeName|contains:"any " and typeName.isClosure and typeName|contains:"?" -%}
260264 ({{ typeName | replace:"any","(any" | replace:"?",")?" }})
@@ -281,7 +285,9 @@ public import {{ import }}
281285 {{ typeName | replace:"inout ","" }}
282286 {%- endif -%}
283287 {% endset %}
284- {%- if typeName|contains:"any " and typeName|contains:"!" -%}
288+ {%- if typeName|contains:"[" and typeName|contains:"]" -%}
289+ {{ name }}
290+ {%- elif typeName|contains:"any " and typeName|contains:"!" -%}
285291 {{ name | replace:"any","(any" | replace:"!",")?" }}
286292 {%- elif typeName|contains:"any " and typeName.isOptional and typeName.isClosure -%}
287293 ({{ typeName.unwrappedTypeName| replace:"inout ","" | replace:"any","(any" | replace:"?",")?" }})?
@@ -314,7 +320,9 @@ public import {{ import }}
314320 {{ typeName | replace:"inout ","" }}
315321 {%- endif -%}
316322 {% endset %}
317- {%- if typeName|contains:"any " and typeName|contains:"!" -%}
323+ {%- if typeName|contains:"[" and typeName|contains:"]" -%}
324+ {{ name }}
325+ {%- elif typeName|contains:"any " and typeName|contains:"!" -%}
318326 {{ name | replace:"any","(any" | replace:"!",")?" }}
319327 {%- elif typeName|contains:"any " and typeName.isOptional and typeName.isClosure -%}
320328 ({{ typeName.unwrappedTypeName| replace:"inout ","" | replace:"any","(any" | replace:"?",")?" }})?
@@ -335,7 +343,9 @@ public import {{ import }}
335343 {%- endif -%}
336344{%- endmacro %}
337345{% macro existentialParameterTypeName typeName isVariadic -%}
338- {%- if typeName|contains:"any " and typeName|contains:"?," and typeName|contains:">?" -%}
346+ {%- if typeName|contains:"[" and typeName|contains:"]" -%}
347+ {{ typeName }}
348+ {%- elif typeName|contains:"any " and typeName|contains:"?," and typeName|contains:">?" -%}
339349 {{ typeName | replace:"any","(any" | replace:"?,",")?," }}
340350 {%- elif typeName|contains:"any " and typeName|contains:"!" -%}
341351 {{ typeName | replace:"any","(any" | replace:"!",")!" }}
0 commit comments