Skip to content

fix(FlagEvaluation): cast value instead of self in getTyped - #271

Open
reginaldalfret wants to merge 1 commit into
spotify:mainfrom
reginaldalfret:spotify/issue-252-cast-value-instead-of-self
Open

reginaldalfret wants to merge 1 commit into
spotify:mainfrom
reginaldalfret:spotify/issue-252-cast-value-instead-of-self

Conversation

@reginaldalfret

Copy link
Copy Markdown

Summary

Fixes a type check in FlagResolution.getTyped(value:defaultValue:) where self was being cast to T instead of the value parameter.

Problem

In Sources/Confidence/FlagEvaluation.swift, line 229 checked if let value = self as? T. Because self is a FlagResolution struct rather than a value type, this conditional cast could never succeed for any requested flag type (String, Int, Double, Bool), causing execution to fall through to the switch statement instead of executing the early return fast-path.

Solution

Update if let value = self as? T to if let value = value as? T to properly evaluate the value parameter.

Testing

  • Verified source diff and compilation logic.

Fixes #252

Fixes spotify#252

Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FlagResolution.getTyped casts self instead of value

1 participant