Skip to content

Commit f053f9c

Browse files
committed
Port getInterfaceType() patterns in libSema
1 parent ed18f47 commit f053f9c

34 files changed

+162
-291
lines changed

lib/Sema/CSApply.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,8 @@ namespace {
17401740
return nullptr;
17411741
}
17421742

1743-
tc.validateDecl(fn);
1743+
// FIXME(InterfaceTypeRequest): Remove this.
1744+
(void)fn->getInterfaceType();
17441745

17451746
// Form a reference to the function. The bridging operations are generic,
17461747
// so we need to form substitutions and compute the resulting type.
@@ -1926,7 +1927,8 @@ namespace {
19261927
return nullptr;
19271928
}
19281929

1929-
tc.validateDecl(maxFloatTypeDecl);
1930+
// FIXME(InterfaceTypeRequest): Remove this.
1931+
(void)maxFloatTypeDecl->getInterfaceType();
19301932
auto maxType = maxFloatTypeDecl->getUnderlyingType();
19311933

19321934
DeclName initName(tc.Context, DeclBaseName::createConstructor(),
@@ -4116,7 +4118,8 @@ namespace {
41164118
assert(method && "Didn't find a method?");
41174119

41184120
// The declaration we found must be exposed to Objective-C.
4119-
tc.validateDecl(method);
4121+
// FIXME(InterfaceTypeRequest): Remove this.
4122+
(void)method->getInterfaceType();
41204123
if (!method->isObjC()) {
41214124
// If the method declaration lies in a protocol and we're providing
41224125
// a default implementation of the method through a protocol extension

lib/Sema/CSDiag.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,8 +4300,6 @@ static bool diagnoseKeyPathComponents(ConstraintSystem &CS, KeyPathExpr *KPE,
43004300

43014301
// Handle property references.
43024302
if (auto var = dyn_cast<VarDecl>(found)) {
4303-
TC.validateDecl(var);
4304-
43054303
// Resolve this component to the variable we found.
43064304
auto varRef = ConcreteDeclRef(var);
43074305
auto resolved =

lib/Sema/CSGen.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,8 @@ namespace {
962962
if (!decl)
963963
return nullptr;
964964

965-
CS.getTypeChecker().validateDecl(decl);
965+
// FIXME(InterfaceTypeRequest): isInvalid() should be based on the interface type.
966+
(void)decl->getInterfaceType();
966967
if (decl->isInvalid())
967968
return nullptr;
968969

@@ -1310,9 +1311,9 @@ namespace {
13101311
// FIXME: If the decl is in error, we get no information from this.
13111312
// We may, alternatively, want to use a type variable in that case,
13121313
// and possibly infer the type of the variable that way.
1313-
CS.getTypeChecker().validateDecl(E->getDecl());
1314+
auto oldInterfaceTy = E->getDecl()->getInterfaceType();
13141315
if (E->getDecl()->isInvalid()) {
1315-
CS.setType(E, E->getDecl()->getInterfaceType());
1316+
CS.setType(E, oldInterfaceTy);
13161317
return nullptr;
13171318
}
13181319

@@ -1425,7 +1426,8 @@ namespace {
14251426
// If the result is invalid, skip it.
14261427
// FIXME: Note this as invalid, in case we don't find a solution,
14271428
// so we don't let errors cascade further.
1428-
CS.getTypeChecker().validateDecl(decls[i]);
1429+
// FIXME(InterfaceTypeRequest): isInvalid() should be based on the interface type.
1430+
(void)decls[i]->getInterfaceType();
14291431
if (decls[i]->isInvalid())
14301432
continue;
14311433

@@ -1983,7 +1985,6 @@ namespace {
19831985
if (dictionaryKeyTy->isTypeVariableOrMember() &&
19841986
tc.Context.getAnyHashableDecl()) {
19851987
auto anyHashable = tc.Context.getAnyHashableDecl();
1986-
tc.validateDecl(anyHashable);
19871988
CS.addConstraint(ConstraintKind::Defaultable, dictionaryKeyTy,
19881989
anyHashable->getDeclaredInterfaceType(), locator);
19891990
}

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4696,7 +4696,8 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
46964696
auto decl = candidate.getDecl();
46974697

46984698
// If the result is invalid, skip it.
4699-
TC.validateDecl(decl);
4699+
// FIXME(InterfaceTypeRequest): isInvalid() should be based on the interface type.
4700+
(void)decl->getInterfaceType();
47004701
if (decl->isInvalid()) {
47014702
result.markErrorAlreadyDiagnosed();
47024703
return;
@@ -5070,7 +5071,8 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
50705071
auto *cand = entry.getValueDecl();
50715072

50725073
// If the result is invalid, skip it.
5073-
TC.validateDecl(cand);
5074+
// FIXME(InterfaceTypeRequest): isInvalid() should be based on the interface type.
5075+
(void)cand->getInterfaceType();
50745076
if (cand->isInvalid()) {
50755077
result.markErrorAlreadyDiagnosed();
50765078
return result;
@@ -7000,7 +7002,8 @@ ConstraintSystem::simplifyDynamicCallableApplicableFnConstraint(
70007002
// Record the 'dynamicallyCall` method overload set.
70017003
SmallVector<OverloadChoice, 4> choices;
70027004
for (auto candidate : candidates) {
7003-
TC.validateDecl(candidate);
7005+
// FIXME(InterfaceTypeRequest): isInvalid() should be based on the interface type.
7006+
(void)candidate->getInterfaceType();
70047007
if (candidate->isInvalid()) continue;
70057008
choices.push_back(
70067009
OverloadChoice(type2, candidate, FunctionRefKind::SingleApply));

lib/Sema/CalleeCandidateInfo.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
593593
auto ctors = TypeChecker::lookupConstructors(
594594
CS.DC, instanceType, NameLookupFlags::IgnoreAccessControl);
595595
for (auto ctor : ctors) {
596-
if (!ctor.getValueDecl()->hasInterfaceType())
597-
CS.getTypeChecker().validateDecl(ctor.getValueDecl());
598-
if (ctor.getValueDecl()->hasInterfaceType())
596+
if (ctor.getValueDecl()->getInterfaceType())
599597
candidates.push_back({ ctor.getValueDecl(), 1 });
600598
}
601599
}

lib/Sema/CodeSynthesis.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
213213

214214
accessLevel = std::min(accessLevel, var->getFormalAccess());
215215

216-
ctx.getLazyResolver()->resolveDeclSignature(var);
217216
auto varInterfaceType = var->getValueInterfaceType();
218217

219218
if (var->getAttrs().hasAttribute<LazyAttr>()) {
@@ -540,9 +539,6 @@ synthesizeDesignatedInitOverride(AbstractFunctionDecl *fn, void *context) {
540539

541540
auto *superclassCtor = (ConstructorDecl *) context;
542541

543-
if (!superclassCtor->hasInterfaceType())
544-
ctx.getLazyResolver()->resolveDeclSignature(superclassCtor);
545-
546542
// Reference to super.init.
547543
auto *selfDecl = ctor->getImplicitSelfDecl();
548544
auto *superRef = buildSelfReference(selfDecl, SelfAccessorKind::Super,
@@ -856,9 +852,7 @@ static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
856852
if (!var->isMemberwiseInitialized(/*preferDeclaredProperties=*/true))
857853
continue;
858854

859-
if (!var->hasInterfaceType())
860-
ctx.getLazyResolver()->resolveDeclSignature(var);
861-
if (!var->hasInterfaceType())
855+
if (!var->getInterfaceType())
862856
return;
863857
}
864858
}
@@ -923,9 +917,7 @@ static void addImplicitConstructorsToClass(ClassDecl *decl, ASTContext &ctx) {
923917
if (!decl->hasClangNode()) {
924918
for (auto member : decl->getMembers()) {
925919
if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
926-
if (!ctor->hasInterfaceType())
927-
ctx.getLazyResolver()->resolveDeclSignature(ctor);
928-
if (!ctor->hasInterfaceType())
920+
if (!ctor->getInterfaceType())
929921
return;
930922
}
931923
}

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,6 @@ Type ConstraintSystem::getEffectiveOverloadType(const OverloadChoice &overload,
14631463
// Retrieve the interface type.
14641464
auto type = decl->getInterfaceType();
14651465
if (!type) {
1466-
decl->getASTContext().getLazyResolver()->resolveDeclSignature(decl);
14671466
type = decl->getInterfaceType();
14681467
if (!type) {
14691468
return Type();

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,9 @@ static CodableConformanceType varConformsToCodable(TypeChecker &tc,
118118
// // hasn't yet been evaluated
119119
// }
120120
//
121-
// Validate the decl eagerly.
122-
if (!varDecl->hasInterfaceType())
123-
tc.validateDecl(varDecl);
124-
125121
// If the var decl didn't validate, it may still not have a type; confirm it
126122
// has a type before ensuring the type conforms to Codable.
127-
if (!varDecl->hasInterfaceType())
123+
if (!varDecl->getInterfaceType())
128124
return TypeNotValidated;
129125

130126
bool isIUO = varDecl->isImplicitlyUnwrappedOptional();
@@ -272,9 +268,6 @@ static CodingKeysValidity hasValidCodingKeysEnum(DerivedConformance &derived) {
272268
return CodingKeysValidity(/*hasType=*/true, /*isValid=*/false);
273269
}
274270

275-
// If the decl hasn't been validated yet, do so.
276-
tc.validateDecl(codingKeysTypeDecl);
277-
278271
// CodingKeys may be a typealias. If so, follow the alias to its canonical
279272
// type.
280273
auto codingKeysType = codingKeysTypeDecl->getDeclaredInterfaceType();

lib/Sema/DerivedConformanceCodingKey.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl, void *) {
333333
static bool canSynthesizeCodingKey(DerivedConformance &derived) {
334334
auto enumDecl = cast<EnumDecl>(derived.Nominal);
335335
// Validate the enum and its raw type.
336-
derived.TC.validateDecl(enumDecl);
337-
336+
// FIXME(InterfaceTypeRequest): Remove this.
337+
(void)enumDecl->getInterfaceType();
338+
338339
// If the enum has a raw type (optional), it must be String or Int.
339340
Type rawType = enumDecl->getRawType();
340341
if (rawType) {

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ enum NonconformingMemberKind {
4545
static SmallVector<ParamDecl *, 3>
4646
associatedValuesNotConformingToProtocol(DeclContext *DC, EnumDecl *theEnum,
4747
ProtocolDecl *protocol) {
48-
auto lazyResolver = DC->getASTContext().getLazyResolver();
4948
SmallVector<ParamDecl *, 3> nonconformingAssociatedValues;
5049
for (auto elt : theEnum->getAllElements()) {
51-
if (!elt->hasInterfaceType())
52-
lazyResolver->resolveDeclSignature(elt);
53-
50+
if (!elt->getInterfaceType())
51+
continue;
52+
5453
auto PL = elt->getParameterList();
5554
if (!PL)
5655
continue;
@@ -85,19 +84,15 @@ static bool allAssociatedValuesConformToProtocol(DeclContext *DC,
8584
static SmallVector<VarDecl *, 3>
8685
storedPropertiesNotConformingToProtocol(DeclContext *DC, StructDecl *theStruct,
8786
ProtocolDecl *protocol) {
88-
auto lazyResolver = DC->getASTContext().getLazyResolver();
8987
auto storedProperties = theStruct->getStoredProperties();
9088
SmallVector<VarDecl *, 3> nonconformingProperties;
9189
for (auto propertyDecl : storedProperties) {
9290
if (!propertyDecl->isUserAccessible())
9391
continue;
9492

95-
if (!propertyDecl->hasInterfaceType())
96-
lazyResolver->resolveDeclSignature(propertyDecl);
97-
if (!propertyDecl->hasInterfaceType())
98-
nonconformingProperties.push_back(propertyDecl);
99-
10093
auto type = propertyDecl->getValueInterfaceType();
94+
if (!type)
95+
nonconformingProperties.push_back(propertyDecl);
10196

10297
if (!TypeChecker::conformsToProtocol(DC->mapTypeIntoContext(type), protocol,
10398
DC, None)) {
@@ -1169,9 +1164,6 @@ deriveBodyHashable_hashValue(AbstractFunctionDecl *hashValueDecl, void *) {
11691164

11701165
// _hashValue(for:)
11711166
auto *hashFunc = C.getHashValueForDecl();
1172-
if (!hashFunc->hasInterfaceType())
1173-
static_cast<TypeChecker *>(C.getLazyResolver())->validateDecl(hashFunc);
1174-
11751167
auto substitutions = SubstitutionMap::get(
11761168
hashFunc->getGenericSignature(),
11771169
[&](SubstitutableType *dependentType) {

0 commit comments

Comments
 (0)