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

No coverage generated for functions in extensions

    XMLWordPrintable

    Details

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

      Xcode 10.0, Xcode 10.1 (10B61). Swift 4.2, XCode 11.4

      Description

      In the example below there is no coverage data produced for extensionMethodGeneric() method.
      If return r.extensionMethodGeneric() is commented out (e.g. replace with return 0), coverage for extensionMethodGeneric() is gathered as expected (0 hits).

      import Foundation
      
      struct MyGenericStruct<T> {
          var value: T
      }
      
      class MyClass {
          func method() -> Int {
              let r = MyGenericStruct<Int>(value: 0)
              return r.extensionMethodGeneric()
          }
      }
      
      extension MyGenericStruct {
          func extensionMethodGeneric() -> Int {
              print("extensionMethodGeneric called")
              return 0
          }
      }
      XCTAssertNotNil(MyClass())
      

       

      Upd: issue also reproduces if instead of a generic type a regular struct is used.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            hybridcattt Marina Gornostaeva
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated: