mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Sema] Pass down ProtocolConformance to DerivedConformance
Previously `getHashableConformance` was attempting to find the conformance itself, which could fail (rdar://129620291). Instead, pass down the known protocol conformance that we're deriving a witness for. No test case unfortunately as I haven't been able to come up with a reproducer. rdar://129620291
This commit is contained in:
@@ -29,20 +29,23 @@ using namespace swift;
|
||||
|
||||
enum NonconformingMemberKind { AssociatedValue, StoredProperty };
|
||||
|
||||
DerivedConformance::DerivedConformance(ASTContext &ctx, Decl *conformanceDecl,
|
||||
NominalTypeDecl *nominal,
|
||||
ProtocolDecl *protocol)
|
||||
: Context(ctx), ConformanceDecl(conformanceDecl), Nominal(nominal),
|
||||
Protocol(protocol) {
|
||||
assert(getConformanceContext()->getSelfNominalTypeDecl() == nominal);
|
||||
DerivedConformance::DerivedConformance(
|
||||
const NormalProtocolConformance *conformance, NominalTypeDecl *nominal,
|
||||
ProtocolDecl *protocol)
|
||||
: Context(nominal->getASTContext()), Conformance(conformance),
|
||||
Nominal(nominal), Protocol(protocol) {
|
||||
auto *DC = Conformance->getDeclContext();
|
||||
ConformanceDecl = DC->getInnermostDeclarationDeclContext();
|
||||
assert(ConformanceDecl);
|
||||
assert(DC->getSelfNominalTypeDecl() == nominal);
|
||||
}
|
||||
|
||||
DeclContext *DerivedConformance::getConformanceContext() const {
|
||||
return cast<DeclContext>(ConformanceDecl);
|
||||
return Conformance->getDeclContext();
|
||||
}
|
||||
|
||||
ModuleDecl *DerivedConformance::getParentModule() const {
|
||||
return cast<DeclContext>(ConformanceDecl)->getParentModule();
|
||||
return getConformanceContext()->getParentModule();
|
||||
}
|
||||
|
||||
void DerivedConformance::addMembersToConformanceContext(
|
||||
|
||||
Reference in New Issue
Block a user