Skip to content

Commit a84833b

Browse files
committed
[test] Add AnyObject construction test case
This is a case where a constructor overload choice might currently have an optional opened type, so make sure we can handle it. Arguably we shouldn't even be introducing constructors into the overload set here though, as it's invalid anyway.
1 parent 5c01efa commit a84833b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/Constraints/dynamic_lookup.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,10 @@ func test_dynamic_subscript_accepts_type_name_argument() {
453453
// expected-note@-2 {{use '.self' to reference the type object}} {{20-20=.self}}
454454
}
455455
}
456+
457+
func testAnyObjectConstruction(_ x: AnyObject) {
458+
AnyObject() // expected-error {{protocol type 'AnyObject' cannot be instantiated}}
459+
460+
// FIXME(SR-15210): This should also be rejected.
461+
_ = type(of: x).init()
462+
}

0 commit comments

Comments
 (0)