From da3b0b5e21c4a57cdabb193768f8c10a1531efb4 Mon Sep 17 00:00:00 2001 From: David Richardson Date: Wed, 8 Jul 2026 18:28:49 -0600 Subject: [PATCH] fix(Foundation): implement valueForKey: for CPSet KVC compliance Resolves testKVCCountSetOperators failure in CPSetTest. The previous implementation lacked an override for valueForKey:, causing the runtime to fall back to the default CPObject behavior, which failed to recognize KVC collection operators (e.g., @count). Delegating valueForKey: to valueForKeyPath: ensures that CPSet correctly routes KVC operations through the existing collection operator logic. --- Foundation/CPSet/CPMutableSet.j | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Foundation/CPSet/CPMutableSet.j b/Foundation/CPSet/CPMutableSet.j index e7c7a602d..6864e6cbe 100644 --- a/Foundation/CPSet/CPMutableSet.j +++ b/Foundation/CPSet/CPMutableSet.j @@ -226,6 +226,14 @@ } } +- (id)valueForKey:(CPString)aKey +{ + // If the key starts with @, it is an operator path. + // If not, it is a property path that we want applied to all members. + // In either case, valueForKeyPath: handles both scenarios correctly. + return [self valueForKeyPath:aKey]; +} + - (void)setValue:(id)aValue forKey:(CPString)aKey { var containedObject,