Skip to content

Commit 3491fec

Browse files
committed
Revert "Sema: Go back to synthesizing hashValue on _StoredBridgedNSError conformers"
This reverts commit 712927c.
1 parent 7beb358 commit 3491fec

File tree

2 files changed

+7
-26
lines changed

2 files changed

+7
-26
lines changed

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,41 +1125,18 @@ deriveBodyHashable_hashValue(AbstractFunctionDecl *hashValueDecl, void *) {
11251125

11261126
// return _hashValue(for: self)
11271127
auto *hashFunc = C.getHashValueForDecl();
1128-
if (!hashFunc->hasInterfaceType())
1129-
C.getLazyResolver()->resolveDeclSignature(hashFunc);
1130-
1131-
auto selfType = hashValueDecl->mapTypeIntoContext(
1132-
parentDC->getSelfInterfaceType());
1133-
auto hashableProto = C.getProtocol(KnownProtocolKind::Hashable);
1134-
auto conformance = TypeChecker::conformsToProtocol(selfType, hashableProto,
1135-
parentDC, None);
1136-
auto subs = SubstitutionMap::get(hashFunc->getGenericSignature(),
1137-
ArrayRef<Type>(selfType),
1138-
ArrayRef<ProtocolConformanceRef>(*conformance));
1139-
ConcreteDeclRef hashRef(hashFunc, subs);
1140-
1141-
auto hashExpr = new (C) DeclRefExpr(hashRef, DeclNameLoc(),
1128+
auto hashExpr = new (C) DeclRefExpr(hashFunc, DeclNameLoc(),
11421129
/*implicit*/ true);
1143-
1144-
Type intType = C.getIntDecl()->getDeclaredType();
1145-
hashExpr->setType(FunctionType::get(AnyFunctionType::Param(selfType),
1146-
intType));
1147-
11481130
auto selfDecl = hashValueDecl->getImplicitSelfDecl();
11491131
auto selfRef = new (C) DeclRefExpr(selfDecl, DeclNameLoc(),
11501132
/*implicit*/ true);
1151-
selfRef->setType(selfType);
1152-
1153-
auto callExpr = CallExpr::createImplicit(C, hashExpr, { selfRef }, { });
1154-
callExpr->setType(intType);
1155-
callExpr->setThrows(false);
1156-
1133+
auto callExpr = CallExpr::createImplicit(C, hashExpr,
1134+
{ selfRef }, { C.Id_for });
11571135
auto returnStmt = new (C) ReturnStmt(SourceLoc(), callExpr);
11581136

11591137
auto body = BraceStmt::create(C, SourceLoc(), {returnStmt}, SourceLoc(),
11601138
/*implicit*/ true);
11611139
hashValueDecl->setBody(body);
1162-
hashValueDecl->setBodyTypeCheckedIfPresent();
11631140
}
11641141

11651142
/// Derive a 'hashValue' implementation.

stdlib/public/Darwin/Foundation/NSError.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ extension _BridgedStoredNSError {
489489
public func hash(into hasher: inout Hasher) {
490490
hasher.combine(_nsError)
491491
}
492+
493+
@_alwaysEmitIntoClient public var hashValue: Int {
494+
return _nsError.hashValue
495+
}
492496
}
493497

494498
/// Describes the code of an error.

0 commit comments

Comments
 (0)