Skip to content

Commit d6346f4

Browse files
authored
Merge pull request #28575 from xedin/rdar-22046487
[TypeChecker] NFC: Add a test-case for rdar://problem/22046487
2 parents 245aac3 + 6fbfe30 commit d6346f4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/Generics/class_constraint.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ where T.B.A: AnyObject, U.B: AnyObject, T.B == T.B.A, U.B.A == U.B {
4545
requiresAnyObject(t.b.a)
4646
requiresAnyObject(u.b.a)
4747
}
48+
49+
func test_class_constraint_diagnostics_with_contextual_type() {
50+
func foo<T : AnyObject>(_: AnyObject) -> T {} // expected-note 2 {{where 'T' = 'P'}}
51+
52+
class A : P {}
53+
54+
// TODO(diagnostics): We could also add a note here that protocols do not conform to themselves
55+
56+
let _: P = foo(A() as AnyObject) // expected-error {{local function 'foo' requires that 'P' be a class type}}
57+
let _: P = foo(A()) // expected-error {{local function 'foo' requires that 'P' be a class type}}
58+
}

0 commit comments

Comments
 (0)