Skip to content

Commit eb1bd07

Browse files
committed
NFC: Remove the now dead ProtocolDecl::existentialTypeSupported()
1 parent 15f88e9 commit eb1bd07

File tree

9 files changed

+2
-121
lines changed

9 files changed

+2
-121
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
514514
IsComputingSemanticMembers : 1
515515
);
516516

517-
SWIFT_INLINE_BITFIELD_FULL(ProtocolDecl, NominalTypeDecl, 1+1+1+1+1+1+1+1+1+1+1+8+16,
517+
SWIFT_INLINE_BITFIELD_FULL(ProtocolDecl, NominalTypeDecl, 1+1+1+1+1+1+1+1+1+8+16,
518518
/// Whether the \c RequiresClass bit is valid.
519519
RequiresClassValid : 1,
520520

@@ -527,12 +527,6 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
527527
/// Whether the existential of this protocol conforms to itself.
528528
ExistentialConformsToSelf : 1,
529529

530-
/// Whether the \c ExistentialTypeSupported bit is valid.
531-
ExistentialTypeSupportedValid : 1,
532-
533-
/// Whether the existential of this protocol can be represented.
534-
ExistentialTypeSupported : 1,
535-
536530
/// True if the protocol has requirements that cannot be satisfied (e.g.
537531
/// because they could not be imported from Objective-C).
538532
HasMissingRequirements : 1,
@@ -4151,21 +4145,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41514145
Bits.ProtocolDecl.ExistentialConformsToSelf = result;
41524146
}
41534147

4154-
/// Returns the cached result of \c existentialTypeSupported or \c None if it
4155-
/// hasn't yet been computed.
4156-
Optional<bool> getCachedExistentialTypeSupported() {
4157-
if (Bits.ProtocolDecl.ExistentialTypeSupportedValid)
4158-
return Bits.ProtocolDecl.ExistentialTypeSupported;
4159-
4160-
return None;
4161-
}
4162-
4163-
/// Caches the result of \c existentialTypeSupported
4164-
void setCachedExistentialTypeSupported(bool supported) {
4165-
Bits.ProtocolDecl.ExistentialTypeSupportedValid = true;
4166-
Bits.ProtocolDecl.ExistentialTypeSupported = supported;
4167-
}
4168-
41694148
bool hasLazyRequirementSignature() const {
41704149
return Bits.ProtocolDecl.HasLazyRequirementSignature;
41714150
}
@@ -4175,7 +4154,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41754154
friend class RequirementSignatureRequest;
41764155
friend class ProtocolRequiresClassRequest;
41774156
friend class ExistentialConformsToSelfRequest;
4178-
friend class ExistentialTypeSupportedRequest;
41794157
friend class InheritedProtocolsRequest;
41804158

41814159
public:
@@ -4264,12 +4242,6 @@ class ProtocolDecl final : public NominalTypeDecl {
42644242
/// contain 'Self' in 'parameter' or 'other' position.
42654243
bool isAvailableInExistential(const ValueDecl *decl) const;
42664244

4267-
/// Determine whether we are allowed to refer to an existential type
4268-
/// conforming to this protocol. This is only permitted if the types of
4269-
/// all the members do not contain any associated types, and do not
4270-
/// contain 'Self' in 'parameter' or 'other' position.
4271-
bool existentialTypeSupported() const;
4272-
42734245
/// Returns a list of protocol requirements that must be assessed to
42744246
/// determine a concrete's conformance effect polymorphism kind.
42754247
PolymorphicEffectRequirementList getPolymorphicEffectRequirements(

include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -287,32 +287,6 @@ class ExistentialConformsToSelfRequest :
287287
void cacheResult(bool value) const;
288288
};
289289

290-
/// Determine whether we are allowed to refer to an existential type conforming
291-
/// to this protocol.
292-
class ExistentialTypeSupportedRequest :
293-
public SimpleRequest<ExistentialTypeSupportedRequest,
294-
bool(ProtocolDecl *),
295-
RequestFlags::SeparatelyCached> {
296-
public:
297-
using SimpleRequest::SimpleRequest;
298-
299-
private:
300-
friend SimpleRequest;
301-
302-
// Evaluation.
303-
bool evaluate(Evaluator &evaluator, ProtocolDecl *decl) const;
304-
305-
public:
306-
// Cycle handling.
307-
void diagnoseCycle(DiagnosticEngine &diags) const;
308-
void noteCycleStep(DiagnosticEngine &diags) const;
309-
310-
// Separate caching.
311-
bool isCached() const { return true; }
312-
Optional<bool> getCachedResult() const;
313-
void cacheResult(bool value) const;
314-
};
315-
316290
class PolymorphicEffectRequirementsRequest :
317291
public SimpleRequest<PolymorphicEffectRequirementsRequest,
318292
PolymorphicEffectRequirementList(EffectKind, ProtocolDecl *),

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ SWIFT_REQUEST(TypeChecker, EnumRawTypeRequest,
8787
Type(EnumDecl *), Cached, NoLocationInfo)
8888
SWIFT_REQUEST(TypeChecker, ExistentialConformsToSelfRequest,
8989
bool(ProtocolDecl *), SeparatelyCached, NoLocationInfo)
90-
SWIFT_REQUEST(TypeChecker, ExistentialTypeSupportedRequest,
91-
bool(ProtocolDecl *), SeparatelyCached, NoLocationInfo)
9290
SWIFT_REQUEST(TypeChecker, ExtendedTypeRequest, Type(ExtensionDecl *), Cached,
9391
NoLocationInfo)
9492
SWIFT_REQUEST(TypeChecker, ResultBuilderTypeRequest, Type(ValueDecl *),

lib/AST/Decl.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5136,11 +5136,6 @@ bool ProtocolDecl::isAvailableInExistential(const ValueDecl *decl) const {
51365136
return true;
51375137
}
51385138

5139-
bool ProtocolDecl::existentialTypeSupported() const {
5140-
return evaluateOrDefault(getASTContext().evaluator,
5141-
ExistentialTypeSupportedRequest{const_cast<ProtocolDecl *>(this)}, true);
5142-
}
5143-
51445139
StringRef ProtocolDecl::getObjCRuntimeName(
51455140
llvm::SmallVectorImpl<char> &buffer) const {
51465141
// If there is an 'objc' attribute with a name, use that name.

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -253,31 +253,6 @@ void ExistentialConformsToSelfRequest::cacheResult(bool value) const {
253253
decl->setCachedExistentialConformsToSelf(value);
254254
}
255255

256-
//----------------------------------------------------------------------------//
257-
// existentialTypeSupported computation.
258-
//----------------------------------------------------------------------------//
259-
260-
void ExistentialTypeSupportedRequest::diagnoseCycle(DiagnosticEngine &diags) const {
261-
auto decl = std::get<0>(getStorage());
262-
diags.diagnose(decl, diag::circular_protocol_def, decl->getName());
263-
}
264-
265-
void ExistentialTypeSupportedRequest::noteCycleStep(DiagnosticEngine &diags) const {
266-
auto requirement = std::get<0>(getStorage());
267-
diags.diagnose(requirement, diag::kind_declname_declared_here,
268-
DescriptiveDeclKind::Protocol, requirement->getName());
269-
}
270-
271-
Optional<bool> ExistentialTypeSupportedRequest::getCachedResult() const {
272-
auto decl = std::get<0>(getStorage());
273-
return decl->getCachedExistentialTypeSupported();
274-
}
275-
276-
void ExistentialTypeSupportedRequest::cacheResult(bool value) const {
277-
auto decl = std::get<0>(getStorage());
278-
decl->setCachedExistentialTypeSupported(value);
279-
}
280-
281256
//----------------------------------------------------------------------------//
282257
// isFinal computation.
283258
//----------------------------------------------------------------------------//

lib/Sema/TypeCheckDecl.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -672,34 +672,6 @@ ExistentialConformsToSelfRequest::evaluate(Evaluator &evaluator,
672672
return true;
673673
}
674674

675-
bool
676-
ExistentialTypeSupportedRequest::evaluate(Evaluator &evaluator,
677-
ProtocolDecl *decl) const {
678-
// ObjC protocols can always be existential.
679-
if (decl->isObjC())
680-
return true;
681-
682-
for (auto member : decl->getMembers()) {
683-
// Existential types cannot be used if the protocol has an associated type.
684-
if (isa<AssociatedTypeDecl>(member))
685-
return false;
686-
687-
// For value members, look at their type signatures.
688-
if (auto valueMember = dyn_cast<ValueDecl>(member)) {
689-
if (!decl->isAvailableInExistential(valueMember))
690-
return false;
691-
}
692-
}
693-
694-
// Check whether all of the inherited protocols support existential types.
695-
for (auto proto : decl->getInheritedProtocols()) {
696-
if (!proto->existentialTypeSupported())
697-
return false;
698-
}
699-
700-
return true;
701-
}
702-
703675
bool
704676
IsFinalRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const {
705677
if (isa<ClassDecl>(decl))

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,14 +3561,13 @@ class DeclDeserializer {
35613561
StringRef blobData) {
35623562
IdentifierID nameID;
35633563
DeclContextID contextID;
3564-
bool isImplicit, isClassBounded, isObjC, existentialTypeSupported;
3564+
bool isImplicit, isClassBounded, isObjC;
35653565
uint8_t rawAccessLevel;
35663566
unsigned numInheritedTypes;
35673567
ArrayRef<uint64_t> rawInheritedAndDependencyIDs;
35683568

35693569
decls_block::ProtocolLayout::readRecord(scratch, nameID, contextID,
35703570
isImplicit, isClassBounded, isObjC,
3571-
existentialTypeSupported,
35723571
rawAccessLevel, numInheritedTypes,
35733572
rawInheritedAndDependencyIDs);
35743573

@@ -3594,8 +3593,6 @@ class DeclDeserializer {
35943593

35953594
ctx.evaluator.cacheOutput(ProtocolRequiresClassRequest{proto},
35963595
std::move(isClassBounded));
3597-
ctx.evaluator.cacheOutput(ExistentialTypeSupportedRequest{proto},
3598-
std::move(existentialTypeSupported));
35993596

36003597
if (auto accessLevel = getActualAccessLevel(rawAccessLevel))
36013598
proto->setAccess(*accessLevel);

lib/Serialization/ModuleFormat.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,6 @@ namespace decls_block {
12571257
BCFixed<1>, // implicit flag
12581258
BCFixed<1>, // class-bounded?
12591259
BCFixed<1>, // objc?
1260-
BCFixed<1>, // existential-type-supported?
12611260
AccessLevelField, // access level
12621261
BCVBR<4>, // number of inherited types
12631262
BCArray<TypeIDField> // inherited types, followed by dependency types

lib/Serialization/Serialization.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3545,7 +3545,6 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
35453545
const_cast<ProtocolDecl *>(proto)
35463546
->requiresClass(),
35473547
proto->isObjC(),
3548-
proto->existentialTypeSupported(),
35493548
rawAccessLevel, numInherited,
35503549
inheritedAndDependencyTypes);
35513550

0 commit comments

Comments
 (0)