Skip to content

Commit b135928

Browse files
committed
Drop CheckingWithValidSignature from the validation state machine
Now that the generic signature is computable on demand, this predicate is doubly useless. All of the callers intended to ask "hasInterfaceType" anyways.
1 parent ae60618 commit b135928

17 files changed

+34
-70
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.

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/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/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());

0 commit comments

Comments
 (0)