@@ -499,6 +499,52 @@ func sr6744() {
499
499
_ = get ( for: \. value)
500
500
}
501
501
502
+ struct VisibilityTesting {
503
+ private( set) var x : Int
504
+ fileprivate( set) var y : Int
505
+ let z : Int
506
+
507
+ // Key path exprs should not get special dispensation to write to lets
508
+ // in init contexts
509
+ init ( ) {
510
+ var xRef = \VisibilityTesting . x
511
+ var yRef = \VisibilityTesting . y
512
+ var zRef = \VisibilityTesting . z
513
+ expect ( & xRef,
514
+ toHaveType: Exactly< WritableKeyPath< VisibilityTesting, Int>>. self )
515
+ expect ( & yRef,
516
+ toHaveType: Exactly< WritableKeyPath< VisibilityTesting, Int>>. self )
517
+ expect ( & zRef,
518
+ toHaveType: Exactly< KeyPath< VisibilityTesting, Int>>. self )
519
+ }
520
+
521
+ func inPrivateContext( ) {
522
+ var xRef = \VisibilityTesting . x
523
+ var yRef = \VisibilityTesting . y
524
+ var zRef = \VisibilityTesting . z
525
+ expect ( & xRef,
526
+ toHaveType: Exactly< WritableKeyPath< VisibilityTesting, Int>>. self )
527
+ expect ( & yRef,
528
+ toHaveType: Exactly< WritableKeyPath< VisibilityTesting, Int>>. self )
529
+ expect ( & zRef,
530
+ toHaveType: Exactly< KeyPath< VisibilityTesting, Int>>. self )
531
+ }
532
+ }
533
+
534
+ struct VisibilityTesting2 {
535
+ func inFilePrivateContext( ) {
536
+ var xRef = \VisibilityTesting . x
537
+ var yRef = \VisibilityTesting . y
538
+ var zRef = \VisibilityTesting . z
539
+ expect ( & xRef,
540
+ toHaveType: Exactly< KeyPath< VisibilityTesting, Int>>. self )
541
+ expect ( & yRef,
542
+ toHaveType: Exactly< WritableKeyPath< VisibilityTesting, Int>>. self )
543
+ expect ( & zRef,
544
+ toHaveType: Exactly< KeyPath< VisibilityTesting, Int>>. self )
545
+ }
546
+ }
547
+
502
548
func testSyntaxErrors( ) { // expected-note{{}}
503
549
_ = \. ; // expected-error{{expected member name following '.'}}
504
550
_ = \. a ;
0 commit comments