Skip to content

Commit 46d4163

Browse files
committed
Sema: Remove TypoCorrectionResolver
With the previous changes, validating a property while type checking its initializer is no longer a fatal error. This means we don't have to do anything special when validating typo correction candidates, so we can get rid of the TypoCorrectionResolver. This means there is now only one subclass of LazyResolver, the TypeChecker itself.
1 parent 09cc860 commit 46d4163

File tree

3 files changed

+2
-91
lines changed

3 files changed

+2
-91
lines changed

include/swift/AST/LazyResolver.h

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -101,71 +101,6 @@ class LazyResolver {
101101
DeclContext *dc) = 0;
102102
};
103103

104-
/// An implementation of LazyResolver that delegates to another.
105-
class DelegatingLazyResolver : public LazyResolver {
106-
protected:
107-
LazyResolver &Principal;
108-
public:
109-
DelegatingLazyResolver(LazyResolver &principal) : Principal(principal) {}
110-
~DelegatingLazyResolver(); // v-table anchor
111-
112-
void resolveTypeWitness(const NormalProtocolConformance *conformance,
113-
AssociatedTypeDecl *assocType) override {
114-
Principal.resolveTypeWitness(conformance, assocType);
115-
}
116-
117-
void resolveWitness(const NormalProtocolConformance *conformance,
118-
ValueDecl *requirement) override {
119-
Principal.resolveWitness(conformance, requirement);
120-
}
121-
122-
void resolveAccessControl(ValueDecl *VD) override {
123-
Principal.resolveAccessControl(VD);
124-
}
125-
126-
void resolveDeclSignature(ValueDecl *VD) override {
127-
Principal.resolveDeclSignature(VD);
128-
}
129-
130-
void resolveInheritanceClause(
131-
llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl) override {
132-
Principal.resolveInheritanceClause(decl);
133-
}
134-
135-
void resolveSuperclass(ClassDecl *classDecl) override {
136-
Principal.resolveSuperclass(classDecl);
137-
}
138-
139-
void resolveRawType(EnumDecl *enumDecl) override {
140-
Principal.resolveRawType(enumDecl);
141-
}
142-
143-
void resolveInheritedProtocols(ProtocolDecl *protocol) override {
144-
Principal.resolveInheritedProtocols(protocol);
145-
}
146-
147-
void bindExtension(ExtensionDecl *ext) override {
148-
Principal.bindExtension(ext);
149-
}
150-
151-
void resolveExtension(ExtensionDecl *ext) override {
152-
Principal.resolveExtension(ext);
153-
}
154-
155-
void resolveImplicitConstructors(NominalTypeDecl *nominal) override {
156-
Principal.resolveImplicitConstructors(nominal);
157-
}
158-
159-
void resolveImplicitMember(NominalTypeDecl *nominal, DeclName member) override {
160-
Principal.resolveImplicitMember(nominal, member);
161-
}
162-
163-
void markConformanceUsed(ProtocolConformanceRef conformance,
164-
DeclContext *dc) override {
165-
return Principal.markConformanceUsed(conformance, dc);
166-
}
167-
};
168-
169104
class LazyMemberLoader;
170105

171106
/// Context data for lazy deserialization.

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ STATISTIC(NumCollapsedSpecializedProtocolConformances,
6767
#define SWIFT_GSB_EXPENSIVE_ASSERTIONS 0
6868

6969
LazyResolver::~LazyResolver() = default;
70-
DelegatingLazyResolver::~DelegatingLazyResolver() = default;
7170
void ModuleLoader::anchor() {}
7271
void ClangModuleLoader::anchor() {}
7372

lib/Sema/TypeCheckNameLookup.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -539,28 +539,6 @@ static bool isLocInVarInit(TypeChecker &TC, VarDecl *var, SourceLoc loc) {
539539
return TC.Context.SourceMgr.rangeContainsTokenLoc(initRange, loc);
540540
}
541541

542-
namespace {
543-
class TypoCorrectionResolver : public DelegatingLazyResolver {
544-
TypeChecker &TC() { return static_cast<TypeChecker&>(Principal); }
545-
SourceLoc NameLoc;
546-
public:
547-
TypoCorrectionResolver(TypeChecker &TC, SourceLoc nameLoc)
548-
: DelegatingLazyResolver(TC), NameLoc(nameLoc) {}
549-
550-
void resolveDeclSignature(ValueDecl *VD) override {
551-
if (VD->isInvalid() || VD->hasInterfaceType()) return;
552-
553-
// Don't process a variable if we're within its initializer.
554-
if (auto var = dyn_cast<VarDecl>(VD)) {
555-
if (isLocInVarInit(TC(), var, NameLoc))
556-
return;
557-
}
558-
559-
DelegatingLazyResolver::resolveDeclSignature(VD);
560-
}
561-
};
562-
} // end anonymous namespace
563-
564542
void TypeChecker::performTypoCorrection(DeclContext *DC, DeclRefKind refKind,
565543
Type baseTypeOrNull,
566544
DeclName targetDeclName,
@@ -608,12 +586,11 @@ void TypeChecker::performTypoCorrection(DeclContext *DC, DeclRefKind refKind,
608586
entries.insert(distance, std::move(decl));
609587
});
610588

611-
TypoCorrectionResolver resolver(*this, nameLoc);
612589
if (baseTypeOrNull) {
613-
lookupVisibleMemberDecls(consumer, baseTypeOrNull, DC, &resolver,
590+
lookupVisibleMemberDecls(consumer, baseTypeOrNull, DC, this,
614591
/*include instance members*/ true, gsb);
615592
} else {
616-
lookupVisibleDecls(consumer, DC, &resolver, /*top level*/ true, nameLoc);
593+
lookupVisibleDecls(consumer, DC, this, /*top level*/ true, nameLoc);
617594
}
618595

619596
// Impose a maximum distance from the best score.

0 commit comments

Comments
 (0)