Skip to content

Commit 1d5e3d4

Browse files
authored
Merge pull request #37246 from xedin/test-case-for-valid-type-arg-of-subscript
[TypeChecker] NFC: Add a test-case for expression affected by rdar://61749633
2 parents 7f4fbf9 + 3b54fdb commit 1d5e3d4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Constraints/subscript.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,15 @@ func rdar61084565() {
216216
let a = Foo()
217217
a[] // expected-error {{value of type 'Foo' has no subscripts}}
218218
}
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

Comments
 (0)