File tree 3 files changed +28
-1
lines changed
3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -651,6 +651,21 @@ bool CrossModuleOptimization::canSerializeFieldsByInstructionKind(
651
651
canUse = methodScope.isPublicOrPackage ();
652
652
}
653
653
});
654
+ auto pattern = KPI->getPattern ();
655
+ for (auto &component : pattern->getComponents ()) {
656
+ if (!canUse) {
657
+ break ;
658
+ }
659
+ switch (component.getKind ()) {
660
+ case KeyPathPatternComponent::Kind::StoredProperty: {
661
+ auto property = component.getStoredPropertyDecl ();
662
+ canUse = isPackageOrPublic (property->getEffectiveAccess ());
663
+ break ;
664
+ }
665
+ default :
666
+ break ;
667
+ }
668
+ }
654
669
return canUse;
655
670
}
656
671
if (auto *MI = dyn_cast<MethodInst>(inst)) {
Original file line number Diff line number Diff line change @@ -311,3 +311,11 @@ public struct S<each T : Visitable> {
311
311
_ = ( repeat ( each storage) . visit ( ) )
312
312
}
313
313
}
314
+
315
+ public struct StructWithInternal {
316
+ var internalVar : Int
317
+ }
318
+
319
+ public func getKP( ) -> KeyPath < StructWithInternal , Int > {
320
+ return \StructWithInternal . internalVar
321
+ }
Original file line number Diff line number Diff line change @@ -171,6 +171,10 @@ func testPrivateVar() {
171
171
print ( getRandom ( ) )
172
172
}
173
173
174
+ func testKeyPathAccess( ) -> KeyPath < StructWithInternal , Int > {
175
+ return getKP ( )
176
+ }
177
+
174
178
testNestedTypes ( )
175
179
testClass ( )
176
180
testError ( )
@@ -182,4 +186,4 @@ testMisc()
182
186
testGlobal ( )
183
187
testImplementationOnly ( )
184
188
testPrivateVar ( )
185
-
189
+ testKeyPathAccess ( )
You can’t perform that action at this time.
0 commit comments