File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -3456,7 +3456,7 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
3456
3456
break ;
3457
3457
3458
3458
case CheckKind::RequiresConcreteImplementation:
3459
- diagnoseOrDefer (requirement, false ,
3459
+ diagnoseOrDefer (requirement, /* isError= */ true ,
3460
3460
[witness, requirement](NormalProtocolConformance *conformance) {
3461
3461
auto &diags = witness->getASTContext ().Diags ;
3462
3462
SourceLoc diagLoc = getLocForDiagnosingWitness (conformance, witness);
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ protocol P {
4
+ @_requiresConcreteImplementation
5
+ func f( _: Int ) -> Bool // expected-note {{requirement 'f' declared here}}
6
+ // expected-note@-1 {{overridden declaration is here}}
7
+ func f< T: SignedInteger > ( _: T ) -> Bool
8
+
9
+ func g( _: Int ) -> Bool
10
+ }
11
+
12
+ extension P {
13
+ func f< T: SignedInteger > ( _ x: T ) -> Bool { // expected-note {{'f' declared here}}
14
+ return f ( Int ( x) )
15
+ }
16
+
17
+ func g( _ x: Int ) -> Bool { // expected-note {{'g' declared here}}
18
+ return f ( x)
19
+ }
20
+ }
21
+
22
+ protocol Q : P {
23
+ override func f( _: Int ) -> Bool // expected-error {{override of protocol requirement marked '@_requiresConcreteImplementation' should also be marked }}
24
+ }
25
+
26
+ protocol R : P {
27
+ @_requiresConcreteImplementation
28
+ override func g( _: Int ) -> Bool // expected-note {{requirement 'g' declared here}}
29
+ }
30
+
31
+ struct S : P { // expected-error {{type 'S' does not conform to protocol 'P'}}
32
+ // expected-error@-1 {{protocol requirement marked '@_requiresConcreteImplementation' cannot be satisfied }}
33
+ }
34
+
35
+ struct T : P , R { // expected-error {{type 'T' does not conform to protocol 'R'}}
36
+ // expected-error@-1 {{protocol requirement marked '@_requiresConcreteImplementation' cannot be satisfied }}
37
+ func f( _: Int ) -> Bool { true }
38
+ }
39
+
40
+ struct U : R {
41
+ func f( _: Int ) -> Bool { true }
42
+ func g( _: Int ) -> Bool { false }
43
+ }
44
+
45
+ class C {
46
+ @_requiresConcreteImplementation // expected-error {{'@_requiresConcreteImplementation' can only be specified on protocol requirements}}
47
+ var x : Int = 42
48
+ }
You can’t perform that action at this time.
0 commit comments