Uploaded image for project: 'Swift'
  1. Swift
  2. SR-6803

Accept same-file extensions for automatic synthesis of Equatable/Hashable

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:
    • Environment:

      Swift version 4.1-dev (LLVM ef53654946, Clang f7df1e5a04, Swift 831b78cdc6)

      Description

      Conditional conformance doesn't work well with automatic synthesis of Equatable/Hashable because the only way to define conformance is in extensions, but automatic synthesis isn't allowed there.

      Consider:

      struct A<T> {
        let t: T
      }
      
      extension A: Equatable where T: Equatable {}
      

      Expected result:

      Code compiles, and Equatable is synthesized

      Actual result:

      error: repl.swift:5:1: error: type 'A<T>' does not conform to protocol 'Equatable'
      extension A: Equatable where T: Equatable {}
      

      See https://twitter.com/dgregor79/status/954524765003292672.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                NachoSoto Nacho Soto
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: