Skip to content

Commit 755f0f9

Browse files
committed
NFC: Remove the now dead ProtocolDecl::existentialTypeSupported()
1 parent 23c1d66 commit 755f0f9

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 {
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 {
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,
@@ -4157,21 +4151,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41574151
Bits.ProtocolDecl.ExistentialConformsToSelf = result;
41584152
}
41594153

4160-
/// Returns the cached result of \c existentialTypeSupported or \c None if it
4161-
/// hasn't yet been computed.
4162-
Optional<bool> getCachedExistentialTypeSupported() {
4163-
if (Bits.ProtocolDecl.ExistentialTypeSupportedValid)
4164-
return Bits.ProtocolDecl.ExistentialTypeSupported;
4165-
4166-
return None;
4167-
}
4168-
4169-
/// Caches the result of \c existentialTypeSupported
4170-
void setCachedExistentialTypeSupported(bool supported) {
4171-
Bits.ProtocolDecl.ExistentialTypeSupportedValid = true;
4172-
Bits.ProtocolDecl.ExistentialTypeSupported = supported;
4173-
}
4174-
41754154
bool hasLazyRequirementSignature() const {
41764155
return Bits.ProtocolDecl.HasLazyRequirementSignature;
41774156
}
@@ -4181,7 +4160,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41814160
friend class RequirementSignatureRequest;
41824161
friend class ProtocolRequiresClassRequest;
41834162
friend class ExistentialConformsToSelfRequest;
4184-
friend class ExistentialTypeSupportedRequest;
41854163
friend class InheritedProtocolsRequest;
41864164

41874165
public:
@@ -4270,12 +4248,6 @@ class ProtocolDecl final : public NominalTypeDecl {
42704248
/// contain 'Self' in 'parameter' or 'other' position.
42714249
bool isAvailableInExistential(const ValueDecl *decl) const;
42724250

4273-
/// Determine whether we are allowed to refer to an existential type
4274-
/// conforming to this protocol. This is only permitted if the types of
4275-
/// all the members do not contain any associated types, and do not
4276-
/// contain 'Self' in 'parameter' or 'other' position.
4277-
bool existentialTypeSupported() const;
4278-
42794251
/// Returns a list of protocol requirements that must be assessed to
42804252
/// determine a concrete's conformance effect polymorphism kind.
42814253
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
@@ -5148,11 +5148,6 @@ bool ProtocolDecl::isAvailableInExistential(const ValueDecl *decl) const {
51485148
return true;
51495149
}
51505150

5151-
bool ProtocolDecl::existentialTypeSupported() const {
5152-
return evaluateOrDefault(getASTContext().evaluator,
5153-
ExistentialTypeSupportedRequest{const_cast<ProtocolDecl *>(this)}, true);
5154-
}
5155-
51565151
StringRef ProtocolDecl::getObjCRuntimeName(
51575152
llvm::SmallVectorImpl<char> &buffer) const {
51585153
// 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
@@ -1252,7 +1252,6 @@ namespace decls_block {
12521252
BCFixed<1>, // implicit flag
12531253
BCFixed<1>, // class-bounded?
12541254
BCFixed<1>, // objc?
1255-
BCFixed<1>, // existential-type-supported?
12561255
AccessLevelField, // access level
12571256
BCVBR<4>, // number of inherited types
12581257
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
@@ -3537,7 +3537,6 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
35373537
const_cast<ProtocolDecl *>(proto)
35383538
->requiresClass(),
35393539
proto->isObjC(),
3540-
proto->existentialTypeSupported(),
35413540
rawAccessLevel, numInherited,
35423541
inheritedAndDependencyTypes);
35433542

0 commit comments

Comments
 (0)