23
23
#include " swift/AST/DefaultArgumentKind.h"
24
24
#include " swift/AST/KnownProtocols.h"
25
25
#include " swift/AST/Identifier.h"
26
+ #include " swift/AST/Requirement.h"
26
27
#include " swift/AST/Substitution.h"
27
28
#include " swift/AST/Type.h"
28
29
#include " swift/AST/TypeLoc.h"
@@ -427,30 +428,19 @@ class GenericParam {
427
428
void setDeclContext (DeclContext *DC);
428
429
};
429
430
430
- // / \brief Describes the kind of a requirement that occurs within a requirements
431
- // / clause.
432
- enum class RequirementKind : unsigned int {
433
- // / \brief A conformance requirement T : P, where T is a type that depends
434
- // / on a generic parameter and P is a protocol to which T must conform.
435
- Conformance,
436
- // / \brief A same-type requirement T == U, where T and U are types that
437
- // / shall be equivalent.
438
- SameType
439
- };
440
-
441
431
// / \brief A single requirement in a 'where' clause, which places additional
442
432
// / restrictions on the generic parameters or associated types of a generic
443
433
// / function, type, or protocol.
444
434
// /
445
435
// / This always represents a requirement spelled in the source code. It is
446
436
// / never generated implicitly.
447
- class Requirement {
437
+ class RequirementRepr {
448
438
SourceLoc SeparatorLoc;
449
439
RequirementKind Kind : 1 ;
450
440
bool Invalid : 1 ;
451
441
TypeLoc Types[2 ];
452
442
453
- Requirement (SourceLoc SeparatorLoc, RequirementKind Kind, TypeLoc FirstType,
443
+ RequirementRepr (SourceLoc SeparatorLoc, RequirementKind Kind, TypeLoc FirstType,
454
444
TypeLoc SecondType)
455
445
: SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false ),
456
446
Types{FirstType, SecondType} { }
@@ -464,7 +454,7 @@ class Requirement {
464
454
// / this requirement was implied.
465
455
// / \param Constraint The protocol or protocol composition to which the
466
456
// / subject must conform, or superclass from which the subject must inherit.
467
- static Requirement getConformance (TypeLoc Subject,
457
+ static RequirementRepr getConformance (TypeLoc Subject,
468
458
SourceLoc ColonLoc,
469
459
TypeLoc Constraint) {
470
460
return { ColonLoc, RequirementKind::Conformance, Subject, Constraint };
@@ -476,7 +466,7 @@ class Requirement {
476
466
// / \param EqualLoc The location of the '==' in the same-type constraint, or
477
467
// / an invalid location if this requirement was implied.
478
468
// / \param SecondType The second type.
479
- static Requirement getSameType (TypeLoc FirstType,
469
+ static RequirementRepr getSameType (TypeLoc FirstType,
480
470
SourceLoc EqualLoc,
481
471
TypeLoc SecondType) {
482
472
return { EqualLoc, RequirementKind::SameType, FirstType, SecondType };
@@ -589,15 +579,15 @@ class GenericParamList {
589
579
SourceRange Brackets;
590
580
unsigned NumParams;
591
581
SourceLoc WhereLoc;
592
- MutableArrayRef<Requirement > Requirements;
582
+ MutableArrayRef<RequirementRepr > Requirements;
593
583
ArrayRef<ArchetypeType *> AllArchetypes;
594
584
595
585
GenericParamList *OuterParameters;
596
586
597
587
GenericParamList (SourceLoc LAngleLoc,
598
588
ArrayRef<GenericParam> Params,
599
589
SourceLoc WhereLoc,
600
- MutableArrayRef<Requirement > Requirements,
590
+ MutableArrayRef<RequirementRepr > Requirements,
601
591
SourceLoc RAngleLoc);
602
592
603
593
public:
@@ -630,7 +620,7 @@ class GenericParamList {
630
620
SourceLoc LAngleLoc,
631
621
ArrayRef<GenericParam> Params,
632
622
SourceLoc WhereLoc,
633
- MutableArrayRef<Requirement > Requirements,
623
+ MutableArrayRef<RequirementRepr > Requirements,
634
624
SourceLoc RAngleLoc);
635
625
636
626
MutableArrayRef<GenericParam> getParams () {
@@ -659,15 +649,15 @@ class GenericParamList {
659
649
// / This list may contain both explicitly-written requirements as well as
660
650
// / implicitly-generated requirements, and may be non-empty even if no
661
651
// / 'where' keyword is present.
662
- MutableArrayRef<Requirement > getRequirements () { return Requirements; }
652
+ MutableArrayRef<RequirementRepr > getRequirements () { return Requirements; }
663
653
664
654
// / \brief Retrieve the set of additional requirements placed on these
665
655
// / generic parameters and types derived from them.
666
656
// /
667
657
// / This list may contain both explicitly-written requirements as well as
668
658
// / implicitly-generated requirements, and may be non-empty even if no
669
659
// / 'where' keyword is present.
670
- ArrayRef<Requirement > getRequirements () const { return Requirements; }
660
+ ArrayRef<RequirementRepr > getRequirements () const { return Requirements; }
671
661
672
662
// / \brief Override the set of requirements associated with this generic
673
663
// / parameter list.
@@ -676,7 +666,7 @@ class GenericParamList {
676
666
// / to be a superset of the existing set of requirements (although this
677
667
// / property is not checked here). It is assumed that the array reference
678
668
// / refers to ASTContext-allocated memory.
679
- void overrideRequirements (MutableArrayRef<Requirement > NewRequirements) {
669
+ void overrideRequirements (MutableArrayRef<RequirementRepr > NewRequirements) {
680
670
Requirements = NewRequirements;
681
671
}
682
672
@@ -887,8 +877,8 @@ class ExtensionDecl : public Decl, public DeclContext {
887
877
}
888
878
889
879
// / Note that we have already type-checked the inheritance clause.
890
- void setCheckedInheritanceClause () {
891
- ExtensionDeclBits.CheckedInheritanceClause = true ;
880
+ void setCheckedInheritanceClause (bool checked = true ) {
881
+ ExtensionDeclBits.CheckedInheritanceClause = checked ;
892
882
}
893
883
894
884
// / \brief Retrieve the set of protocols to which this extension conforms.
@@ -1158,8 +1148,8 @@ class TypeDecl : public ValueDecl {
1158
1148
}
1159
1149
1160
1150
// / Note that we have already type-checked the inheritance clause.
1161
- void setCheckedInheritanceClause () {
1162
- TypeDeclBits.CheckedInheritanceClause = true ;
1151
+ void setCheckedInheritanceClause (bool checked = true ) {
1152
+ TypeDeclBits.CheckedInheritanceClause = checked ;
1163
1153
}
1164
1154
1165
1155
// / \brief Retrieve the set of protocols to which this type conforms.
0 commit comments