Skip to content

Commit 7f036f4

Browse files
authored
Merge pull request #27289 from CodaFi/ah-well-on-to-the-next-one
Remove resolveExtension and validateExtension
2 parents 340bbe9 + b135928 commit 7f036f4

22 files changed

+81
-131
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ class alignas(1 << DeclAlignInBits) Decl {
279279
enum class ValidationState {
280280
Unchecked,
281281
Checking,
282-
CheckingWithValidSignature,
283282
Checked,
284283
};
285284

@@ -850,19 +849,11 @@ class alignas(1 << DeclAlignInBits) Decl {
850849
case ValidationState::Checked:
851850
return false;
852851
case ValidationState::Checking:
853-
case ValidationState::CheckingWithValidSignature:
854852
return true;
855853
}
856854
llvm_unreachable("Unknown ValidationState");
857855
}
858856

859-
/// Update the validation state for the declaration to allow access to the
860-
/// generic signature.
861-
void setSignatureIsValidated() {
862-
assert(getValidationState() == ValidationState::Checking);
863-
setValidationState(ValidationState::CheckingWithValidSignature);
864-
}
865-
866857
bool hasValidationStarted() const {
867858
return getValidationState() > ValidationState::Unchecked;
868859
}
@@ -1769,11 +1760,6 @@ class ExtensionDecl final : public GenericContext, public Decl,
17691760

17701761
void setInherited(MutableArrayRef<TypeLoc> i) { Inherited = i; }
17711762

