@@ -953,20 +953,6 @@ getHashValueRequirement(ASTContext &C) {
953953 return nullptr ;
954954}
955955
956- static ProtocolConformance *
957- getHashableConformance (const Decl *parentDecl) {
958- ASTContext &C = parentDecl->getASTContext ();
959- const auto IDC = cast<IterableDeclContext>(parentDecl);
960- auto hashableProto = C.getProtocol (KnownProtocolKind::Hashable);
961- for (auto conformance: IDC->getLocalConformances (
962- ConformanceLookupKind::NonStructural)) {
963- if (conformance->getProtocol () == hashableProto) {
964- return conformance;
965- }
966- }
967- return nullptr ;
968- }
969-
970956bool DerivedConformance::canDeriveHashable (NominalTypeDecl *type) {
971957 // FIXME: This is not actually correct. We cannot promise to always
972958 // provide a witness here in all cases. Unfortunately, figuring out
@@ -985,21 +971,18 @@ void DerivedConformance::tryDiagnoseFailedHashableDerivation(
985971}
986972
987973ValueDecl *DerivedConformance::deriveHashable (ValueDecl *requirement) {
988- ASTContext &C = ConformanceDecl->getASTContext ();
989-
990974 // var hashValue: Int
991- if (requirement->getBaseName () == C .Id_hashValue ) {
975+ if (requirement->getBaseName () == Context .Id_hashValue ) {
992976 // We always allow hashValue to be synthesized; invalid cases are diagnosed
993977 // during hash(into:) synthesis.
994978 return deriveHashable_hashValue (*this );
995979 }
996980
997981 // Hashable.hash(into:)
998- if (requirement->getBaseName () == C .Id_hash ) {
982+ if (requirement->getBaseName () == Context .Id_hash ) {
999983 // Start by resolving hashValue conformance.
1000- auto hashValueReq = getHashValueRequirement (C);
1001- auto conformance = getHashableConformance (ConformanceDecl);
1002- auto hashValueDecl = conformance->getWitnessDecl (hashValueReq);
984+ auto hashValueReq = getHashValueRequirement (Context);
985+ auto hashValueDecl = Conformance->getWitnessDecl (hashValueReq);
1003986 if (!hashValueDecl) {
1004987 // We won't derive hash(into:) if hashValue cannot be resolved.
1005988 // The hashValue failure will produce a diagnostic elsewhere.
@@ -1011,7 +994,7 @@ ValueDecl *DerivedConformance::deriveHashable(ValueDecl *requirement) {
1011994
1012995 // Refuse to synthesize Hashable if type isn't a struct or enum, or if it
1013996 // has non-Hashable stored properties/associated values.
1014- auto hashableProto = C .getProtocol (KnownProtocolKind::Hashable);
997+ auto hashableProto = Context .getProtocol (KnownProtocolKind::Hashable);
1015998 if (!canDeriveConformance (getConformanceContext (), Nominal,
1016999 hashableProto)) {
10171000 ConformanceDecl->diagnose (diag::type_does_not_conform,
0 commit comments