|
16 | 16 | #include "swift/AST/Availability.h"
|
17 | 17 | #include "swift/AST/Expr.h"
|
18 | 18 | #include "swift/AST/GenericEnvironment.h"
|
| 19 | +#include "swift/AST/LocalArchetypeRequirementCollector.h" |
19 | 20 | #include "swift/AST/Module.h"
|
20 | 21 | #include "swift/AST/Stmt.h"
|
21 | 22 | #include "swift/Basic/OptimizationMode.h"
|
@@ -490,24 +491,43 @@ bool SILFunction::shouldOptimize() const {
|
490 | 491 | }
|
491 | 492 |
|
492 | 493 | Type SILFunction::mapTypeIntoContext(Type type) const {
|
493 |
| - return GenericEnvironment::mapTypeIntoContext( |
494 |
| - getGenericEnvironment(), type); |
| 494 | + assert(!type->hasPrimaryArchetype()); |
| 495 | + |
| 496 | + if (GenericEnv) { |
| 497 | + return type.subst(MapIntoLocalArchetypeContext(GenericEnv, CapturedEnvs), |
| 498 | + LookUpConformanceInModule(Module.getSwiftModule()), |
| 499 | + SubstFlags::AllowLoweredTypes | |
| 500 | + SubstFlags::PreservePackExpansionLevel); |
| 501 | + } |
| 502 | + |
| 503 | + assert(!type->hasTypeParameter()); |
| 504 | + return type; |
495 | 505 | }
|
496 | 506 |
|
497 | 507 | SILType SILFunction::mapTypeIntoContext(SILType type) const {
|
498 |
| - if (auto *genericEnv = getGenericEnvironment()) |
499 |
| - return genericEnv->mapTypeIntoContext(getModule(), type); |
| 508 | + assert(!type.hasPrimaryArchetype()); |
| 509 | + |
| 510 | + if (GenericEnv) { |
| 511 | + auto genericSig = GenericEnv->getGenericSignature().getCanonicalSignature(); |
| 512 | + return type.subst(Module, |
| 513 | + MapIntoLocalArchetypeContext(GenericEnv, CapturedEnvs), |
| 514 | + LookUpConformanceInModule(Module.getSwiftModule()), |
| 515 | + genericSig, |
| 516 | + SubstFlags::PreservePackExpansionLevel); |
| 517 | + } |
| 518 | + |
| 519 | + assert(!type.hasTypeParameter()); |
500 | 520 | return type;
|
501 | 521 | }
|
502 | 522 |
|
503 | 523 | SILType GenericEnvironment::mapTypeIntoContext(SILModule &M,
|
504 | 524 | SILType type) const {
|
505 |
| - assert(!type.hasArchetype()); |
| 525 | + assert(!type.hasPrimaryArchetype()); |
506 | 526 |
|
507 | 527 | auto genericSig = getGenericSignature().getCanonicalSignature();
|
508 | 528 | return type.subst(M,
|
509 | 529 | QueryInterfaceTypeSubstitutions(this),
|
510 |
| - LookUpConformanceInSignature(genericSig.getPointer()), |
| 530 | + LookUpConformanceInModule(M.getSwiftModule()), |
511 | 531 | genericSig,
|
512 | 532 | SubstFlags::PreservePackExpansionLevel);
|
513 | 533 | }
|
|
0 commit comments