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

Async overloading in protocol implementation fails

    XMLWordPrintable

    Details

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

      swift-driver version: 1.26.9 Apple Swift version 5.5 (swiftlang-1300.0.29.102 clang-1300.0.28.1)

      Target: x86_64-apple-macosx12.0

      MacOS: 12.0 Beta (21A5506j)

      Description

      Amendment https://github.com/apple/swift-evolution/pull/1392 is incomplete.

      Compilation fails, when class with both async and async method versions trying to satisfy protocol requirement with both sync and async methods or just async method implementation.

       

      protocol TestProtocol {
          func read() // Compilation also fails if TestProtocol contains only async version
          func read() async
      }
      
      // Note: everything compiles and resolves correctly in call side when TestClass does not implement TestProtocol 
      class TestClass: TestProtocol {
          func read() {}
          func read() async {}
      }
      

       

      Throws several issues:

      • error: type 'TestClass' does not conform to protocol 'TestProtocol'
      • note: multiple matching functions named 'read()' with type '() async -> ()'

        Attachments

        1. Test.swift
          0.1 kB
        2. Test 2.swift
          0.1 kB

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            Nekitosss Nikita
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: