File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,14 @@ acceptKeyPathDynamicLookup(lens.topLeft.x)
456456acceptKeyPathDynamicLookup ( lens. topLeft. y)
457457acceptKeyPathDynamicLookup ( lens. topLeft. z) // expected-error {{'z' is inaccessible due to 'private' protection level}}
458458
459+ var tupleLens = Lens < ( String , Int ) > ( ( " ultimate question " , 42 ) )
460+ _ = tupleLens. 0 . count
461+ _ = tupleLens. 1
462+
463+ var namedTupleLens = Lens < ( question: String , answer: Int ) > ( ( question: " ultimate question " , answer: 42 ) )
464+ _ = namedTupleLens. question. count
465+ _ = namedTupleLens. answer
466+
459467@dynamicMemberLookup
460468class A < T> {
461469 var value : T
@@ -607,3 +615,11 @@ func keypath_with_trailing_closure_subscript(_ ty: inout SubscriptLens<WithTrail
607615 _ = ty [ ] { 42 } // expected-error {{subscript index of type '() -> Int' in a key path must be Hashable}}
608616 _ = ty [ ] { 42 } = 0 // expected-error {{subscript index of type '() -> Int' in a key path must be Hashable}}
609617}
618+
619+ func keypath_to_subscript_to_property( _ lens: inout Lens < Array < Rectangle > > ) {
620+ _ = lens [ 0 ] . topLeft. x
621+ _ = lens [ 0 ] . topLeft. y
622+ _ = lens [ 0 ] . topLeft. x = Lens ( 0 )
623+ _ = lens [ 0 ] . topLeft. y = Lens ( 1 ) // FIXME(diagnostics): Diagnostic should point to 'y' instead of 'lens'
624+ // expected-error@-1 {{cannot assign through dynamic lookup property: 'lens' is immutable}}
625+ }
You can’t perform that action at this time.
0 commit comments