Ensure that we record the @unsafe for conformances introduced via extensions

This commit is contained in:
Doug Gregor
2025-01-10 17:02:53 -08:00
parent aea6b38584
commit f14baef7f4
2 changed files with 23 additions and 5 deletions

View File

@@ -166,13 +166,17 @@ namespace {
/// The location of the "preconcurrency" attribute if present.
const SourceLoc preconcurrencyLoc;
/// The location of the "unsafe" attribute if present.
const SourceLoc unsafeLoc;
ConformanceConstructionInfo() { }
ConformanceConstructionInfo(ProtocolDecl *item, SourceLoc loc,
SourceLoc uncheckedLoc,
SourceLoc preconcurrencyLoc)
SourceLoc preconcurrencyLoc,
SourceLoc unsafeLoc)
: Located(item, loc), uncheckedLoc(uncheckedLoc),
preconcurrencyLoc(preconcurrencyLoc) {}
preconcurrencyLoc(preconcurrencyLoc), unsafeLoc(unsafeLoc) {}
};
}
@@ -228,7 +232,7 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
registerProtocolConformances(next, conformances);
for (auto conf : conformances) {
protocols.push_back(
{conf->getProtocol(), SourceLoc(), SourceLoc(), SourceLoc()});
{conf->getProtocol(), SourceLoc(), SourceLoc(), SourceLoc(), SourceLoc()});
}
} else if (next->getParentSourceFile() ||
next->getParentModule()->isBuiltinModule()) {
@@ -238,7 +242,8 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
getDirectlyInheritedNominalTypeDecls(next, inverses, anyObject)) {
if (auto proto = dyn_cast<ProtocolDecl>(found.Item))
protocols.push_back(
{proto, found.Loc, found.uncheckedLoc, found.preconcurrencyLoc});
{proto, found.Loc, found.uncheckedLoc,
found.preconcurrencyLoc, found.unsafeLoc});
}
}
@@ -343,7 +348,8 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
addProtocol(
locAndProto.Item, locAndProto.Loc,
source.withUncheckedLoc(locAndProto.uncheckedLoc)
.withPreconcurrencyLoc(locAndProto.preconcurrencyLoc));
.withPreconcurrencyLoc(locAndProto.preconcurrencyLoc)
.withUnsafeLoc(locAndProto.unsafeLoc));
});
break;