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

Compiler crash when accessing protocol extension method by type name

    XMLWordPrintable

    Details

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

      Xcode 9.4 (9F1027a)
      Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
      Target: x86_64-apple-darwin17.5.0

      Description

      Current version of swift compiler crashes on following minimal code sample

      protocol A {}
      
      extension A {
          func methodA() { print(self) }
      }
      
      extension String: A {}
      
      let array = ["One", "Two", "Three"]
          .map { $0 as? A }
          .compactMap { $0 }
          .map(A.methodA)
      
      

      Getting rid of last map (where compiler should infer type of result by the type of closure, obtained via accessing protocol extension method by typename) fixes issue

      Attached stack trace crashdump.txt

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              petro.korienev Petro Korienev
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: