@@ -15,6 +15,8 @@ struct ImplicitMembers: Equatable {
15
15
}
16
16
17
17
static var implicit = ImplicitMembers ( )
18
+ static let implicitLet = ImplicitMembers ( ) // expected-note2 {{change 'let' to 'var' to make it mutable}}
19
+ static var implicitImmutable : ImplicitMembers { ImplicitMembers ( ) }
18
20
static func createImplicit( ) -> ImplicitMembers {
19
21
ImplicitMembers ( )
20
22
}
@@ -61,6 +63,7 @@ struct ImplicitMembers: Equatable {
61
63
get { ImplicitMembers ( ) }
62
64
set { }
63
65
}
66
+ subscript( immutable arg: Void ) -> ImplicitMembers { ImplicitMembers ( ) }
64
67
subscript( func arg: Void ) -> ( ( ) -> ImplicitMembers ) { { ImplicitMembers ( ) } }
65
68
subscript( funcOptional arg: Void ) -> ( ( ) -> ImplicitMembers ? ) { { ImplicitMembers ( ) } }
66
69
subscript( optionalFunc arg: Void ) -> ( ( ) -> ImplicitMembers ) ? { { ImplicitMembers ( ) } }
@@ -205,7 +208,22 @@ func testLValues() {
205
208
. implicit. anotherOptionalMutable! = local;
206
209
. implicit[ ( ) ] = local;
207
210
. implicit[ ( ) ] . anotherMutable = local;
208
- . optional? [ optional: ( ) ] ? . anotherOptionalMutable! = local
211
+ . optional? [ optional: ( ) ] ? . anotherOptionalMutable! = local;
212
+
213
+ . implicitLet = local; // expected-error {{cannot assign to property: 'implicitLet' is a 'let' constant}}
214
+ . implicitImmutable = local; // expected-error {{cannot assign to property: 'implicitImmutable' is a get-only property}}
215
+ . createImplicit( ) = local; // expected-error {{cannot assign to value: 'createImplicit' is a method}}
216
+ . implicit. another = local; // expected-error {{cannot assign to property: 'another' is a get-only property}}
217
+ . implicit[ immutable: ( ) ] = local; // expected-error {{cannot assign through subscript: subscript is get-only}}
218
+ . implicit. getAnother ( ) = local; // expected-error {{expression is not assignable: function call returns immutable value}}
219
+
220
+ . implicitLet. anotherMutable = local; // expected-error {{cannot assign to property: 'implicitLet' is a 'let' constant}}
221
+ . implicitImmutable. anotherMutable = local; // expected-error {{cannot assign to property: 'implicitImmutable' is a get-only property}}
222
+ . createImplicit( ) . anotherMutable = local; // expected-error {{cannot assign to value: 'createImplicit' is a method}}
223
+ . implicit. another. anotherMutable = local; // expected-error {{cannot assign to property: 'another' is a get-only property}}
224
+ . implicit[ immutable: ( ) ] . anotherMutable = local; // expected-error {{cannot assign to property: subscript is get-only}}
225
+ . implicit. getAnother ( ) . anotherMutable = local; // expected-error {{cannot assign to property: function call returns immutable value}}
226
+
209
227
210
228
// FIXME: These should probably be allowed
211
229
//.implicit.anotherOptionalMutable = local;
0 commit comments