@@ -336,16 +336,22 @@ 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
342
343
// / The kind of constraint.
343
344
ConstraintKind Kind : 8 ;
344
345
345
346
// / The kind of restriction placed on this constraint.
346
- ConversionRestrictionKind Restriction : 8 ;
347
+ ConversionRestrictionKind Restriction : 5 ;
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,17 @@ 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
+
386
395
union {
387
396
struct {
388
397
// / The first type.
@@ -433,10 +442,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
433
442
struct {
434
443
// / The node itself.
435
444
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
445
} SyntacticElement;
441
446
442
447
struct {
@@ -447,9 +452,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
447
452
// / The type being called, primarily a function type, but could
448
453
// / be a metatype, a tuple or a nominal type.
449
454
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
455
// / The declaration context in which the application appears.
454
456
DeclContext *UseDC;
455
457
} Apply;
@@ -527,6 +529,10 @@ class Constraint final : public llvm::ilist_node<Constraint>,
527
529
return HasFix ? 1 : 0 ;
528
530
}
529
531
532
+ size_t numTrailingObjects (OverloadToken<ContextualTypeInfo>) const {
533
+ return Kind == ConstraintKind::SyntacticElement ? 1 : 0 ;
534
+ }
535
+
530
536
size_t numTrailingObjects (OverloadToken<OverloadChoice>) const {
531
537
return Kind == ConstraintKind::BindOverload ? 1 : 0 ;
532
538
}
@@ -604,15 +610,15 @@ class Constraint final : public llvm::ilist_node<Constraint>,
604
610
DeclContext *useDC, ConstraintLocator *locator);
605
611
606
612
static Constraint *createSyntacticElement (ConstraintSystem &cs,
607
- ASTNode node,
608
- ConstraintLocator *locator,
609
- bool isDiscarded = false );
613
+ ASTNode node,
614
+ ConstraintLocator *locator,
615
+ bool isDiscarded = false );
610
616
611
617
static Constraint *createSyntacticElement (ConstraintSystem &cs,
612
- ASTNode node,
613
- ContextualTypeInfo context,
614
- ConstraintLocator *locator,
615
- bool isDiscarded = false );
618
+ ASTNode node,
619
+ ContextualTypeInfo context,
620
+ ConstraintLocator *locator,
621
+ bool isDiscarded = false );
616
622
617
623
// / Determine the kind of constraint.
618
624
ConstraintKind getKind () const { return Kind; }
@@ -903,13 +909,13 @@ class Constraint final : public llvm::ilist_node<Constraint>,
903
909
}
904
910
905
911
ContextualTypeInfo getElementContext () const {
906
- assert (Kind == ConstraintKind::SyntacticElement);
907
- return SyntacticElement. Context ;
912
+ ASSERT (Kind == ConstraintKind::SyntacticElement);
913
+ return *getTrailingObjects<ContextualTypeInfo>() ;
908
914
}
909
915
910
916
bool isDiscardedElement () const {
911
917
assert (Kind == ConstraintKind::SyntacticElement);
912
- return SyntacticElement. IsDiscarded ;
918
+ return isDiscarded ;
913
919
}
914
920
915
921
// / For an applicable function constraint, retrieve the trailing closure
0 commit comments