Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4098,7 +4098,6 @@ lowerKeyPathSubscriptIndexTypes(
SmallVectorImpl<IndexTypePair> &indexPatterns,
SubscriptDecl *subscript,
SubstitutionMap subscriptSubs,
ResilienceExpansion expansion,
bool &needsGenericContext) {
// Capturing an index value dependent on the generic context means we
// need the generic context captured in the key path.
Expand All @@ -4118,7 +4117,8 @@ lowerKeyPathSubscriptIndexTypes(

auto indexLoweredTy = SGM.Types.getLoweredType(
AbstractionPattern::getOpaque(), indexTy,
TypeExpansionContext::noOpaqueTypeArchetypesSubstitution(expansion));
TypeExpansionContext::noOpaqueTypeArchetypesSubstitution(
ResilienceExpansion::Minimal));
indexLoweredTy = indexLoweredTy.mapTypeOutOfContext();
indexPatterns.push_back({indexTy->mapTypeOutOfContext()
->getCanonicalType(),
Expand Down Expand Up @@ -4345,7 +4345,6 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
SmallVector<IndexTypePair, 4> indexTypes;
lowerKeyPathSubscriptIndexTypes(*this, indexTypes,
decl, subs,
expansion,
needsGenericContext);

SmallVector<KeyPathPatternComponent::Index, 4> indexPatterns;
Expand Down
19 changes: 19 additions & 0 deletions test/SILGen/keypaths_resilient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %target-swift-emit-silgen %s -enable-library-evolution | %FileCheck %s

public enum E: Hashable {
case e
}

public struct S {
public var dict: [E: Int] = [:]
}

public func f() {
let _ = \S.dict[.e]
}

// CHECK-LABEL: sil [ossa] @$s18keypaths_resilient1fyyF : $@convention(thin) () -> () {
// CHECK: [[ARG:%.*]] = alloc_stack $E
// CHECK: store %1 to [trivial] [[ARG]]
// CHECK: {{%.*}} = keypath $WritableKeyPath<S, Optional<Int>>, (root $S; stored_property #S.dict : $Dictionary<E, Int>; settable_property $Optional<Int>, id @$sSDyq_Sgxcig : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in_guaranteed τ_0_0, @guaranteed Dictionary<τ_0_0, τ_0_1>) -> @out Optional<τ_0_1>, getter @$sSDyq_SgxcipSDy18keypaths_resilient1EOSiGADSiTK : $@convention(keypath_accessor_getter) (@in_guaranteed Dictionary<E, Int>, @in_guaranteed E) -> @out Optional<Int>, setter @$sSDyq_SgxcipSDy18keypaths_resilient1EOSiGADSiTk : $@convention(keypath_accessor_setter) (@in_guaranteed Optional<Int>, @inout Dictionary<E, Int>, @in_guaranteed E) -> (), indices [%$0 : $E : $*E], indices_equals @$s18keypaths_resilient1EOTH : $@convention(keypath_accessor_equals) (@in_guaranteed E, @in_guaranteed E) -> Bool, indices_hash @$s18keypaths_resilient1EOTh : $@convention(keypath_accessor_hash) (@in_guaranteed E) -> Int, external #Dictionary.subscript<E, Int>) ([[ARG]])
// CHECK: return