Skip to content

Commit 815927a

Browse files
authored
Merge pull request #15924 from slavapestov/add-silly-testcase
Add test for https://bugs.swift.org/browse/SR-7422
2 parents dfa8a31 + 08e4e7c commit 815927a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/decl/protocol/conforms/self.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,38 @@ class NonFinalClass : P {
3535
return self
3636
}
3737
}
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 {}

0 commit comments

Comments
 (0)