[Sema] Allow synthesis of protocol conformances in extensions.

This works for all protocols except for Decodable on non-final classes, because
the init requirement has to be 'required' and thus in the type's declaration.

Fixes most of https://bugs.swift.org/browse/SR-6803.
This commit is contained in:
Huon Wilson
2018-05-04 19:26:04 +10:00
parent 5e094bdaa2
commit 3488a3a53b
16 changed files with 178 additions and 88 deletions

View File

@@ -682,7 +682,7 @@ bool DerivedConformance::canDeriveEquatable(TypeChecker &tc,
}
ValueDecl *DerivedConformance::deriveEquatable(ValueDecl *requirement) {
if (checkAndDiagnoseDisallowedContext())
if (checkAndDiagnoseDisallowedContext(requirement))
return nullptr;
// Build the necessary decl.
@@ -1197,7 +1197,7 @@ ValueDecl *DerivedConformance::deriveHashable(ValueDecl *requirement) {
return nullptr;
}
if (checkAndDiagnoseDisallowedContext())
if (checkAndDiagnoseDisallowedContext(requirement))
return nullptr;
if (auto ED = dyn_cast<EnumDecl>(Nominal)) {