1772-
/// Whether we have fully checked the extension signature.
1773-
bool hasValidSignature() const {
1774-
return getValidationState() > ValidationState::CheckingWithValidSignature;
1775-
}
1776-
17771763
bool hasDefaultAccessLevel() const {
17781764
return Bits.ExtensionDecl.DefaultAndMaxAccessLevel != 0;
17791765
}
@@ -2608,8 +2594,6 @@ class ValueDecl : public Decl {
26082594

26092595
/// Set the interface type for the given value.
26102596
void setInterfaceType(Type type);
2611-
2612-
bool hasValidSignature() const;
26132597

26142598
/// isInstanceMember - Determine whether this value is an instance member
26152599
/// of an enum or protocol.

include/swift/AST/LazyResolver.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ class LazyResolver {
6060
/// consistency and provides the value a type.
6161
virtual void resolveDeclSignature(ValueDecl *VD) = 0;
6262

63-
/// Resolve the type of an extension.
64-
///
65-
/// This can be called to ensure that the members of an extension can be
66-
/// considered to be members of the extended type.
67-
virtual void resolveExtension(ExtensionDecl *ext) = 0;
68-
6963
/// Resolve any implicitly-declared constructors within the given nominal.
7064
virtual void resolveImplicitConstructors(NominalTypeDecl *nominal) = 0;
7165

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2968,7 +2968,7 @@ class Verifier : public ASTWalker {
29682968
void verifyChecked(AbstractFunctionDecl *AFD) {
29692969
PrettyStackTraceDecl debugStack("verifying AbstractFunctionDecl", AFD);
29702970

2971-
if (!AFD->hasValidSignature()) {
2971+
if (!AFD->hasInterfaceType()) {
29722972
if (isa<AccessorDecl>(AFD) && AFD->isImplicit())
29732973
return;
29742974

lib/AST/ConformanceLookupTable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@ ConformanceLookupTable::getConformance(NominalTypeDecl *nominal,
798798
// Everything about this conformance is nailed down, so we can now ensure that
799799
// the extension is fully resolved.
800800
if (auto resolver = nominal->getASTContext().getLazyResolver()) {
801-
if (auto ED = dyn_cast<ExtensionDecl>(conformingDC)) {
802-
resolver->resolveExtension(ED);
801+
if (auto ext = dyn_cast<ExtensionDecl>(conformingDC)) {
802+
resolver->resolveDeclSignature(ext->getExtendedNominal());
803803
} else {
804804
resolver->resolveDeclSignature(cast<NominalTypeDecl>(conformingDC));
805805
}

lib/AST/Decl.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,14 +2720,6 @@ void ValueDecl::setInterfaceType(Type type) {
27202720
TypeAndAccess.setPointer(type);
27212721
}
27222722

2723-
bool ValueDecl::hasValidSignature() const {
2724-
if (!hasInterfaceType())
2725-
return false;
2726-
// FIXME -- The build blows up if the correct code is used:
2727-
// return getValidationState() > ValidationState::CheckingWithValidSignature;
2728-
return getValidationState() != ValidationState::Checking;
2729-
}
2730-
27312723
Optional<ObjCSelector> ValueDecl::getObjCRuntimeName(
27322724
bool skipIsObjCResolution) const {
27332725
if (auto func = dyn_cast<AbstractFunctionDecl>(this))

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,8 @@ CanType TypeBase::computeCanonicalType() {
10981098
assert(resolver && "Need to resolve generic parameter depth");
10991099
if (auto decl =
11001100
gpDecl->getDeclContext()->getInnermostDeclarationDeclContext())
1101-
if (auto valueDecl = dyn_cast<ValueDecl>(decl))
1102-
resolver->resolveDeclSignature(valueDecl);
1101+
if (auto valueDecl = decl->getAsGenericContext())
1102+
(void)valueDecl->getGenericSignature();
11031103
}
11041104

11051105
assert(gpDecl->getDepth() != GenericTypeParamDecl::InvalidDepth &&

lib/IDE/CodeCompletion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
20462046
auto *GenericSig = VD->getInnermostDeclContext()
20472047
->getGenericSignatureOfContext();
20482048

2049-
assert(VD->hasValidSignature());
2049+
assert(VD->hasInterfaceType());
20502050
Type T = VD->getInterfaceType();
20512051

20522052
if (ExprType) {
@@ -2135,7 +2135,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
21352135
addValueBaseName(Builder, Name);
21362136
setClangDeclKeywords(VD, Pairs, Builder);
21372137

2138-
if (!VD->hasValidSignature())
2138+
if (!VD->hasInterfaceType())
21392139
return;
21402140

21412141
// Add a type annotation.

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ DeclContext *FailureDiagnosis::findDeclContext(Expr *subExpr) const {
13291329
// variables would be accessible to name lookup of the subexpression and
13301330
// may thus leak in. Reset them to UnresolvedTypes for safe measures.
13311331
assert(llvm::all_of(*closure->getParameters(), [](const ParamDecl *PD) {
1332-
if (PD->hasValidSignature()) {
1332+
if (PD->hasInterfaceType()) {
13331333
auto paramTy = PD->getType();
13341334
return !(paramTy->hasTypeVariable() || paramTy->hasError());
13351335
}
@@ -5345,7 +5345,7 @@ diagnoseAmbiguousMultiStatementClosure(ClosureExpr *closure) {
53455345
if (auto DRE = dyn_cast<DeclRefExpr>(childExpr)) {
53465346
if (auto param = dyn_cast<ParamDecl>(DRE->getDecl())) {
53475347
auto paramType =
5348-
param->hasValidSignature() ? param->getType() : Type();
5348+
param->hasInterfaceType() ? param->getType() : Type();
53495349
if (!paramType || paramType->hasTypeVariable()) {
53505350
hasUnresolvedParams = true;
53515351
return nullptr;

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ bool TrailingClosureAmbiguityFailure::diagnoseAsNote() {
14731473
const ParamDecl *param = paramList->getArray().back();
14741474

14751475
// Sanity-check that the trailing closure corresponds to this parameter.
1476-
if (!param->hasValidSignature() ||
1476+
if (!param->hasInterfaceType() ||
14771477
!param->getInterfaceType()->is<AnyFunctionType>())
14781478
return false;
14791479

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@ static ConstraintFix *fixPropertyWrapperFailure(
21442144
};
21452145

21462146
auto applyFix = [&](Fix fix, VarDecl *decl, Type type) -> ConstraintFix * {
2147-
if (!decl->hasValidSignature() || !type)
2147+
if (!decl->hasInterfaceType() || !type)
21482148
return nullptr;
21492149

21502150
if (baseTy->isEqual(type))

lib/Sema/CalleeCandidateInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ OverloadCandidate::OverloadCandidate(ValueDecl *decl, bool skipCurriedSelf)
6161
: declOrExpr(decl), skipCurriedSelf(skipCurriedSelf), substituted(false) {
6262

6363
if (auto *PD = dyn_cast<ParamDecl>(decl)) {
64-
if (PD->hasValidSignature())
64+
if (PD->hasInterfaceType())
6565
entityType = PD->getType();
6666
else
6767
entityType = PD->getASTContext().TheUnresolvedType;

lib/Sema/CodeSynthesis.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ synthesizeDesignatedInitOverride(AbstractFunctionDecl *fn, void *context) {
540540

541541
auto *superclassCtor = (ConstructorDecl *) context;
542542

543-
if (!superclassCtor->hasValidSignature())
543+
if (!superclassCtor->hasInterfaceType())
544544
ctx.getLazyResolver()->resolveDeclSignature(superclassCtor);
545545

546546
// Reference to super.init.
@@ -856,9 +856,9 @@ static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
856856
if (!var->isMemberwiseInitialized(/*preferDeclaredProperties=*/true))
857857
continue;
858858

859-
if (!var->hasValidSignature())
859+
if (!var->hasInterfaceType())
860860
ctx.getLazyResolver()->resolveDeclSignature(var);
861-
if (!var->hasValidSignature())
861+
if (!var->hasInterfaceType())
862862
return;
863863
}
864864
}
@@ -923,9 +923,9 @@ static void addImplicitConstructorsToClass(ClassDecl *decl, ASTContext &ctx) {
923923
if (!decl->hasClangNode()) {
924924
for (auto member : decl->getMembers()) {
925925
if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
926-
if (!ctor->hasValidSignature())
926+
if (!ctor->hasInterfaceType())
927927
ctx.getLazyResolver()->resolveDeclSignature(ctor);
928-
if (!ctor->hasValidSignature())
928+
if (!ctor->hasInterfaceType())
929929
return;
930930
}
931931
}
@@ -1081,7 +1081,7 @@ static void addImplicitConstructorsToClass(ClassDecl *decl, ASTContext &ctx) {
10811081

10821082
// We have a designated initializer. Create an override of it.
10831083
// FIXME: Validation makes sure we get a generic signature here.
1084-
if (!decl->hasValidSignature())
1084+
if (!decl->hasInterfaceType())
10851085
ctx.getLazyResolver()->resolveDeclSignature(decl);
10861086

10871087
if (auto ctor = createDesignatedInitOverride(

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ Type ConstraintSystem::getUnopenedTypeOfReference(VarDecl *value, Type baseType,
819819
if (auto *param = dyn_cast<ParamDecl>(var))
820820
return getType(param);
821821

822-
if (!var->hasValidSignature()) {
822+
if (!var->hasInterfaceType()) {
823823
if (!var->isInvalid()) {
824824
TC.diagnose(var->getLoc(), diag::recursive_decl_reference,
825825
var->getDescriptiveKind(), var->getName());

lib/Sema/IDETypeCheckingRequests.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ static bool isExtensionAppliedInternal(const DeclContext *DC, Type BaseTy,
5656
if (!ED->isConstrainedExtension())
5757
return true;
5858

59-
TypeChecker *TC = &TypeChecker::createForContext((DC->getASTContext()));
60-
TC->validateExtension(const_cast<ExtensionDecl *>(ED));
61-
59+
(void)TypeChecker::createForContext(DC->getASTContext());
6260
GenericSignature *genericSig = ED->getGenericSignature();
6361
SubstitutionMap substMap = BaseTy->getContextSubstitutionMap(
6462
DC->getParentModule(), ED->getExtendedNominal());

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ static bool hasSingleNonVariadicParam(SubscriptDecl *decl,
11511151
return false;
11521152

11531153
auto *index = indices->get(0);
1154-
if (index->isVariadic() || !index->hasValidSignature())
1154+
if (index->isVariadic() || !index->hasInterfaceType())
11551155
return false;
11561156

11571157
if (ignoreLabel) {

0 commit comments

Comments
 (0)