File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
test/decl/protocol/conforms Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,38 @@ class NonFinalClass : P {
35
35
return self
36
36
}
37
37
}
38
+
39
+ // Test for default implementation that comes from a constrained extension
40
+ // - https://bugs.swift.org/browse/SR-7422
41
+
42
+ // FIXME: Better error message here?
43
+
44
+ class SillyClass { }
45
+
46
+ protocol HasDefault {
47
+ func foo( )
48
+ // expected-note@-1 {{protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub?}}
49
+ }
50
+
51
+ extension HasDefault where Self == SillyClass {
52
+ func foo( ) { }
53
+ // expected-note@-1 {{candidate has non-matching type '<Self> () -> ()'}}
54
+ }
55
+
56
+ extension SillyClass : HasDefault { }
57
+ // expected-error@-1 {{type 'SillyClass' does not conform to protocol 'HasDefault'}}
58
+
59
+ // This is OK, though
60
+ class SeriousClass { }
61
+
62
+ extension HasDefault where Self : SeriousClass {
63
+ func foo( ) { }
64
+ // expected-note@-1 {{candidate has non-matching type '<Self> () -> ()'}}
65
+
66
+ // FIXME: the above diangostic is from trying to check conformance for
67
+ // 'SillyClass' and not 'SeriousClass'. Evidently name lookup finds members
68
+ // from all constrained extensions, and then if any don't have a matching
69
+ // generic signature, diagnostics doesn't really know what to do about it.
70
+ }
71
+
72
+ extension SeriousClass : HasDefault { }
You can’t perform that action at this time.
0 commit comments