Skip to content

Commit 451b2c7

Browse files
committed
AST: Remove NominalTypeDecl::hasInverseMarking()
1 parent a53b2dd commit 451b2c7

File tree

6 files changed

+2
-193
lines changed

6 files changed

+2
-193
lines changed

include/swift/AST/Decl.h

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "swift/AST/IfConfigClause.h"
3333
#include "swift/AST/Import.h"
3434
#include "swift/AST/Initializer.h"
35-
#include "swift/AST/InverseMarking.h"
3635
#include "swift/AST/LayoutConstraint.h"
3736
#include "swift/AST/LifetimeAnnotation.h"
3837
#include "swift/AST/ReferenceCounting.h"
@@ -96,7 +95,6 @@ namespace swift {
9695
class NamedPattern;
9796
class EnumCaseDecl;
9897
class EnumElementDecl;
99-
struct InverseMarking;
10098
class ParameterList;
10199
class ParameterTypeFlags;
102100
class Pattern;
@@ -4372,30 +4370,12 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
43724370
/// Returns null if the type is a class, or does not have a declared `deinit`.
43734371
DestructorDecl *getValueTypeDestructor();
43744372

4375-
/// "Does a conformance for Copyable exist for this type declaration?"
4376-
///
4377-
/// This doesn't mean that all instance of this type are Copyable, because
4378-
/// if a conditional conformance to Copyable exists, this method will return
4379-
/// true.
4380-
///
4381-
/// If you need a more precise answer, ask this Decl's corresponding
4382-
/// Type if it `isCopyable` instead of using this.
4373+
/// Does a conformance for Copyable exist for this nominal type declaration?
43834374
CanBeInvertible::Result canBeCopyable() const;
43844375

4385-
/// "Does a conformance for Escapable exist for this type declaration?"
4386-
///
4387-
/// This doesn't mean that all instance of this type are Escapable, because
4388-
/// if a conditional conformance to Escapable exists, this method will return
4389-
/// true.
4390-
///
4391-
/// If you need a more precise answer, ask this Decl's corresponding
4392-
/// Type if it `isEscapable` instead of using this.
4376+
/// Does a conformance for Escapable exist for this nominal type declaration?
43934377
CanBeInvertible::Result canBeEscapable() const;
43944378

4395-
/// Determine whether this type has ~<target>` stated on
4396-
/// itself, one of its inherited types or `Self` requirements.
4397-
InverseMarking::Mark hasInverseMarking(InvertibleProtocolKind target) const;
4398-
43994379
// Implement isa/cast/dyncast/etc.
44004380
static bool classof(const Decl *D) {
44014381
return D->getKind() >= DeclKind::First_NominalTypeDecl &&

include/swift/AST/InverseMarking.h

Lines changed: 0 additions & 90 deletions
This file was deleted.

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "swift/AST/GenericEnvironment.h"
3030
#include "swift/AST/GenericParamList.h"
3131
#include "swift/AST/GenericSignature.h"
32-
#include "swift/AST/InverseMarking.h"
3332
#include "swift/AST/MacroDefinition.h"
3433
#include "swift/AST/Module.h"
3534
#include "swift/AST/NameLookup.h"

lib/AST/Decl.cpp

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "swift/AST/GenericSignature.h"
3333
#include "swift/AST/ImportCache.h"
3434
#include "swift/AST/Initializer.h"
35-
#include "swift/AST/InverseMarking.h"
3635
#include "swift/AST/LazyResolver.h"
3736
#include "swift/AST/MacroDefinition.h"
3837
#include "swift/AST/MacroDiscriminatorContext.h"
@@ -6601,83 +6600,6 @@ bool ProtocolDecl::inheritsFrom(const ProtocolDecl *super) const {
66016600
return (llvm::find(allInherited, super) != allInherited.end());
66026601
}
66036602

6604-
static void findInheritedType(
6605-
InheritedTypes inherited,
6606-
llvm::function_ref<bool(Type, NullablePtr<TypeRepr>)> isMatch) {
6607-
for (size_t i = 0; i < inherited.size(); i++) {
6608-
auto type = inherited.getResolvedType(i, TypeResolutionStage::Structural);
6609-
if (!type)
6610-
continue;
6611-
6612-
if (isMatch(type, inherited.getTypeRepr(i)))
6613-
break;
6614-
}
6615-
}
6616-
6617-
static InverseMarking::Mark
6618-
findInverseInInheritance(InheritedTypes inherited,
6619-
InvertibleProtocolKind target) {
6620-
auto isInverseOfTarget = [&](Type t) {
6621-
if (auto pct = t->getAs<ProtocolCompositionType>())
6622-
return pct->getInverses().contains(target);
6623-
return false;
6624-
};
6625-
6626-
InverseMarking::Mark inverse;
6627-
findInheritedType(inherited,
6628-
[&](Type inheritedTy, NullablePtr<TypeRepr> repr) {
6629-
if (!isInverseOfTarget(inheritedTy))
6630-
return false;
6631-
6632-
inverse = InverseMarking::Mark(
6633-
InverseMarking::Kind::Explicit,
6634-
repr.isNull() ? SourceLoc() : repr.get()->getLoc());
6635-
return true;
6636-
});
6637-
return inverse;
6638-
}
6639-
6640-
InverseMarking::Mark
6641-
NominalTypeDecl::hasInverseMarking(InvertibleProtocolKind target) const {
6642-
switch (target) {
6643-
case InvertibleProtocolKind::Copyable:
6644-
// Handle the legacy '@_moveOnly' for types they can validly appear.
6645-
// TypeCheckAttr handles the illegal situations for us.
6646-
if (auto attr = getAttrs().getAttribute<MoveOnlyAttr>())
6647-
if (isa<StructDecl, EnumDecl, ClassDecl>(this))
6648-
return InverseMarking::Mark(InverseMarking::Kind::LegacyExplicit,
6649-
attr->getLocation());
6650-
break;
6651-
6652-
case InvertibleProtocolKind::Escapable:
6653-
// Handle the legacy '@_nonEscapable' attribute
6654-
if (auto attr = getAttrs().getAttribute<NonEscapableAttr>()) {
6655-
assert((isa<ClassDecl, StructDecl, EnumDecl>(this)));
6656-
return InverseMarking::Mark(InverseMarking::Kind::LegacyExplicit,
6657-
attr->getLocation());
6658-
}
6659-
break;
6660-
}
6661-
6662-
auto &ctx = getASTContext();
6663-
6664-
// Legacy support stops here.
6665-
if (!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics))
6666-
return InverseMarking::Mark(InverseMarking::Kind::None);
6667-
6668-
// Claim that the tuple decl has an explicit ~TARGET marking.
6669-
if (isa<BuiltinTupleDecl>(this))
6670-
return InverseMarking::Mark(InverseMarking::Kind::Explicit);
6671-
6672-
assert(!isa<ProtocolDecl>(this));
6673-
6674-
// Search the inheritance clause first.
6675-
if (auto inverse = findInverseInInheritance(getInherited(), target))
6676-
return inverse;
6677-
6678-
return InverseMarking::Mark();
6679-
}
6680-
66816603
bool ProtocolDecl::requiresClass() const {
66826604
return evaluateOrDefault(getASTContext().evaluator,
66836605
ProtocolRequiresClassRequest{const_cast<ProtocolDecl *>(this)}, false);

lib/Sema/TypeCheckDecl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "swift/AST/ForeignErrorConvention.h"
3838
#include "swift/AST/GenericEnvironment.h"
3939
#include "swift/AST/Initializer.h"
40-
#include "swift/AST/InverseMarking.h"
4140
#include "swift/AST/NameLookup.h"
4241
#include "swift/AST/NameLookupRequests.h"
4342
#include "swift/AST/OperatorNameLookup.h"

lib/Sema/TypeCheckRequestFunctions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "swift/AST/ProtocolConformance.h"
2323
#include "swift/AST/TypeLoc.h"
2424
#include "swift/AST/Types.h"
25-
#include "swift/AST/InverseMarking.h"
2625
#include "swift/Subsystems.h"
2726

2827
using namespace swift;

0 commit comments

Comments
 (0)