Skip to content

Commit

Permalink
fix: handle Int32 and Int64 in defaultValue evaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklasl committed Jul 10, 2024
1 parent 409974d commit 8782f72
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Sources/Confidence/FlagEvaluation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extension FlagResolution {
}
}

// swiftlint:disable:next cyclomatic_complexity
private func getTyped<T>(value: ConfidenceValue) -> T? {
if let value = self as? T {
return value
Expand All @@ -97,7 +98,16 @@ extension FlagResolution {
case .string:
return value.asString() as? T
case .integer:
return value.asInteger() as? T
if let intValue = value.asInteger() as? T {
return intValue
}
if T.self == Int32.self, let intValue = value.asInteger() {
return Int32(intValue) as? T
}
if T.self == Int64.self, let intValue = value.asInteger() {
return Int64(intValue) as? T
}
return nil
case .double:
return value.asDouble() as? T
case .date:
Expand Down

0 comments on commit 8782f72

Please sign in to comment.