File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -869,7 +869,7 @@ class GenericSignatureBuilder::RequirementSource final
869
869
" RequirementSource kind/storageKind mismatch" );
870
870
871
871
storage.type = type.getPointer ();
872
- if (kind == ProtocolRequirement )
872
+ if (isProtocolRequirement () )
873
873
getTrailingObjects<ProtocolDecl *>()[0 ] = protocol;
874
874
if (hasTrailingWrittenRequirementLoc)
875
875
getTrailingObjects<WrittenRequirementLoc>()[0 ] = writtenReqLoc;
@@ -979,6 +979,11 @@ class GenericSignatureBuilder::RequirementSource final
979
979
llvm::function_ref<bool (PotentialArchetype *,
980
980
const RequirementSource *)> visitor) const ;
981
981
982
+ // / Whether this source is a requirement in a protocol.
983
+ bool isProtocolRequirement () const {
984
+ return kind == ProtocolRequirement || kind == InferredProtocolRequirement;
985
+ }
986
+
982
987
// / Whether the requirement is inferred or derived from an inferred
983
988
// / requirement.
984
989
bool isInferredRequirement () const ;
Original file line number Diff line number Diff line change @@ -823,8 +823,7 @@ ConformanceAccessPath GenericSignature::getConformanceAccessPath(
823
823
buildPath = [&](GenericSignature *sig, const RequirementSource *source,
824
824
ProtocolDecl *conformingProto, Type rootType) {
825
825
// Each protocol requirement is a step along the path.
826
- if (source->kind == RequirementSource::ProtocolRequirement ||
827
- source->kind == RequirementSource::InferredProtocolRequirement) {
826
+ if (source->isProtocolRequirement ()) {
828
827
// Follow the rest of the path to derive the conformance into which
829
828
// this particular protocol requirement step would look.
830
829
auto inProtocol = source->getProtocolDecl ();
Original file line number Diff line number Diff line change @@ -613,7 +613,7 @@ ProtocolDecl *RequirementSource::getProtocolDecl() const {
613
613
return nullptr ;
614
614
615
615
case StorageKind::StoredType:
616
- if (kind == ProtocolRequirement )
616
+ if (isProtocolRequirement () )
617
617
return getTrailingObjects<ProtocolDecl *>()[0 ];
618
618
return nullptr ;
619
619
@@ -637,7 +637,7 @@ SourceLoc RequirementSource::getLoc() const {
637
637
// for a particular requirement, rather than turning on/off location info.
638
638
// Locations that fall into this category should be advisory, emitted via
639
639
// notes rather than as the normal location.
640
- if (kind == ProtocolRequirement && parent &&
640
+ if (isProtocolRequirement () && parent &&
641
641
parent->kind != RequirementSignatureSelf)
642
642
return parent->getLoc ();
643
643
@@ -668,8 +668,7 @@ SourceLoc RequirementSource::getLoc() const {
668
668
static unsigned sourcePathLength (const RequirementSource *source) {
669
669
unsigned count = 0 ;
670
670
for (; source; source = source->parent ) {
671
- if (source->kind == RequirementSource::ProtocolRequirement ||
672
- source->kind == RequirementSource::InferredProtocolRequirement)
671
+ if (source->isProtocolRequirement ())
673
672
++count;
674
673
}
675
674
return count;
You can’t perform that action at this time.
0 commit comments