Skip to content

Commit 0e0cdd3

Browse files
authored
Merge pull request swiftlang#38151 from eeckstein/fix-silgen-keypath-crash-5.5
[5.5] Revert "SILGen: avoid reusing the same opened archetype in keypath setter and getter functions."
2 parents 1b6f3a8 + fad03b5 commit 0e0cdd3

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
@@ -3521,14 +3521,6 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35213521
return storage->isSettable(storage->getDeclContext());
35223522
};
35233523

3524-
// We cannot use the same opened archetype in the getter and setter. Therefore
3525-
// we create a new one for both the getter and the setter.
3526-
auto renewOpenedArchetypes = [](SubstitutableType *type) -> Type {
3527-
if (auto *openedTy = dyn_cast<OpenedArchetypeType>(type))
3528-
return OpenedArchetypeType::get(openedTy->getOpenedExistentialType());
3529-
return type;
3530-
};
3531-
35323524
if (auto var = dyn_cast<VarDecl>(storage)) {
35333525
CanType componentTy;
35343526
if (!var->getDeclContext()->isTypeContext()) {
@@ -3552,15 +3544,13 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35523544
auto id = getIdForKeyPathComponentComputedProperty(*this, var,
35533545
strategy);
35543546
auto getter = getOrCreateKeyPathGetter(*this, loc,
3555-
var, subs.subst(renewOpenedArchetypes,
3556-
MakeAbstractConformanceForGenericType()),
3547+
var, subs,
35573548
needsGenericContext ? genericEnv : nullptr,
35583549
expansion, {}, baseTy, componentTy);
35593550

35603551
if (isSettableInComponent()) {
35613552
auto setter = getOrCreateKeyPathSetter(*this, loc,
3562-
var, subs.subst(renewOpenedArchetypes,
3563-
MakeAbstractConformanceForGenericType()),
3553+
var, subs,
35643554
needsGenericContext ? genericEnv : nullptr,
35653555
expansion, {}, baseTy, componentTy);
35663556
return KeyPathPatternComponent::forComputedSettableProperty(id,
@@ -3605,8 +3595,7 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
36053595

36063596
auto id = getIdForKeyPathComponentComputedProperty(*this, decl, strategy);
36073597
auto getter = getOrCreateKeyPathGetter(*this, loc,
3608-
decl, subs.subst(renewOpenedArchetypes,
3609-
MakeAbstractConformanceForGenericType()),
3598+
decl, subs,
36103599
needsGenericContext ? genericEnv : nullptr,
36113600
expansion,
36123601
indexTypes,
@@ -3615,8 +3604,7 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
36153604
auto indexPatternsCopy = getASTContext().AllocateCopy(indexPatterns);
36163605
if (isSettableInComponent()) {
36173606
auto setter = getOrCreateKeyPathSetter(*this, loc,
3618-
decl, subs.subst(renewOpenedArchetypes,
3619-
MakeAbstractConformanceForGenericType()),
3607+
decl, subs,
36203608
needsGenericContext ? genericEnv : nullptr,
36213609
expansion,
36223610
indexTypes,

0 commit comments

Comments
 (0)