Skip to content

Commit 1a6b83f

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 27f3f84 + 72f1504 commit 1a6b83f

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,8 @@ bool SILGenModule::hasNonTrivialIVars(ClassDecl *cd) {
956956
auto *vd = dyn_cast<VarDecl>(member);
957957
if (!vd || !vd->hasStorage()) continue;
958958

959-
// FIXME: Expansion
960959
auto &ti = Types.getTypeLowering(vd->getType(),
961-
ResilienceExpansion::Minimal);
960+
ResilienceExpansion::Maximal);
962961
if (!ti.isTrivial())
963962
return true;
964963
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,7 @@ lowerKeyPathSubscriptIndexTypes(
33133313
SmallVectorImpl<IndexTypePair> &indexPatterns,
33143314
SubscriptDecl *subscript,
33153315
SubstitutionMap subscriptSubs,
3316+
ResilienceExpansion expansion,
33163317
bool &needsGenericContext) {
33173318
// Capturing an index value dependent on the generic context means we
33183319
// need the generic context captured in the key path.
@@ -3330,11 +3331,9 @@ lowerKeyPathSubscriptIndexTypes(
33303331
indexTy = indexTy.subst(subscriptSubs);
33313332
}
33323333

3333-
// FIXME: Expansion
33343334
auto indexLoweredTy = SGM.Types.getLoweredType(
33353335
AbstractionPattern::getOpaque(),
3336-
indexTy,
3337-
ResilienceExpansion::Minimal);
3336+
indexTy, expansion);
33383337
indexLoweredTy = indexLoweredTy.mapTypeOutOfContext();
33393338
indexPatterns.push_back({indexTy->mapTypeOutOfContext()
33403339
->getCanonicalType(),
@@ -3531,6 +3530,7 @@ SILGenModule::emitKeyPathComponentForDecl(SILLocation loc,
35313530
SmallVector<IndexTypePair, 4> indexTypes;
35323531
lowerKeyPathSubscriptIndexTypes(*this, indexTypes,
35333532
decl, subs,
3533+
expansion,
35343534
needsGenericContext);
35353535

35363536
SmallVector<KeyPathPatternComponent::Index, 4> indexPatterns;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -enable-sil-ownership %S/../Inputs/resilient_struct.swift
4+
// RUN: %target-swift-emit-silgen -I %t -enable-sil-ownership -enable-resilience %s | %FileCheck %s
5+
6+
import resilient_struct
7+
8+
public class Base {}
9+
10+
public struct MyResilientInt {
11+
var i: Int
12+
13+
public init(i: Int) { self.i = i }
14+
}
15+
16+
public class NeedsIVarDetroyer : Base {
17+
var x = ResilientInt(i: 0)
18+
}
19+
20+
public class DoesNotNeedIVarDestroyer : Base {
21+
var x = MyResilientInt(i: 0)
22+
}
23+
24+
// CHECK-LABEL: sil_vtable NeedsIVarDetroyer {
25+
// CHECK-NEXT: #Base.init!allocator.1: (Base.Type) -> () -> Base
26+
// CHECK-NEXT: #NeedsIVarDetroyer.x!getter.1: (NeedsIVarDetroyer) -> () -> resilient_struct.ResilientInt
27+
// CHECK-NEXT: #NeedsIVarDetroyer.x!setter.1: (NeedsIVarDetroyer) -> (resilient_struct.ResilientInt) -> ()
28+
// CHECK-NEXT: #NeedsIVarDetroyer.x!modify.1: (NeedsIVarDetroyer) -> () -> ()
29+
// CHECK-NEXT: #NeedsIVarDetroyer.deinit!deallocator.1
30+
// CHECK-NEXT: #NeedsIVarDetroyer!ivardestroyer.1
31+
// CHECK-NEXT: }
32+
33+
// CHECK-LABEL: sil_vtable DoesNotNeedIVarDestroyer {
34+
// CHECK-NEXT: #Base.init!allocator.1: (Base.Type) -> () -> Base
35+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.x!getter.1: (DoesNotNeedIVarDestroyer) -> () -> MyResilientInt
36+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.x!setter.1: (DoesNotNeedIVarDestroyer) -> (MyResilientInt) -> ()
37+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.x!modify.1: (DoesNotNeedIVarDestroyer) -> () -> ()
38+
// CHECK-NEXT: #DoesNotNeedIVarDestroyer.deinit!deallocator.1
39+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)