@@ -336,6 +336,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
336
336
private llvm::TrailingObjects<Constraint,
337
337
TypeVariableType *,
338
338
ConstraintFix *,
339
+ DeclContext *,
339
340
ContextualTypeInfo,
340
341
OverloadChoice> {
341
342
friend TrailingObjects;
@@ -354,6 +355,9 @@ class Constraint final : public llvm::ilist_node<Constraint>,
354
355
// / Whether we have a tail-allocated fix.
355
356
unsigned HasFix : 1 ;
356
357
358
+ // / Whether we have a tail-allocated DeclContext.
359
+ unsigned HasDeclContext : 1 ;
360
+
357
361
// / Whether the \c Restriction field is valid.
358
362
unsigned HasRestriction : 1 ;
359
363
@@ -392,7 +396,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
392
396
// / node is unused.
393
397
unsigned isDiscarded : 1 ;
394
398
395
- // 23 bits remaining
399
+ // 22 bits remaining
396
400
397
401
union {
398
402
struct {
@@ -425,20 +429,14 @@ class Constraint final : public llvm::ilist_node<Constraint>,
425
429
// / Used for ValueWitness constraints.
426
430
ValueDecl *Ref;
427
431
} Member;
428
-
429
- // / The DC in which the use appears.
430
- DeclContext *UseDC;
431
432
} Member;
432
433
433
434
// / The set of constraints for a disjunction.
434
435
ArrayRef<Constraint *> Nested;
435
436
436
437
struct {
437
- // / The first type
438
+ // / The first type.
438
439
Type First;
439
-
440
- // / The DC in which the use appears.
441
- DeclContext *UseDC;
442
440
} Overload;
443
441
444
442
struct {
@@ -454,8 +452,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
454
452
// / The type being called, primarily a function type, but could
455
453
// / be a metatype, a tuple or a nominal type.
456
454
Type Callee;
457
- // / The declaration context in which the application appears.
458
- DeclContext *UseDC;
459
455
} Apply;
460
456
};
461
457
@@ -531,6 +527,10 @@ class Constraint final : public llvm::ilist_node<Constraint>,
531
527
return HasFix ? 1 : 0 ;
532
528
}
533
529
530
+ size_t numTrailingObjects (OverloadToken<DeclContext *>) const {
531
+ return HasDeclContext ? 1 : 0 ;
532
+ }
533
+
534
534
size_t numTrailingObjects (OverloadToken<ContextualTypeInfo>) const {
535
535
return Kind == ConstraintKind::SyntacticElement ? 1 : 0 ;
536
536
}
@@ -876,20 +876,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
876
876
return *getTrailingObjects<OverloadChoice>();
877
877
}
878
878
879
- // / Retrieve the DC in which the overload was used.
880
- DeclContext *getOverloadUseDC () const {
881
- assert (Kind == ConstraintKind::BindOverload);
882
- return Overload.UseDC ;
883
- }
884
-
885
- // / Retrieve the DC in which the member was used.
886
- DeclContext *getMemberUseDC () const {
887
- assert (Kind == ConstraintKind::ValueMember ||
888
- Kind == ConstraintKind::UnresolvedValueMember ||
889
- Kind == ConstraintKind::ValueWitness);
890
- return Member.UseDC ;
891
- }
892
-
893
879
FunctionType *getAppliedFunctionType () const {
894
880
assert (Kind == ConstraintKind::ApplicableFunction);
895
881
return Apply.AppliedFn ;
@@ -900,11 +886,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
900
886
return Apply.Callee ;
901
887
}
902
888
903
- DeclContext *getApplicationDC () const {
904
- assert (Kind == ConstraintKind::ApplicableFunction);
905
- return Apply.UseDC ;
906
- }
907
-
908
889
ASTNode getSyntacticElement () const {
909
890
assert (Kind == ConstraintKind::SyntacticElement);
910
891
return SyntacticElement.Element ;
@@ -920,6 +901,12 @@ class Constraint final : public llvm::ilist_node<Constraint>,
920
901
return isDiscarded;
921
902
}
922
903
904
+ // / Retrieve the DC in which the overload was used.
905
+ DeclContext *getDeclContext () const {
906
+ assert (HasDeclContext);
907
+ return *getTrailingObjects<DeclContext *>();
908
+ }
909
+
923
910
// / For an applicable function constraint, retrieve the trailing closure
924
911
// / matching rule.
925
912
std::optional<TrailingClosureMatching> getTrailingClosureMatching () const ;
0 commit comments