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

Protocol stubs include __consuming and __owned



    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
    • Environment:

      Reproduced in Xcode 11 beta 3 and Swift Development Snapshot 2019-07-11 (a)


      When Swift offers to apply protocol stubs in Xcode, the fix-it produced may include the __consuming and __owned modifiers, which are not currently a supported part of the language and are not intended to be used in most conformances even once they are officially added.

      Steps To Reproduce:
      Although this is a compiler bug, the printed form of compiler diagnostics doesn't display fix-its in sufficient detail to easily demonstrate it. It's most easily reproduced in an Xcode with an appropriate toolchain:

      1. Create a new Xcode project with this code in a Swift source file:

      struct MyType: Hashable {
        typealias Element = Int
      extension MyType: SetAlgebra {}

      2. Build it.
      3. Click the error badge on the extension line, then click the “Fix” button to apply the fix-it.

      Some of the stubbed declarations include __consuming and/or __owned modifiers, such as:

      __consuming func union(_ other: __owned MyType) -> MyType

      I would not expect Swift to suggest these modifiers, since they aren’t officially part of the language. Instead I would expect it to drop these keywords:

      func union(_ other: MyType) -> MyType

      Even after we fully support move-only types, I would expect the protocol stubs for a non-move-only conformance to remove unnecessary move-only–related modifiers so that users don't need to worry about this complexity.




            • Assignee:
              brentdax Brent Royal-Gordon
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: