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

LLVM error when assigning protocol function to variable

    XMLWordPrintable

    Details

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

      Xcode 7.3 (iOS and OS X SDKs)

      Description

      I know this might not be valid and may become a normal error in Swift 3 but I thought I should report it anyway.

      import Foundation
      
      @objc protocol TestProtocol {
          func foo(i: Int)
      }
      
      class Test : TestProtocol {
          @objc func foo(i: Int) {
          }
      }
      
      func bar(t: TestProtocol?) {
          let foofunc = t?.foo
          foofunc?(5)
      }
      

      Results in:

      xcrun -sdk macosx swiftc -v main.swift
      Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)
      Target: x86_64-apple-macosx10.9
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file main.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name main -o /var/folders/n7/l0f7j3655lz047816hj6p3mr0000gn/T/main-014dff.o
      Incorrect number of arguments passed to called function!
        call void @_TTOFP4main12TestProtocol3foofSiT_(i64 %0, %objc_object* %6) #0
      LLVM ERROR: Broken function found, compilation aborted!
      

      This was quite hard to find in a big project. I needed to do command line build with -j1

      This may be related to SR-44 but it didn't seem to match completely.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              slavapestov Slava Pestov
              Reporter:
              josephlord Joseph Lord
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: