@@ -152,12 +152,12 @@ class ConstraintLocator : public llvm::FoldingSetNode {
152
152
case AutoclosureResult:
153
153
case Requirement:
154
154
case Witness:
155
- case OpenedGeneric:
156
155
case ImplicitlyUnwrappedDisjunctionChoice:
157
156
case DynamicLookupResult:
158
157
case ContextualType:
159
158
return 0 ;
160
159
160
+ case OpenedGeneric:
161
161
case GenericArgument:
162
162
case NamedTupleElement:
163
163
case TupleElement:
@@ -236,6 +236,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
236
236
StoredGenericParameter,
237
237
StoredRequirement,
238
238
StoredWitness,
239
+ StoredGenericSignature,
239
240
StoredKindAndValue
240
241
};
241
242
@@ -249,11 +250,11 @@ class ConstraintLocator : public llvm::FoldingSetNode {
249
250
// / kind. Use \c encodeStorage and \c decodeStorage to work with this value.
250
251
// /
251
252
// / \note The "storage kind" is stored in the \c storedKind field.
252
- uint64_t storage : 62 ;
253
+ uint64_t storage : 61 ;
253
254
254
255
// / The kind of value stored in \c storage. Valid values are those
255
256
// / from the StoredKind enum.
256
- uint64_t storedKind : 2 ;
257
+ uint64_t storedKind : 3 ;
257
258
258
259
// / Encode a path element kind and a value into the storage format.
259
260
static uint64_t encodeStorage (PathElementKind kind, unsigned value) {
@@ -281,6 +282,10 @@ class ConstraintLocator : public llvm::FoldingSetNode {
281
282
" Path element kind does not require 2 values" );
282
283
}
283
284
285
+ PathElement (GenericSignature *sig)
286
+ : storage((reinterpret_cast <uintptr_t >(sig) >> 3)),
287
+ storedKind(StoredGenericSignature) {}
288
+
284
289
friend class ConstraintLocator ;
285
290
286
291
public:
@@ -292,7 +297,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
292
297
}
293
298
294
299
PathElement (GenericTypeParamType *type)
295
- : storage((reinterpret_cast <uintptr_t >(type) >> 2 )),
300
+ : storage((reinterpret_cast <uintptr_t >(type) >> 3 )),
296
301
storedKind(StoredGenericParameter)
297
302
{
298
303
static_assert (alignof (GenericTypeParamType) >= 4 ,
@@ -301,7 +306,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
301
306
}
302
307
303
308
PathElement (PathElementKind kind, ValueDecl *decl)
304
- : storage((reinterpret_cast <uintptr_t >(decl) >> 2 )),
309
+ : storage((reinterpret_cast <uintptr_t >(decl) >> 3 )),
305
310
storedKind(kind == Witness ? StoredWitness : StoredRequirement)
306
311
{
307
312
assert ((kind == Witness || kind == Requirement) &&
@@ -339,6 +344,10 @@ class ConstraintLocator : public llvm::FoldingSetNode {
339
344
return PathElement (KeyPathComponent, position);
340
345
}
341
346
347
+ static PathElement getOpenedGeneric (GenericSignature *sig) {
348
+ return PathElement (sig);
349
+ }
350
+
342
351
// / Get a path element for a conditional requirement.
343
352
static PathElement
344
353
getConditionalRequirementComponent (unsigned index, RequirementKind kind) {
@@ -364,6 +373,9 @@ class ConstraintLocator : public llvm::FoldingSetNode {
364
373
case StoredWitness:
365
374
return Witness;
366
375
376
+ case StoredGenericSignature:
377
+ return OpenedGeneric;
378
+
367
379
case StoredKindAndValue:
368
380
return decodeStorage (storage).first ;
369
381
}
@@ -399,22 +411,28 @@ class ConstraintLocator : public llvm::FoldingSetNode {
399
411
// / Retrieve the declaration for a witness path element.
400
412
ValueDecl *getWitness () const {
401
413
assert (getKind () == Witness && " Is not a witness" );
402
- return reinterpret_cast <ValueDecl *>(storage << 2 );
414
+ return reinterpret_cast <ValueDecl *>(storage << 3 );
403
415
}
404
416
405
417
// / Retrieve the actual archetype for a generic parameter path
406
418
// / element.
407
419
GenericTypeParamType *getGenericParameter () const {
408
420
assert (getKind () == GenericParameter &&
409
421
" Not a generic parameter path element" );
410
- return reinterpret_cast <GenericTypeParamType *>(storage << 2 );
422
+ return reinterpret_cast <GenericTypeParamType *>(storage << 3 );
411
423
}
412
424
413
425
// / Retrieve the declaration for a requirement path element.
414
426
ValueDecl *getRequirement () const {
415
427
assert ((static_cast <StoredKind>(storedKind) == StoredRequirement) &&
416
428
" Is not a requirement" );
417
- return reinterpret_cast <ValueDecl *>(storage << 2 );
429
+ return reinterpret_cast <ValueDecl *>(storage << 3 );
430
+ }
431
+
432
+ GenericSignature *getGenericSignature () const {
433
+ assert ((static_cast <StoredKind>(storedKind) == StoredGenericSignature) &&
434
+ " Is not an opened generic" );
435
+ return reinterpret_cast <GenericSignature *>(storage << 3 );
418
436
}
419
437
420
438
// / Return the summary flags for this particular element.
0 commit comments