File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -651,6 +651,21 @@ bool CrossModuleOptimization::canSerializeFieldsByInstructionKind(
651651 canUse = methodScope.isPublicOrPackage ();
652652 }
653653 });
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+ }
654669 return canUse;
655670 }
656671 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> {
311311 _ = ( repeat ( each storage) . visit ( ) )
312312 }
313313}
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() {
171171 print ( getRandom ( ) )
172172}
173173
174+ func testKeyPathAccess( ) -> KeyPath < StructWithInternal , Int > {
175+ return getKP ( )
176+ }
177+
174178testNestedTypes ( )
175179testClass ( )
176180testError ( )
@@ -182,4 +186,4 @@ testMisc()
182186testGlobal ( )
183187testImplementationOnly ( )
184188testPrivateVar ( )
185-
189+ testKeyPathAccess ( )
You can’t perform that action at this time.
0 commit comments