@@ -188,12 +188,9 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
188188 // / func ==(Int, Int) -> Bool
189189 FuncDecl *EqualIntDecl = nullptr ;
190190
191- // / func _combineHashValues(Int, Int ) -> Int
192- FuncDecl *CombineHashValuesDecl = nullptr ;
191+ // / func _hashValue<H: Hashable>(for: H ) -> Int
192+ FuncDecl *HashValueForDecl = nullptr ;
193193
194- // / func _mixInt(Int) -> Int
195- FuncDecl *MixIntDecl = nullptr ;
196-
197194 // / func append(Element) -> void
198195 FuncDecl *ArrayAppendElementDecl = nullptr ;
199196
@@ -989,44 +986,29 @@ FuncDecl *ASTContext::getGetBoolDecl(LazyResolver *resolver) const {
989986 return decl;
990987}
991988
992- FuncDecl *ASTContext::getCombineHashValuesDecl () const {
993- if (Impl.CombineHashValuesDecl )
994- return Impl.CombineHashValuesDecl ;
995-
996- auto resolver = getLazyResolver ();
997- auto intType = getIntDecl ()->getDeclaredType ();
998-
999- auto callback = [&](Type inputType, Type resultType) {
1000- // Look for the signature (Int, Int) -> Int
1001- auto tupleType = dyn_cast<TupleType>(inputType.getPointer ());
1002- assert (tupleType);
1003- return tupleType->getNumElements () == 2 &&
1004- tupleType->getElementType (0 )->isEqual (intType) &&
1005- tupleType->getElementType (1 )->isEqual (intType) &&
1006- resultType->isEqual (intType);
1007- };
1008-
1009- auto decl = lookupLibraryIntrinsicFunc (
1010- *this , " _combineHashValues" , resolver, callback);
1011- Impl.CombineHashValuesDecl = decl;
1012- return decl;
1013- }
1014-
1015- FuncDecl *ASTContext::getMixIntDecl () const {
1016- if (Impl.MixIntDecl )
1017- return Impl.MixIntDecl ;
989+ FuncDecl *ASTContext::getHashValueForDecl () const {
990+ if (Impl.HashValueForDecl )
991+ return Impl.HashValueForDecl ;
1018992
1019- auto resolver = getLazyResolver ();
1020- auto intType = getIntDecl ()->getDeclaredType ();
1021-
1022- auto callback = [&](Type inputType, Type resultType) {
1023- // Look for the signature (Int) -> Int
1024- return inputType->isEqual (intType) && resultType->isEqual (intType);
1025- };
1026-
1027- auto decl = lookupLibraryIntrinsicFunc (*this , " _mixInt" , resolver, callback);
1028- Impl.MixIntDecl = decl;
1029- return decl;
993+ SmallVector<ValueDecl *, 1 > results;
994+ lookupInSwiftModule (" _hashValue" , results);
995+ for (auto result : results) {
996+ auto *fd = dyn_cast<FuncDecl>(result);
997+ if (!fd)
998+ continue ;
999+ auto paramLists = fd->getParameterLists ();
1000+ if (paramLists.size () != 1 || paramLists[0 ]->size () != 1 )
1001+ continue ;
1002+ auto paramDecl = paramLists[0 ]->get (0 );
1003+ if (paramDecl->getArgumentName () != Id_for)
1004+ continue ;
1005+ auto genericParams = fd->getGenericParams ();
1006+ if (!genericParams || genericParams->size () != 1 )
1007+ continue ;
1008+ Impl.HashValueForDecl = fd;
1009+ return fd;
1010+ }
1011+ return nullptr ;
10301012}
10311013
10321014FuncDecl *ASTContext::getArrayAppendElementDecl () const {
0 commit comments