Introduce isDecl and getDeclType

fix enum logic issue

fix tests

guard against null types
This commit is contained in:
Azoy
2021-04-18 01:27:46 -04:00
parent f75f5fe78d
commit 9ed732f0ab
62 changed files with 391 additions and 569 deletions

View File

@@ -4902,12 +4902,11 @@ findProtocolSelfReferences(const ProtocolDecl *proto, Type type,
if (auto *const bgt = type->getAs<BoundGenericType>()) {
auto info = SelfReferenceInfo();
const auto &ctx = bgt->getDecl()->getASTContext();
if (ctx.getArrayDecl() == bgt->getDecl()) {
if (bgt->isArray()) {
// Swift.Array preserves variance in its Value type.
info |= findProtocolSelfReferences(proto, bgt->getGenericArgs().front(),
position);
} else if (bgt->getDecl() == ctx.getDictionaryDecl()) {
} else if (bgt->isDictionary()) {
// Swift.Dictionary preserves variance in its Element type.
info |= findProtocolSelfReferences(proto, bgt->getGenericArgs().front(),
SelfReferencePosition::Invariant);