You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When declaring protocol conformance using an extension, it is not possible to redeclare that extension, regardless of whether the first declaration was successful or failed due to compilation errors.
This makes it difficult to quickly fix errors by modifying the broken extension and furthermore leaves types in an inconsistent state, where they are reported as being conformant but do not have required members.
Expected results:
When declaring an extension that declares protocol conformance, the extended type should not become conformant to that extension if the extension has compilation errors.
Example:
$ swift
Welcome to Apple Swift version 5.5 (swiftlang-1300.0.20.104 clang-1300.0.21.1).
Type :help for assistance.
1> struct Foo {
2. }
3> extension Foo: CustomStringConvertible {}
error: repl.swift:3:1: error: type'Foo' does not conform to protocol 'CustomStringConvertible'
extension Foo: CustomStringConvertible {}
^
Swift.CustomStringConvertible:2:9: note: protocol requires property 'description' with type'String'
var description: String
{ get }
^
3> extension Foo: CustomStringConvertible {
4. public var description: String {
5. return"Foo"
6. }
7. }
error: repl.swift:3:16: error: redundant conformance of 'Foo' to protocol 'CustomStringConvertible'
extension Foo: CustomStringConvertible {
^
repl.swift:3:1: note: 'Foo' declares conformance to protocol 'CustomStringConvertible' here
extension Foo: CustomStringConvertible {}
^
First, an invalid conformance is declared for CustomStringConvertible (missing description property).
This causes an error to be reported, but Foo is still marked as being conformant to CustomStringConvertible. (Foo() is CustomStringConvertible evaluates to true)
Environment
swift-driver version: 1.26 Apple Swift version 5.5 (swiftlang-1300.0.20.104 clang-1300.0.21.1)
Target: x86_64-apple-macosx12.0
macOS 12.0 Beta (21A5248p)
Xcode 13.0 beta (13A5155e)
Additional Detail from JIRA
md5: 06bb3073af23d7520736a35596a0eb6d
Issue Description:
Description
When declaring protocol conformance using an extension, it is not possible to redeclare that extension, regardless of whether the first declaration was successful or failed due to compilation errors.
This makes it difficult to quickly fix errors by modifying the broken extension and furthermore leaves types in an inconsistent state, where they are reported as being conformant but do not have required members.
Expected results:
When declaring an extension that declares protocol conformance, the extended type should not become conformant to that extension if the extension has compilation errors.
Example:
First, an invalid conformance is declared for
CustomStringConvertible
(missingdescription
property).This causes an error to be reported, but
Foo
is still marked as being conformant toCustomStringConvertible
. (Foo() is CustomStringConvertible
evaluates totrue
)When declaring a function, such as
and calling it with an instance of
Foo
following the initial, broken conformance declaration, a symbol lookup error is raised:The text was updated successfully, but these errors were encountered: