AST: Don't call hasType()/getType()/setType() on TypeDecls

This commit is contained in:
Slava Pestov
2016-11-30 01:30:08 -08:00
parent 07780bd60c
commit 9caaad442b
18 changed files with 104 additions and 109 deletions

View File

@@ -949,8 +949,9 @@ calculateTypeRelationForDecl(const Decl *D, Type ExpectedType,
}
}
if (auto NTD = dyn_cast<NominalTypeDecl>(VD)) {
return std::max(calculateTypeRelation(NTD->getType(), ExpectedType, DC),
calculateTypeRelation(NTD->getDeclaredType(), ExpectedType, DC));
return std::max(
calculateTypeRelation(NTD->getInterfaceType(), ExpectedType, DC),
calculateTypeRelation(NTD->getDeclaredInterfaceType(), ExpectedType, DC));
}
return calculateTypeRelation(VD->getInterfaceType(), ExpectedType, DC);
}
@@ -1341,7 +1342,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
if (auto *NTD = dyn_cast<NominalTypeDecl>(DC)) {
// First, type check the parent DeclContext.
typecheckContextImpl(DC->getParent());
if (NTD->hasType())
if (NTD->hasInterfaceType())
return true;
return typeCheckCompletionDecl(cast<NominalTypeDecl>(DC));
}
@@ -2855,7 +2856,8 @@ public:
if (auto *NTD = dyn_cast<NominalTypeDecl>(D)) {
addNominalTypeRef(NTD, Reason);
addConstructorCallsForType(NTD->getType(), NTD->getName(), Reason);
addConstructorCallsForType(NTD->getInterfaceType(), NTD->getName(),
Reason);
return;
}
@@ -2869,7 +2871,7 @@ public:
if (auto *GP = dyn_cast<GenericTypeParamDecl>(D)) {
addGenericTypeParamRef(GP, Reason);
for (auto *protocol : GP->getConformingProtocols())
addConstructorCallsForType(protocol->getType(), GP->getName(),
addConstructorCallsForType(protocol->getInterfaceType(), GP->getName(),
Reason);
return;
}
@@ -2923,7 +2925,8 @@ public:
if (auto *NTD = dyn_cast<NominalTypeDecl>(D)) {
addNominalTypeRef(NTD, Reason);
addConstructorCallsForType(NTD->getType(), NTD->getName(), Reason);
addConstructorCallsForType(NTD->getInterfaceType(), NTD->getName(),
Reason);
return;
}
@@ -2937,7 +2940,7 @@ public:
if (auto *GP = dyn_cast<GenericTypeParamDecl>(D)) {
addGenericTypeParamRef(GP, Reason);
for (auto *protocol : GP->getConformingProtocols())
addConstructorCallsForType(protocol->getType(), GP->getName(),
addConstructorCallsForType(protocol->getInterfaceType(), GP->getName(),
Reason);
return;
}
@@ -3630,12 +3633,6 @@ public:
return std::binary_search(SortedNames.begin(), SortedNames.end(), Name);
}
void collectEnumElementTypes(EnumElementDecl *EED) {
if (isNameHit(EED->getNameStr()) && EED->getType()) {
unboxType(EED->getType());
}
}
void unboxType(Type T) {
if (T->getKind() == TypeKind::Paren) {
unboxType(T->getDesugaredType());