mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When an extension introduces a conformance that already exists, the type checker will reject the conformance and then ignore it. In cases where the original conformance is in the same module as the type or protocol (but the new, redundant conformance is in some other module), downgrade this error to a warning. This helps with library-evolution cases where a library omitted a particular conformance for one of its own types/protocols in a previous version, then introduces it in a new version. The specific driver for this is the conformance of String to Collection, which affects source compatibility. Fixes rdar://problem/31104415.
16 lines
572 B
Swift
16 lines
572 B
Swift
// RUN: %target-typecheck-verify-swift -swift-version 3
|
|
|
|
extension String : Collection { // expected-warning{{conformance of 'String' to protocol 'Collection' was already stated in the type's module 'Swift'}}
|
|
subscript (i: Index) -> String { // expected-note{{subscript 'subscript' will not be used to satisfy the conformance to 'Collection'}}
|
|
get { return self }
|
|
set { }
|
|
}
|
|
|
|
var isEmpty: Bool { return false } // expected-note{{var 'isEmpty' will not be used to satisfy the conformance to 'Collection'}}
|
|
|
|
}
|
|
|
|
func testStringOps(s: String) {
|
|
_ = s.isEmpty
|
|
}
|