Skip to content

Commit 94c6bff

Browse files
committed
AST: Replace some calls to getDeclaredType() with getDeclaredInterfaceType()
1 parent 22409d7 commit 94c6bff

10 files changed

+29
-26
lines changed

lib/AST/ASTContext.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ FuncDecl *ASTContext::getSequenceMakeIterator() const {
772772

773773
CanType ASTContext::getExceptionType() const {
774774
if (auto exn = getErrorDecl()) {
775-
return exn->getDeclaredType()->getCanonicalType();
775+
return exn->getDeclaredInterfaceType()->getCanonicalType();
776776
} else {
777777
// Use Builtin.NativeObject just as a stand-in.
778778
return TheNativeObjectType;
@@ -864,7 +864,7 @@ CanType ASTContext::getNeverType() const {
864864
auto neverDecl = getNeverDecl();
865865
if (!neverDecl)
866866
return CanType();
867-
return neverDecl->getDeclaredType()->getCanonicalType();
867+
return neverDecl->getDeclaredInterfaceType()->getCanonicalType();
868868
}
869869

870870
#define KNOWN_OBJC_TYPE_DECL(MODULE, NAME, DECLTYPE) \
@@ -1073,7 +1073,7 @@ ASTContext::getBuiltinInitDecl(NominalTypeDecl *decl,
10731073
if (witness)
10741074
return witness;
10751075

1076-
auto type = decl->getDeclaredType();
1076+
auto type = decl->getDeclaredInterfaceType();
10771077
auto builtinProtocol = getProtocol(builtinProtocolKind);
10781078
auto builtinConformance = getStdlibModule()->lookupConformance(
10791079
type, builtinProtocol);
@@ -1102,12 +1102,12 @@ FuncDecl *getBinaryComparisonOperatorIntDecl(const ASTContext &C, StringRef op,
11021102
if (!C.getIntDecl() || !C.getBoolDecl())
11031103
return nullptr;
11041104

1105-
auto intType = C.getIntDecl()->getDeclaredType();
1105+
auto intType = C.getIntDecl()->getDeclaredInterfaceType();
11061106
auto isIntParam = [&](AnyFunctionType::Param param) {
11071107
return (!param.isVariadic() && !param.isInOut() &&
11081108
param.getPlainType()->isEqual(intType));
11091109
};
1110-
auto boolType = C.getBoolDecl()->getDeclaredType();
1110+
auto boolType = C.getBoolDecl()->getDeclaredInterfaceType();
11111111
auto decl = lookupOperatorFunc(C, op, intType,
11121112
[=](FunctionType *type) {
11131113
// Check for the signature: (Int, Int) -> Bool
@@ -4264,7 +4264,7 @@ ASTContext::getForeignRepresentationInfo(NominalTypeDecl *nominal,
42644264
if (auto objcBridgeable
42654265
= getProtocol(KnownProtocolKind::ObjectiveCBridgeable)) {
42664266
auto conformance = dc->getParentModule()->lookupConformance(
4267-
nominal->getDeclaredType(), objcBridgeable);
4267+
nominal->getDeclaredInterfaceType(), objcBridgeable);
42684268
if (conformance) {
42694269
result =
42704270
ForeignRepresentationInfo::forBridged(conformance.getConcrete());

lib/AST/ASTDemangler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Type ASTBuilder::createNominalType(GenericTypeDecl *decl, Type parent) {
153153
bool isImported = nominalDecl->hasClangNode() ||
154154
nominalDecl->getAttrs().hasAttribute<ClangImporterSynthesizedTypeAttr>();
155155
if (isImported && !nominalDecl->isGenericContext())
156-
return nominalDecl->getDeclaredType();
156+
return nominalDecl->getDeclaredInterfaceType();
157157

158158
// Validate the parent type.
159159
if (!validateParentType(nominalDecl, parent))
@@ -572,7 +572,7 @@ Type ASTBuilder::createProtocolCompositionType(
572572
bool isClassBound) {
573573
std::vector<Type> members;
574574
for (auto protocol : protocols)
575-
members.push_back(protocol->getDeclaredType());
575+
members.push_back(protocol->getDeclaredInterfaceType());
576576
if (superclass && superclass->getClassOrBoundGenericClass())
577577
members.push_back(superclass);
578578
return ProtocolCompositionType::get(Ctx, members, isClassBound);

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5045,7 +5045,7 @@ swift::getInheritedForPrinting(const Decl *decl, const PrintOptions &options,
50455045
isa<EnumDecl>(decl) &&
50465046
cast<EnumDecl>(decl)->hasRawType())
50475047
continue;
5048-
Results.push_back(TypeLoc::withoutLoc(proto->getDeclaredType()));
5048+
Results.push_back(TypeLoc::withoutLoc(proto->getDeclaredInterfaceType()));
50495049
}
50505050
}
50515051
}

lib/AST/ASTVerifier.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,8 @@ class Verifier : public ASTWalker {
10401040
case StmtConditionElement::CK_Boolean: {
10411041
auto *E = elt.getBoolean();
10421042
if (shouldVerifyChecked(E))
1043-
checkSameType(E->getType(), Ctx.getBoolDecl()->getDeclaredType(),
1043+
checkSameType(E->getType(),
1044+
Ctx.getBoolDecl()->getDeclaredInterfaceType(),
10441045
"condition type");
10451046
break;
10461047
}
@@ -1633,7 +1634,8 @@ class Verifier : public ASTWalker {
16331634
abort();
16341635
}
16351636

1636-
checkSameType(E->getType(), anyHashableDecl->getDeclaredType(),
1637+
checkSameType(E->getType(),
1638+
anyHashableDecl->getDeclaredInterfaceType(),
16371639
"AnyHashableErasureExpr and the standard AnyHashable type");
16381640

16391641
if (E->getConformance().getRequirement() != hashableDecl) {
@@ -3355,7 +3357,7 @@ class Verifier : public ASTWalker {
33553357

33563358
Type checkExceptionTypeExists(const char *where) {
33573359
auto exn = Ctx.getErrorDecl();
3358-
if (exn) return exn->getDeclaredType();
3360+
if (exn) return exn->getDeclaredInterfaceType();
33593361

33603362
Out << "exception type does not exist in " << where << "\n";
33613363
abort();

lib/AST/AutoDiff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ GenericSignature autodiff::getConstrainedDerivativeGenericSignature(
282282
// Require differentiability parameters to conform to `Differentiable`.
283283
auto paramType = originalFnTy->getParameters()[paramIdx].getInterfaceType();
284284
Requirement req(RequirementKind::Conformance, paramType,
285-
diffableProto->getDeclaredType());
285+
diffableProto->getDeclaredInterfaceType());
286286
requirements.push_back(req);
287287
if (isTranspose) {
288288
// Require linearity parameters to additionally satisfy

lib/AST/Builtins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ namespace {
496496
void addConformanceRequirement(const G &generator, ProtocolDecl *proto) {
497497
Requirement req(RequirementKind::Conformance,
498498
generator.build(*this),
499-
proto->getDeclaredType());
499+
proto->getDeclaredInterfaceType());
500500
addedRequirements.push_back(req);
501501
}
502502

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5068,7 +5068,7 @@ class GenericSignatureBuilder::InferRequirementsWalker : public TypeWalker {
50685068
if (differentiableProtocol && fnTy->isDifferentiable()) {
50695069
auto addConformanceConstraint = [&](Type type, ProtocolDecl *protocol) {
50705070
Requirement req(RequirementKind::Conformance, type,
5071-
protocol->getDeclaredType());
5071+
protocol->getDeclaredInterfaceType());
50725072
Builder.addRequirement(req, source, nullptr);
50735073
};
50745074
auto addSameTypeConstraint = [&](Type firstType,

lib/AST/NameLookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,7 +2323,7 @@ GenericParamListRequest::evaluate(Evaluator &evaluator, GenericContext *value) c
23232323
// Protocol extensions need an inheritance clause due to how name lookup
23242324
// is implemented.
23252325
if (auto *proto = ext->getExtendedProtocolDecl()) {
2326-
auto protoType = proto->getDeclaredType();
2326+
auto protoType = proto->getDeclaredInterfaceType();
23272327
TypeLoc selfInherited[1] = { TypeLoc::withoutLoc(protoType) };
23282328
genericParams->getParams().front()->setInherited(
23292329
ctx.AllocateCopy(selfInherited));
@@ -2343,7 +2343,7 @@ GenericParamListRequest::evaluate(Evaluator &evaluator, GenericContext *value) c
23432343
auto selfId = ctx.Id_Self;
23442344
auto selfDecl = new (ctx) GenericTypeParamDecl(
23452345
proto, selfId, SourceLoc(), /*depth=*/0, /*index=*/0);
2346-
auto protoType = proto->getDeclaredType();
2346+
auto protoType = proto->getDeclaredInterfaceType();
23472347
TypeLoc selfInherited[1] = { TypeLoc::withoutLoc(protoType) };
23482348
selfDecl->setInherited(ctx.AllocateCopy(selfInherited));
23492349
selfDecl->setImplicit();

lib/AST/SubstitutionMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
337337
for (auto reqt : genericSig->getRequirements()) {
338338
if (reqt.getKind() == RequirementKind::Conformance) {
339339
if (reqt.getFirstType()->isEqual(type) &&
340-
reqt.getSecondType()->isEqual(proto->getDeclaredType()))
340+
reqt.getSecondType()->isEqual(proto->getDeclaredInterfaceType()))
341341
return getConformances()[index];
342342

343343
++index;

lib/AST/Type.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,8 @@ addMinimumProtocols(Type T, SmallVectorImpl<ProtocolDecl *> &Protocols,
10311031
if (Visited.insert(Proto->getDecl()).second) {
10321032
Stack.push_back(Proto->getDecl());
10331033
for (auto Inherited : Proto->getDecl()->getInheritedProtocols())
1034-
addMinimumProtocols(Inherited->getDeclaredType(), Protocols, Known,
1035-
Visited, Stack, ZappedAny);
1034+
addMinimumProtocols(Inherited->getDeclaredInterfaceType(),
1035+
Protocols, Known, Visited, Stack, ZappedAny);
10361036
}
10371037
return;
10381038
}
@@ -1108,8 +1108,8 @@ void ProtocolType::canonicalizeProtocols(
11081108

11091109
// Add the protocols we inherited.
11101110
for (auto Inherited : Current->getInheritedProtocols()) {
1111-
addMinimumProtocols(Inherited->getDeclaredType(), protocols, known,
1112-
visited, stack, zappedAny);
1111+
addMinimumProtocols(Inherited->getDeclaredInterfaceType(),
1112+
protocols, known, visited, stack, zappedAny);
11131113
}
11141114
}
11151115

@@ -2391,7 +2391,8 @@ getForeignRepresentable(Type type, ForeignLanguage language,
23912391
if (wasOptional) {
23922392
if (nominal->hasClangNode()) {
23932393
Type underlyingType =
2394-
nominal->getDeclaredType()->getSwiftNewtypeUnderlyingType();
2394+
nominal->getDeclaredInterfaceType()
2395+
->getSwiftNewtypeUnderlyingType();
23952396
if (underlyingType) {
23962397
return getForeignRepresentable(OptionalType::get(underlyingType),
23972398
language, dc);
@@ -2841,7 +2842,7 @@ Type ArchetypeType::getExistentialType() const {
28412842
constraintTypes.push_back(super);
28422843
}
28432844
for (auto proto : getConformsTo()) {
2844-
constraintTypes.push_back(proto->getDeclaredType());
2845+
constraintTypes.push_back(proto->getDeclaredInterfaceType());
28452846
}
28462847
return ProtocolCompositionType::get(
28472848
const_cast<ArchetypeType*>(this)->getASTContext(), constraintTypes, false);
@@ -3393,7 +3394,7 @@ Type ProtocolCompositionType::get(const ASTContext &C,
33933394
// If one protocol remains with no further constraints, its nominal
33943395
// type is the canonical type.
33953396
if (Protocols.size() == 1 && !Superclass && !HasExplicitAnyObject)
3396-
return Protocols.front()->getDeclaredType();
3397+
return Protocols.front()->getDeclaredInterfaceType();
33973398

33983399
// Form the set of canonical protocol types from the protocol
33993400
// declarations, and use that to build the canonical composition type.
@@ -3403,7 +3404,7 @@ Type ProtocolCompositionType::get(const ASTContext &C,
34033404
std::transform(Protocols.begin(), Protocols.end(),
34043405
std::back_inserter(CanTypes),
34053406
[](ProtocolDecl *Proto) {
3406-
return Proto->getDeclaredType();
3407+
return Proto->getDeclaredInterfaceType();
34073408
});
34083409

34093410
// TODO: Canonicalize away HasExplicitAnyObject if it is implied

0 commit comments

Comments
 (0)