Skip to content

Add test for https://bugs.swift.org/browse/SR-7422 #15924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/decl/protocol/conforms/self.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,38 @@ class NonFinalClass : P {
return self
}
}

// Test for default implementation that comes from a constrained extension
// - https://bugs.swift.org/browse/SR-7422

// FIXME: Better error message here?

class SillyClass {}

protocol HasDefault {
func foo()
// expected-note@-1 {{protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub?}}
}

extension HasDefault where Self == SillyClass {
func foo() {}
// expected-note@-1 {{candidate has non-matching type '<Self> () -> ()'}}
}

extension SillyClass : HasDefault {}
// expected-error@-1 {{type 'SillyClass' does not conform to protocol 'HasDefault'}}

// This is OK, though
class SeriousClass {}

extension HasDefault where Self : SeriousClass {
func foo() {}
// expected-note@-1 {{candidate has non-matching type '<Self> () -> ()'}}

// FIXME: the above diangostic is from trying to check conformance for
// 'SillyClass' and not 'SeriousClass'. Evidently name lookup finds members
// from all constrained extensions, and then if any don't have a matching
// generic signature, diagnostics doesn't really know what to do about it.
}

extension SeriousClass : HasDefault {}