Skip to content

Commit 7af4539

Browse files
committed
Add testcase for @_implements typechecking diagnostics.
1 parent 0894464 commit 7af4539

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-swift-frontend -typecheck -verify %s
2+
3+
protocol NeedsF0 {
4+
func f0() // expected-note {{protocol requires function 'f0()' with type '() -> ()'; do you want to add a stub?}}
5+
}
6+
7+
struct S0 : NeedsF0 { // expected-error {{type 'S0' does not conform to protocol 'NeedsF0'}}
8+
@_implements(NeedsF0, f0())
9+
func g0() -> Bool { // expected-note {{candidate has non-matching type '() -> Bool'}}
10+
return true
11+
}
12+
13+
@_implements(NeedsF0, ff0()) // expected-error {{protocol 'NeedsF0' has no member 'ff0()'}}
14+
func gg0() {
15+
}
16+
17+
@_implements(Int, zz) // expected-error {{non-protocol type in @_implements attribute}}
18+
static func gg1(x:S0, y:S0) -> Bool {
19+
}
20+
21+
@_implements(Equatable, ==(_:_:)) // expected-error {{containing type 'S0' does not conform to protocol 'Equatable'}}
22+
static func gg2(x:S0, y:S0) -> Bool {
23+
}
24+
}
25+

0 commit comments

Comments
 (0)