fastlane/lib/fastlane/swift_fastlane_function.rb in fastlane-2.148.1 vs fastlane/lib/fastlane/swift_fastlane_function.rb in fastlane-2.149.0
- old
+ new
@@ -93,10 +93,12 @@
return "[String : Any]"
elsif type_override == Integer
return "Int"
elsif type_override == Boolean
return "Bool"
+ elsif type_override == Float
+ return "Float"
elsif type_override == :string_callback
return "((String) -> Void)"
else
return default_type
end
@@ -128,12 +130,23 @@
type = "Bool"
elsif default_value.kind_of?(Array)
type = "[String]"
elsif default_value.kind_of?(Hash)
type = "[String : Any]"
+ # Altough we can have a default value of Integer type, if param_type_override overridden that value, respect it.
elsif default_value.kind_of?(Integer)
- type = "Int"
+ if type == "Double" || type == "Float"
+ begin
+ # If we're not able to instantiate
+ _ = BigDecimal(default_value)
+ rescue
+ # We set it as a Int
+ type = "Int"
+ end
+ else
+ type = "Int"
+ end
end
return "#{type}#{optional_specifier}"
end
def parameters
@@ -147,10 +160,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)"
+ elsif type != "Bool" && type != "[String]" && type != "Int" && type != "((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