Skip to content

AnyKeyPath._validateForPredicateUsage should validate the keypath contains no arguments #1482

@jmschonfeld

Description

@jmschonfeld

KeyPaths with computed components can contain arguments if the component is a subscript component. PredicateExpressions.KeyPath does not support subscript keypaths (the subscript operator is used instead) and so _validateForPredicateUsage should validate that a computed component does not contain arguments. However, arguments are also used to pass generic constraints (in the case where a keypath is rooted on a generic type, for example). When validating arguments don't exist, we need to ensure that we do allow cases where all arguments are generic arguments rather than concrete values passed to a subscript.

This distinction should be able to be determined by examining the witness table pointer in the computed component. For KeyPaths with actual argument values for subscripts, the witness table pointer will point to a concrete witness table for the value(s). However, if only generic arguments are used, the witness table pointer will be the global swift_keyPathGenericWitnessTable. We should allow arguments iff. the witness table pointer is NULL or is a pointer to swift_keyPathGenericWitnessTable.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions