@@ -127,6 +127,8 @@ class ConstraintLocator : public llvm::FoldingSetNode {
127
127
ContextualType,
128
128
// / The missing argument synthesized by the solver.
129
129
SynthesizedArgument,
130
+ // / The member looked up via keypath based dynamic lookup.
131
+ KeyPathDynamicMember,
130
132
};
131
133
132
134
// / Determine the number of numeric values used for the given path
@@ -165,6 +167,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
165
167
case TupleElement:
166
168
case KeyPathComponent:
167
169
case SynthesizedArgument:
170
+ case KeyPathDynamicMember:
168
171
return 1 ;
169
172
170
173
case TypeParameterRequirement:
@@ -221,6 +224,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
221
224
case DynamicLookupResult:
222
225
case ContextualType:
223
226
case SynthesizedArgument:
227
+ case KeyPathDynamicMember:
224
228
return 0 ;
225
229
226
230
case FunctionArgument:
@@ -241,6 +245,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
241
245
StoredRequirement,
242
246
StoredWitness,
243
247
StoredGenericSignature,
248
+ StoredKeyPathDynamicMemberBase,
244
249
StoredKindAndValue
245
250
};
246
251
@@ -290,6 +295,10 @@ class ConstraintLocator : public llvm::FoldingSetNode {
290
295
: storage((reinterpret_cast <uintptr_t >(sig) >> 3)),
291
296
storedKind(StoredGenericSignature) {}
292
297
298
+ PathElement (const NominalTypeDecl *keyPath)
299
+ : storage((reinterpret_cast <uintptr_t >(keyPath) >> 3)),
300
+ storedKind(StoredKeyPathDynamicMemberBase) {}
301
+
293
302
friend class ConstraintLocator ;
294
303
295
304
public:
@@ -369,6 +378,10 @@ class ConstraintLocator : public llvm::FoldingSetNode {
369
378
return PathElement (SynthesizedArgument, position);
370
379
}
371
380
381
+ static PathElement getKeyPathDynamicMember (const NominalTypeDecl *base) {
382
+ return PathElement (base);
383
+ }
384
+
372
385
// / Retrieve the kind of path element.
373
386
PathElementKind getKind () const {
374
387
switch (static_cast <StoredKind>(storedKind)) {
@@ -384,6 +397,9 @@ class ConstraintLocator : public llvm::FoldingSetNode {
384
397
case StoredGenericSignature:
385
398
return OpenedGeneric;
386
399
400
+ case StoredKeyPathDynamicMemberBase:
401
+ return KeyPathDynamicMember;
402
+
387
403
case StoredKindAndValue:
388
404
return decodeStorage (storage).first ;
389
405
}
@@ -443,6 +459,13 @@ class ConstraintLocator : public llvm::FoldingSetNode {
443
459
return reinterpret_cast <GenericSignature *>(storage << 3 );
444
460
}
445
461
462
+ NominalTypeDecl *getKeyPath () const {
463
+ assert ((static_cast <StoredKind>(storedKind) ==
464
+ StoredKeyPathDynamicMemberBase) &&
465
+ " Is not a keypath dynamic member" );
466
+ return reinterpret_cast <NominalTypeDecl *>(storage << 3 );
467
+ }
468
+
446
469
// / Return the summary flags for this particular element.
447
470
unsigned getNewSummaryFlags () const {
448
471
return getSummaryFlagsForPathElement (getKind ());
@@ -459,6 +482,10 @@ class ConstraintLocator : public llvm::FoldingSetNode {
459
482
bool isSynthesizedArgument () const {
460
483
return getKind () == PathElementKind::SynthesizedArgument;
461
484
}
485
+
486
+ bool isKeyPathDynamicMember () const {
487
+ return getKind () == PathElementKind::KeyPathDynamicMember;
488
+ }
462
489
};
463
490
464
491
// / Return the summary flags for an entire path.
0 commit comments