We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7f4fbf9 + 3b54fdb commit 1d5e3d4Copy full SHA for 1d5e3d4
test/Constraints/subscript.swift
@@ -216,3 +216,15 @@ func rdar61084565() {
216
let a = Foo()
217
a[] // expected-error {{value of type 'Foo' has no subscripts}}
218
}
219
+
220
+func test_subscript_accepts_type_name_argument() {
221
+ struct A {
222
+ subscript(a: A.Type) -> Int { get { 42 } }
223
+ }
224
225
+ func test(a: A?) {
226
+ let _ = a?[A] // expected-error {{expected member name or constructor call after type name}}
227
+ // expected-note@-1 {{add arguments after the type to construct a value of the type}} {{17-17=()}}
228
+ // expected-note@-2 {{use '.self' to reference the type object}} {{17-17=.self}}
229
230
+}
0 commit comments