fastlane/lib/fastlane/swift_fastlane_function.rb in fastlane-2.149.1 vs fastlane/lib/fastlane/swift_fastlane_function.rb in fastlane-2.150.0.rc1

- old
+ new

@@ -96,19 +96,23 @@ elsif type_override == Boolean return "Bool" elsif type_override == Float return "Float" elsif type_override == :string_callback - return "((String) -> Void)" + # David Hart: + # It doesn't make sense to add escaping annotations to optional closures because they aren't function types: + # they are basically an enum (Optional) containing a function, the same way you would store a closure in any type: + # it's implicitly escaping because it's owned by another type. + return "((String) -> Void)?" else return default_type end end def override_default_value_if_not_correct_type(param_name: nil, param_type: nil, default_value: nil) return "[]" if param_type == "[String]" && default_value == "" - return "{_ in }" if param_type == "((String) -> Void)" + return "nil" if param_type == "((String) -> Void)?" return default_value end def get_type(param: nil, default_value: nil, optional: nil, param_type_override: nil, is_string: true) @@ -119,11 +123,11 @@ # defaulting type to Any if is_string is false so users are allowed to input all allowed types type ||= is_string ? "String" : "Any" optional_specifier = "" # if we are optional and don't have a default value, we'll need to use ? - optional_specifier = "?" if (optional && default_value.nil?) && type != "((String) -> Void)" + optional_specifier = "?" if (optional && default_value.nil?) && type != "((String) -> Void)?" # If we have a default value of true or false, we can infer it is a Bool if default_value.class == FalseClass type = "Bool" elsif default_value.class == TrueClass @@ -160,10 +164,10 @@ unless default_value.nil? if type == "[String : Any]" # we can't handle default values for Hashes, yet # see method swift_default_implementations for similar behavior default_value = "[:]" - elsif type != "Bool" && type != "[String]" && type != "Int" && type != "((String) -> Void)" && type != "Float" && type != "Double" + elsif type != "Bool" && type != "[String]" && type != "Int" && type != "@escaping ((String) -> Void)" && type != "Float" && type != "Double" default_value = "\"#{default_value}\"" end end # if we don't have a default value, but the param is optional, set a default value in Swift to be nil