Skip to content

Commit 7476430

Browse files
committed
Remove validateDeclForNameLookup and related logic
1 parent 95a8d08 commit 7476430

File tree

5 files changed

+5
-117
lines changed

5 files changed

+5
-117
lines changed

lib/Sema/CalleeCandidateInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
594594
CS.DC, instanceType, NameLookupFlags::IgnoreAccessControl);
595595
for (auto ctor : ctors) {
596596
if (!ctor.getValueDecl()->hasInterfaceType())
597-
CS.getTypeChecker().validateDeclForNameLookup(ctor.getValueDecl());
597+
CS.getTypeChecker().validateDecl(ctor.getValueDecl());
598598
if (ctor.getValueDecl()->hasInterfaceType())
599599
candidates.push_back({ ctor.getValueDecl(), 1 });
600600
}

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ bool swift::isValidDynamicCallableMethod(FuncDecl *decl, DeclContext *DC,
10691069
// `ExpressibleByStringLiteral`.
10701070
// `D.Value` and the return type can be arbitrary.
10711071

1072-
TC.validateDeclForNameLookup(decl);
1072+
TC.validateDecl(decl);
10731073
auto paramList = decl->getParameters();
10741074
if (paramList->size() != 1 || paramList->get(0)->isVariadic()) return false;
10751075
auto argType = paramList->get(0)->getType();
@@ -1235,7 +1235,7 @@ visitDynamicMemberLookupAttr(DynamicMemberLookupAttr *attr) {
12351235
auto oneCandidate = candidates.front();
12361236
candidates.filter([&](LookupResultEntry entry, bool isOuter) -> bool {
12371237
auto cand = cast<SubscriptDecl>(entry.getValueDecl());
1238-
TC.validateDeclForNameLookup(cand);
1238+
TC.validateDecl(cand);
12391239
return isValidDynamicMemberLookupSubscript(cand, decl, TC);
12401240
});
12411241

lib/Sema/TypeCheckDecl.cpp

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,33 +3772,6 @@ void TypeChecker::validateDecl(ValueDecl *D) {
37723772
validateGenericTypeSignature(proto);
37733773
proto->setSignatureIsValidated();
37743774

3775-
// See the comment in validateDeclForNameLookup(); we may have validated
3776-
// the alias before we built the protocol's generic environment.
3777-
//
3778-
// FIXME: Hopefully this can all go away with the ITC.
3779-
for (auto member : proto->getMembers()) {
3780-
if (auto *aliasDecl = dyn_cast<TypeAliasDecl>(member)) {
3781-
if (!aliasDecl->isGeneric()) {
3782-
aliasDecl->setGenericEnvironment(proto->getGenericEnvironment());
3783-
3784-
// The generic environment didn't exist until now, we may have
3785-
// unresolved types we will need to deal with, and need to record the
3786-
// appropriate substitutions for that environment. Wipe out the types
3787-
// and validate them again.
3788-
aliasDecl->getUnderlyingTypeLoc().setType(Type());
3789-
aliasDecl->setInterfaceType(Type());
3790-
3791-
// Check generic parameters, if needed.
3792-
if (aliasDecl->hasValidationStarted()) {
3793-
validateTypealiasType(*this, aliasDecl);
3794-
} else {
3795-
DeclValidationRAII IBV(aliasDecl);
3796-
validateTypealiasType(*this, aliasDecl);
3797-
}
3798-
}
3799-
}
3800-
}
3801-
38023775
break;
38033776
}
38043777

@@ -4103,88 +4076,6 @@ void TypeChecker::validateDecl(ValueDecl *D) {
41034076
assert(D->hasValidSignature());
41044077
}
41054078

4106-
void TypeChecker::validateDeclForNameLookup(ValueDecl *D) {
4107-
// Validate the context.
4108-
auto dc = D->getDeclContext();
4109-
if (auto nominal = dyn_cast<NominalTypeDecl>(dc)) {
4110-
validateDeclForNameLookup(nominal);
4111-
if (!nominal->hasInterfaceType())
4112-
return;
4113-
} else if (auto ext = dyn_cast<ExtensionDecl>(dc)) {
4114-
validateExtension(ext);
4115-
if (!ext->hasValidSignature())
4116-
return;
4117-
}
4118-
4119-
switch (D->getKind()) {
4120-
case DeclKind::Protocol: {
4121-
auto proto = cast<ProtocolDecl>(D);
4122-
if (proto->hasInterfaceType())
4123-
return;
4124-
proto->computeType();
4125-
4126-
break;
4127-
}
4128-
case DeclKind::AssociatedType: {
4129-
auto assocType = cast<AssociatedTypeDecl>(D);
4130-
if (assocType->hasInterfaceType())
4131-
return;
4132-
assocType->computeType();
4133-
break;
4134-
}
4135-
case DeclKind::TypeAlias: {
4136-
auto typealias = cast<TypeAliasDecl>(D);
4137-
if (typealias->getUnderlyingTypeLoc().getType())
4138-
return;
4139-
4140-
// Perform earlier validation of typealiases in protocols.
4141-
if (isa<ProtocolDecl>(dc)) {
4142-
if (!typealias->getGenericParams()) {
4143-
if (typealias->isBeingValidated()) return;
4144-
4145-
auto helper = [&] {
4146-
TypeResolutionOptions options(
4147-
(typealias->getGenericParams() ?
4148-
TypeResolverContext::GenericTypeAliasDecl :
4149-
TypeResolverContext::TypeAliasDecl));
4150-
auto &underlyingTL = typealias->getUnderlyingTypeLoc();
4151-
if (underlyingTL.isNull() ||
4152-
validateType(underlyingTL,
4153-
TypeResolution::forStructural(typealias), options)) {
4154-
typealias->setInvalid();
4155-
underlyingTL.setInvalidType(Context);
4156-
}
4157-
4158-
typealias->setUnderlyingType(underlyingTL.getType());
4159-
4160-
// Note that this doesn't set the generic environment of the alias yet,
4161-
// because we haven't built one for the protocol.
4162-
//
4163-
// See how validateDecl() sets the generic environment on alias members
4164-
// explicitly.
4165-
//
4166-
// FIXME: Hopefully this can all go away with the ITC.
4167-
};
4168-
4169-
if (typealias->hasValidationStarted()) {
4170-
helper();
4171-
} else {
4172-
DeclValidationRAII IBV(typealias);
4173-
helper();
4174-
}
4175-
4176-
return;
4177-
}
4178-
}
4179-
LLVM_FALLTHROUGH;
4180-
}
4181-
4182-
default:
4183-
validateDecl(D);
4184-
break;
4185-
}
4186-
}
4187-
41884079
llvm::Expected<DeclRange>
41894080
EmittedMembersRequest::evaluate(Evaluator &evaluator,
41904081
ClassDecl *CD) const {

lib/Sema/TypeCheckPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ bool TypeChecker::coercePatternToType(Pattern *&P, TypeResolution resolution,
14971497
}
14981498

14991499
// If there is a subpattern, push the enum element type down onto it.
1500-
validateDeclForNameLookup(elt);
1500+
validateDecl(elt);
15011501
if (EEP->hasSubPattern()) {
15021502
Pattern *sub = EEP->getSubPattern();
15031503
if (!elt->hasAssociatedValues()) {

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,6 @@ class TypeChecker final : public LazyResolver {
788788
void validateDecl(OperatorDecl *decl);
789789
void validateDecl(PrecedenceGroupDecl *decl);
790790

791-
/// Perform just enough validation for looking up names using the Decl.
792-
void validateDeclForNameLookup(ValueDecl *D);
793-
794791
/// Validate the given extension declaration, ensuring that it
795792
/// properly extends the nominal type it names.
796793
void validateExtension(ExtensionDecl *ext);
@@ -999,7 +996,7 @@ class TypeChecker final : public LazyResolver {
999996
void checkDefaultArguments(ParameterList *params, ValueDecl *VD);
1000997

1001998
virtual void resolveDeclSignature(ValueDecl *VD) override {
1002-
validateDeclForNameLookup(VD);
999+
validateDecl(VD);
10031000
}
10041001

10051002
virtual void resolveProtocolEnvironment(ProtocolDecl *proto) override {

0 commit comments

Comments
 (0)