Skip to content

Commit e9bcd00

Browse files
committed
AST: Remove GenericEnvironment::OwningDC
1 parent 97dd1aa commit e9bcd00

File tree

6 files changed

+2
-59
lines changed

6 files changed

+2
-59
lines changed

include/swift/AST/GenericEnvironment.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
5959
: private llvm::TrailingObjects<GenericEnvironment, Type> {
6060
GenericSignature *Signature = nullptr;
6161
GenericSignatureBuilder *Builder = nullptr;
62-
DeclContext *OwningDC = nullptr;
6362

6463
friend TrailingObjects;
6564

@@ -98,18 +97,6 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
9897
GenericEnvironment *getIncomplete(GenericSignature *signature,
9998
GenericSignatureBuilder *builder);
10099

101-
/// Set the owning declaration context for this generic environment.
102-
void setOwningDeclContext(DeclContext *owningDC);
103-
104-
/// Retrieve the declaration context that owns this generic environment, if
105-
/// there is one.
106-
///
107-
/// Note that several generic environments may refer to the same declaration
108-
/// context, because non-generic declarations nested within generic ones
109-
/// inherit the enclosing generic environment. In such cases, the owning
110-
/// context is the outermost context.
111-
DeclContext *getOwningDeclContext() const { return OwningDC; }
112-
113100
/// Add a mapping of a generic parameter to a specific type (which may be
114101
/// an archetype)
115102
void addMapping(GenericParamKey key, Type contextType);

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,10 +3519,6 @@ namespace {
35193519
printArchetypeCommon(T, "primary_archetype_type", label);
35203520
printField("name", T->getFullName());
35213521
OS << "\n";
3522-
auto genericEnv = T->getGenericEnvironment();
3523-
if (auto owningDC = genericEnv->getOwningDeclContext()) {
3524-
owningDC->printContext(OS, Indent + 2);
3525-
}
35263522
printArchetypeNestedTypes(T);
35273523
PrintWithColorRAII(OS, ParenthesisColor) << ')';
35283524
}

lib/AST/ASTVerifier.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -667,14 +667,6 @@ class Verifier : public ASTWalker {
667667
Out << "AST verification error: archetype "
668668
<< root->getString() << " not allowed in this context\n";
669669

670-
if (auto env = rootPrimary->getGenericEnvironment()) {
671-
if (auto owningDC = env->getOwningDeclContext()) {
672-
llvm::errs() << "archetype came from:\n";
673-
owningDC->dumpContext();
674-
llvm::errs() << "\n";
675-
}
676-
}
677-
678670
return true;
679671
}
680672

lib/AST/Decl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,6 @@ void GenericContext::setGenericEnvironment(GenericEnvironment *genericEnv) {
874874
genericEnv->getGenericSignature()->getCanonicalSignature()) &&
875875
"set a generic environment with a different generic signature");
876876
this->GenericSigOrEnv = genericEnv;
877-
if (genericEnv)
878-
genericEnv->setOwningDeclContext(this);
879877
}
880878

881879
GenericEnvironment *

lib/AST/GenericEnvironment.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,6 @@ GenericEnvironment::GenericEnvironment(GenericSignature *signature,
5555
Type());
5656
}
5757

58-
void GenericEnvironment::setOwningDeclContext(DeclContext *newOwningDC) {
59-
if (!OwningDC) {
60-
OwningDC = newOwningDC;
61-
return;
62-
}
63-
64-
if (!newOwningDC || OwningDC == newOwningDC)
65-
return;
66-
67-
// Find the least common ancestor context to be the owner.
68-
unsigned oldDepth = OwningDC->getSyntacticDepth();
69-
unsigned newDepth = newOwningDC->getSyntacticDepth();
70-
71-
while (oldDepth > newDepth) {
72-
OwningDC = OwningDC->getParent();
73-
--oldDepth;
74-
}
75-
76-
while (newDepth > oldDepth) {
77-
newOwningDC = newOwningDC->getParent();
78-
--newDepth;
79-
}
80-
81-
while (OwningDC != newOwningDC) {
82-
OwningDC = OwningDC->getParent();
83-
newOwningDC = newOwningDC->getParent();
84-
}
85-
}
86-
8758
void GenericEnvironment::addMapping(GenericParamKey key,
8859
Type contextType) {
8960
// Find the index into the parallel arrays of generic parameters and

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,17 +3357,16 @@ bool FailureDiagnosis::diagnoseArgumentGenericRequirements(
33573357
}
33583358
};
33593359

3360-
auto *dc = env->getOwningDeclContext();
33613360
auto substitutionFn = QueryTypeSubstitutionMap{substitutions};
33623361
RequirementsListener genericReqListener(CS, AFD, substitutionFn,
33633362
callExpr, fnExpr, argExpr);
33643363

33653364
auto result = TC.checkGenericArguments(
3366-
dc, callExpr->getLoc(), fnExpr->getLoc(), AFD->getInterfaceType(),
3365+
AFD, callExpr->getLoc(), fnExpr->getLoc(), AFD->getInterfaceType(),
33673366
env->getGenericSignature()->getGenericParams(),
33683367
env->getGenericSignature()->getRequirements(),
33693368
substitutionFn,
3370-
LookUpConformanceInModule{dc->getParentModule()},
3369+
LookUpConformanceInModule{AFD->getParentModule()},
33713370
ConformanceCheckFlags::SuppressDependencyTracking, &genericReqListener);
33723371

33733372
// Note: If result is RequirementCheckResult::SubstitutionFailure, we did

0 commit comments

Comments
 (0)