@@ -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
+ ContextualTypeInfo,
339
340
OverloadChoice> {
340
341
friend TrailingObjects;
341
342
@@ -345,7 +346,12 @@ class Constraint final : public llvm::ilist_node<Constraint>,
345
346
// / The kind of restriction placed on this constraint.
346
347
ConversionRestrictionKind Restriction : 8 ;
347
348
348
- // / Whether we have a fix.
349
+ // / The number of type variables referenced by this constraint.
350
+ // /
351
+ // / The type variables themselves are tail-allocated.
352
+ unsigned NumTypeVariables : 11 ;
353
+
354
+ // / Whether we have a tail-allocated fix.
349
355
unsigned HasFix : 1 ;
350
356
351
357
// / Whether the \c Restriction field is valid.
@@ -375,14 +381,19 @@ class Constraint final : public llvm::ilist_node<Constraint>,
375
381
// / the rest of the constraint system. Currently only applies to conjunctions.
376
382
unsigned IsIsolated : 1 ;
377
383
378
- // / The number of type variables referenced by this constraint.
379
- // /
380
- // / The type variables themselves are tail-allocated.
381
- unsigned NumTypeVariables : 11 ;
382
-
383
384
// / The kind of function reference, for member references.
384
385
unsigned TheFunctionRefInfo : 3 ;
385
386
387
+ // / The trailing closure matching for an applicable function constraint,
388
+ // / if any. 0 = None, 1 = Forward, 2 = Backward.
389
+ unsigned trailingClosureMatching : 2 ;
390
+
391
+ // / For a SyntacticElement constraint, identify whether the result of this
392
+ // / node is unused.
393
+ unsigned isDiscarded : 1 ;
394
+
395
+ // 23 bits remaining
396
+
386
397
union {
387
398
struct {
388
399
// / The first type.
@@ -433,10 +444,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
433
444
struct {
434
445
// / The node itself.
435
446
ASTNode Element;
436
- // / Contextual information associated with the element (if any).
437
- ContextualTypeInfo Context;
438
- // / Identifies whether result of this node is unused.
439
- bool IsDiscarded;
440
447
} SyntacticElement;
441
448
442
449
struct {
@@ -447,9 +454,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
447
454
// / The type being called, primarily a function type, but could
448
455
// / be a metatype, a tuple or a nominal type.
449
456
Type Callee;
450
- // / The trailing closure matching for an applicable function constraint,
451
- // / if any. 0 = None, 1 = Forward, 2 = Backward.
452
- unsigned TrailingClosureMatching : 2 ;
453
457
// / The declaration context in which the application appears.
454
458
DeclContext *UseDC;
455
459
} Apply;
@@ -527,6 +531,10 @@ class Constraint final : public llvm::ilist_node<Constraint>,
527
531
return HasFix ? 1 : 0 ;
528
532
}
529
533
534
+ size_t numTrailingObjects (OverloadToken<ContextualTypeInfo>) const {
535
+ return Kind == ConstraintKind::SyntacticElement ? 1 : 0 ;
536
+ }
537
+
530
538
size_t numTrailingObjects (OverloadToken<OverloadChoice>) const {
531
539
return Kind == ConstraintKind::BindOverload ? 1 : 0 ;
532
540
}
@@ -604,15 +612,15 @@ class Constraint final : public llvm::ilist_node<Constraint>,
604
612
DeclContext *useDC, ConstraintLocator *locator);
605
613
606
614
static Constraint *createSyntacticElement (ConstraintSystem &cs,
607
- ASTNode node,
608
- ConstraintLocator *locator,
609
- bool isDiscarded = false );
615
+ ASTNode node,
616
+ ConstraintLocator *locator,
617
+ bool isDiscarded = false );
610
618
611
619
static Constraint *createSyntacticElement (ConstraintSystem &cs,
612
- ASTNode node,
613
- ContextualTypeInfo context,
614
- ConstraintLocator *locator,
615
- bool isDiscarded = false );
620
+ ASTNode node,
621
+ ContextualTypeInfo context,
622
+ ConstraintLocator *locator,
623
+ bool isDiscarded = false );
616
624
617
625
// / Determine the kind of constraint.
618
626
ConstraintKind getKind () const { return Kind; }
@@ -903,13 +911,13 @@ class Constraint final : public llvm::ilist_node<Constraint>,
903
911
}
904
912
905
913
ContextualTypeInfo getElementContext () const {
906
- assert (Kind == ConstraintKind::SyntacticElement);
907
- return SyntacticElement. Context ;
914
+ ASSERT (Kind == ConstraintKind::SyntacticElement);
915
+ return *getTrailingObjects<ContextualTypeInfo>() ;
908
916
}
909
917
910
918
bool isDiscardedElement () const {
911
919
assert (Kind == ConstraintKind::SyntacticElement);
912
- return SyntacticElement. IsDiscarded ;
920
+ return isDiscarded ;
913
921
}
914
922
915
923
// / For an applicable function constraint, retrieve the trailing closure
0 commit comments