Skip to content

Conversation

@jmschonfeld
Copy link
Contributor

This predicate code validates that the provided KeyPath only contains a single component. Originally, for stored property components, this code checked the payload value to see if it was an inline offset or the out-of-line sentinel defined by the KeyPath ABI documentation to determine if the buffer size matches the expected single component buffer size. However, this document was determined to be incorrect and there are actually multiple sentinel values defined. #216 attempted to correct this by switching to MemoryLayout.offset(of:) to check for a single stored property component. However, MemoryLayout.offset(of:) is also not an appropriate way to check for a single stored property component as not all single stored components have offsets (for example, a property in a final class).

This changes the implementation back to the original style of check before #216 but with a corrected check for whether the offset is stored inline (based on the existence of multiple sentinel values and the max inline offset defined here). This fixes the regression caused for final class properties while still ensuring that we respect other sentinel values as well.

Resolves #1173

@jmschonfeld jmschonfeld requested a review from Azoy August 19, 2025 22:56
@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit 92b1b02 into swiftlang:main Aug 20, 2025
19 checks passed
@jmschonfeld jmschonfeld deleted the predicate-final-class-kp branch August 20, 2025 19:20
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.

Bug: #Predicate macro incorrectly fails for ‘final’ classes

2 participants