|
37 | 37 | #include "swift/AST/Expr.h" |
38 | 38 | #include "swift/AST/ForeignErrorConvention.h" |
39 | 39 | #include "swift/AST/GenericEnvironment.h" |
| 40 | +#include "swift/AST/InFlightSubstitution.h" |
| 41 | +#include "swift/AST/KnownProtocols.h" |
40 | 42 | #include "swift/AST/ParameterList.h" |
41 | 43 | #include "swift/AST/ProtocolConformance.h" |
42 | 44 | #include "swift/AST/SubstitutionMap.h" |
@@ -2381,8 +2383,20 @@ RValue SILGenFunction::emitAnyHashableErasure(SILLocation loc, |
2381 | 2383 | return emitUndefRValue(loc, getASTContext().getAnyHashableType()); |
2382 | 2384 |
|
2383 | 2385 | // Construct the substitution for T: Hashable. |
2384 | | - auto subMap = SubstitutionMap::getProtocolSubstitutions( |
2385 | | - conformance.getProtocol(), type, conformance); |
| 2386 | + auto subMap = SubstitutionMap::get(convertFn->getGenericSignature(), type, |
| 2387 | + [&](InFlightSubstitution &ifs, |
| 2388 | + Type ty, |
| 2389 | + ProtocolDecl *proto) -> ProtocolConformanceRef { |
| 2390 | + switch (*proto->getKnownProtocolKind()) { |
| 2391 | + case KnownProtocolKind::Hashable: |
| 2392 | + return conformance; |
| 2393 | + case KnownProtocolKind::Copyable: |
| 2394 | + case KnownProtocolKind::Escapable: |
| 2395 | + return lookupConformance(type, proto); |
| 2396 | + default: |
| 2397 | + llvm_unreachable("no other conformances should be involved"); |
| 2398 | + } |
| 2399 | + }); |
2386 | 2400 |
|
2387 | 2401 | return emitApplyOfLibraryIntrinsic(loc, convertFn, subMap, value, C); |
2388 | 2402 | } |
|
0 commit comments