mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Fix confusion when builtin conformance passed to registerProtocolConformance()
This commit is contained in:
@@ -4219,7 +4219,7 @@ public:
|
||||
///
|
||||
/// This is used by deserialization of module files to report
|
||||
/// conformances.
|
||||
void registerProtocolConformance(ProtocolConformance *conformance,
|
||||
void registerProtocolConformance(NormalProtocolConformance *conformance,
|
||||
bool synthesized = false);
|
||||
|
||||
void setConformanceLoader(LazyMemberLoader *resolver, uint64_t contextData);
|
||||
|
||||
@@ -174,7 +174,7 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
|
||||
if (loader.first) {
|
||||
SmallVector<ProtocolConformance *, 2> conformances;
|
||||
loader.first->loadAllConformances(nominal, loader.second, conformances);
|
||||
loadAllConformances(nominal, conformances);
|
||||
registerProtocolConformances(nominal, conformances);
|
||||
}
|
||||
|
||||
nominalFunc(nominal);
|
||||
@@ -202,7 +202,7 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
|
||||
if (loader.first) {
|
||||
SmallVector<ProtocolConformance *, 2> conformances;
|
||||
loader.first->loadAllConformances(next, loader.second, conformances);
|
||||
loadAllConformances(next, conformances);
|
||||
registerProtocolConformances(next, conformances);
|
||||
for (auto conf : conformances) {
|
||||
protocols.push_back(
|
||||
{conf->getProtocol(), SourceLoc(), SourceLoc(), SourceLoc()});
|
||||
@@ -433,19 +433,17 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
|
||||
}
|
||||
}
|
||||
|
||||
void ConformanceLookupTable::loadAllConformances(
|
||||
void ConformanceLookupTable::registerProtocolConformances(
|
||||
DeclContext *dc,
|
||||
ArrayRef<ProtocolConformance*> conformances) {
|
||||
// If this declaration context came from source, there's nothing to
|
||||
// do here.
|
||||
if (dc->getParentSourceFile() ||
|
||||
dc->getParentModule()->isBuiltinModule()) {
|
||||
return;
|
||||
}
|
||||
assert(!dc->getParentSourceFile() &&
|
||||
!dc->getParentModule()->isBuiltinModule());
|
||||
|
||||
// Add entries for each loaded conformance.
|
||||
for (auto conformance : conformances) {
|
||||
registerProtocolConformance(conformance);
|
||||
registerProtocolConformance(dc, conformance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,10 +1017,9 @@ void ConformanceLookupTable::addSynthesizedConformance(
|
||||
}
|
||||
|
||||
void ConformanceLookupTable::registerProtocolConformance(
|
||||
ProtocolConformance *conformance,
|
||||
DeclContext *dc, ProtocolConformance *conformance,
|
||||
bool synthesized) {
|
||||
auto protocol = conformance->getProtocol();
|
||||
auto dc = conformance->getDeclContext();
|
||||
auto nominal = dc->getSelfNominalTypeDecl();
|
||||
|
||||
// If there is an entry to update, do so.
|
||||
|
||||
@@ -459,10 +459,10 @@ class ConformanceLookupTable : public ASTAllocated<ConformanceLookupTable> {
|
||||
/// Update a lookup table with conformances from newly-added extensions.
|
||||
void updateLookupTable(NominalTypeDecl *nominal, ConformanceStage stage);
|
||||
|
||||
/// Load all of the protocol conformances for the given (serialized)
|
||||
/// Register deserialized protocol conformances for the given (serialized)
|
||||
/// declaration context.
|
||||
void loadAllConformances(DeclContext *dc,
|
||||
ArrayRef<ProtocolConformance *> conformances);
|
||||
void registerProtocolConformances(DeclContext *dc,
|
||||
ArrayRef<ProtocolConformance *> conformances);
|
||||
|
||||
public:
|
||||
/// Create a new conformance lookup table.
|
||||
@@ -477,7 +477,8 @@ public:
|
||||
DeclContext *conformanceDC);
|
||||
|
||||
/// Register an externally-supplied protocol conformance.
|
||||
void registerProtocolConformance(ProtocolConformance *conformance,
|
||||
void registerProtocolConformance(DeclContext *dc,
|
||||
ProtocolConformance *conformance,
|
||||
bool synthesized = false);
|
||||
|
||||
/// Look for conformances to the given protocol.
|
||||
|
||||
@@ -1195,9 +1195,10 @@ void NominalTypeDecl::getImplicitProtocols(
|
||||
}
|
||||
|
||||
void NominalTypeDecl::registerProtocolConformance(
|
||||
ProtocolConformance *conformance, bool synthesized) {
|
||||
NormalProtocolConformance *conformance, bool synthesized) {
|
||||
prepareConformanceTable();
|
||||
ConformanceTable->registerProtocolConformance(conformance, synthesized);
|
||||
auto *dc = conformance->getDeclContext();
|
||||
ConformanceTable->registerProtocolConformance(dc, conformance, synthesized);
|
||||
}
|
||||
|
||||
ArrayRef<ValueDecl *>
|
||||
|
||||
Reference in New Issue
Block a user