Skip to content

Commit d514422

Browse files
committed
AST: Add HasComputedAssociatedConformancesFlag to NormalProtocolConformance
1 parent 793c7a1 commit d514422

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

include/swift/AST/ProtocolConformance.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,18 @@ class NormalProtocolConformance : public RootProtocolConformance,
444444

445445
/// The conformance was labeled with @unchecked.
446446
UncheckedFlag = 0x02,
447+
448+
/// We have allocated the AssociatedConformances array (but not necessarily
449+
/// populated any of its elements).
450+
HasComputedAssociatedConformancesFlag = 0x04,
447451
};
448452

449453
/// The declaration context containing the ExtensionDecl or
450454
/// NominalTypeDecl that declared the conformance.
451455
///
452-
/// Also stores the "invalid" and "unchecked" bits.
453-
llvm::PointerIntPair<DeclContext *, 2, unsigned> ContextAndBits;
456+
/// Also stores the "invalid", "unchecked" and "has computed associated
457+
/// conformances" bits.
458+
llvm::PointerIntPair<DeclContext *, 3, unsigned> ContextAndBits;
454459

455460
/// The reason that this conformance exists.
456461
///
@@ -554,6 +559,17 @@ class NormalProtocolConformance : public RootProtocolConformance,
554559
ContextAndBits.setInt(ContextAndBits.getInt() | UncheckedFlag);
555560
}
556561

562+
/// Determine whether we've lazily computed the associated conformance array
563+
/// already.
564+
bool hasComputedAssociatedConformances() const {
565+
return ContextAndBits.getInt() & HasComputedAssociatedConformancesFlag;
566+
}
567+
568+
/// Mark this conformance as having computed the assocaited conformance array.
569+
void setHasComputedAssociatedConformances() {
570+
ContextAndBits.setInt(ContextAndBits.getInt() | HasComputedAssociatedConformancesFlag);
571+
}
572+
557573
/// Get the kind of source from which this conformance comes.
558574
ConformanceEntryKind getSourceKind() const {
559575
return SourceKindAndImplyingConformance.getInt();

lib/AST/ProtocolConformance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,14 @@ Type ProtocolConformance::getAssociatedType(Type assocType) const {
535535

536536
ProtocolConformanceRef
537537
ProtocolConformance::getAssociatedConformance(Type assocType,
538-
ProtocolDecl *protocol) const {
538+
ProtocolDecl *protocol) const {
539539
CONFORMANCE_SUBCLASS_DISPATCH(getAssociatedConformance,
540540
(assocType, protocol))
541541
}
542542

543543
ProtocolConformanceRef
544544
NormalProtocolConformance::getAssociatedConformance(Type assocType,
545-
ProtocolDecl *protocol) const {
545+
ProtocolDecl *protocol) const {
546546
assert(assocType->isTypeParameter() &&
547547
"associated type must be a type parameter");
548548

0 commit comments

Comments
 (0)