Skip to content

Commit 4310230

Browse files
committed
Revert "SILGen: avoid reusing the same opened archetype in keypath setter and getter functions."
There are some crashes (for which we don't have a reproducer, unfortunately), which are caused by this change. The good thing is that this change is not needed anymore, because it's handled by the more general eecb9fa "SILModule: track opened archetypes per function.". The test case for this was added in the original commit (test/stdlib/KeyPath.swift), which is not reverted with this commit. rdar://79415891
1 parent efd9c45 commit 4310230

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,14 +3514,6 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35143514
return storage->isSettable(storage->getDeclContext());
35153515
};
35163516

3517-
// We cannot use the same opened archetype in the getter and setter. Therefore
3518-
// we create a new one for both the getter and the setter.
3519-
auto renewOpenedArchetypes = [](SubstitutableType *type) -> Type {
3520-
if (auto *openedTy = dyn_cast<OpenedArchetypeType>(type))
3521-
return OpenedArchetypeType::get(openedTy->getOpenedExistentialType());
3522-
return type;
3523-
};
3524-
35253517
if (auto var = dyn_cast<VarDecl>(storage)) {
35263518
CanType componentTy;
35273519
if (!var->getDeclContext()->isTypeContext()) {
@@ -3545,15 +3537,13 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35453537
auto id = getIdForKeyPathComponentComputedProperty(*this, var,
35463538
strategy);
35473539
auto getter = getOrCreateKeyPathGetter(*this, loc,
3548-
var, subs.subst(renewOpenedArchetypes,
3549-
MakeAbstractConformanceForGenericType()),
3540+
var, subs,
35503541
needsGenericContext ? genericEnv : nullptr,
35513542
expansion, {}, baseTy, componentTy);
35523543

35533544
if (isSettableInComponent()) {
35543545
auto setter = getOrCreateKeyPathSetter(*this, loc,
3555-
var, subs.subst(renewOpenedArchetypes,
3556-
MakeAbstractConformanceForGenericType()),
3546+
var, subs,
35573547
needsGenericContext ? genericEnv : nullptr,
35583548
expansion, {}, baseTy, componentTy);
35593549
return KeyPathPatternComponent::forComputedSettableProperty(id,
@@ -3598,8 +3588,7 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35983588

35993589
auto id = getIdForKeyPathComponentComputedProperty(*this, decl, strategy);
36003590
auto getter = getOrCreateKeyPathGetter(*this, loc,
3601-
decl, subs.subst(renewOpenedArchetypes,
3602-
MakeAbstractConformanceForGenericType()),
3591+
decl, subs,
36033592
needsGenericContext ? genericEnv : nullptr,
36043593
expansion,
36053594
indexTypes,
@@ -3608,8 +3597,7 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
36083597
auto indexPatternsCopy = getASTContext().AllocateCopy(indexPatterns);
36093598
if (isSettableInComponent()) {
36103599
auto setter = getOrCreateKeyPathSetter(*this, loc,
3611-
decl, subs.subst(renewOpenedArchetypes,
3612-
MakeAbstractConformanceForGenericType()),
3600+
decl, subs,
36133601
needsGenericContext ? genericEnv : nullptr,
36143602
expansion,
36153603
indexTypes,

0 commit comments

Comments
 (0)