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

Not correct function types in Swift4 (typeof)

    XMLWordPrintable

    Details

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

      swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-01-a-osx

      Description

      Mark Lacey <mark.lacey@apple.com> asked to create this issue.

      I believe fooParam should have type of (Int,Int) -> () and fooTuple of type ((Int,Int)) -> (), but it seems like they have the same type:

      func fooParam(_ x: Int, _ y: Int){}
      func fooTuple(_ x: (Int, Int)) {}
      
      print("type of fooParam is", type(of:fooParam))
      // result: type of fooParam is (Int, Int) -> ()
      
      print("type of fooTuple is", type(of:fooTuple))
      // result: type of fooTuple is (Int, Int) -> ()
      
      print("type of fooTuple as (_:(Int,Int))->Void is", type(of: fooTuple as (_:(Int,Int))->()))
      // result: type of fooTuple as (_:(Int,Int))->() is (Int, Int) -> ()
      
      print("type of fooParam == type of fooTuple ?", type(of: fooParam) == type(of: fooTuple))
      // result: true
      
      //--- closure ---
      
      var closureParam = { (x: Int, y: Int) in  }
      var closureTuple = { (x: (Int, Int)) in  }
      
      print("type of closureParam is", type(of:closureParam))
      // result: type of closureParam is (Int, Int) -> ()
      
      print("type of closureTuple is", type(of:closureTuple))
      // result: type of closureTuple is (Int, Int) -> ()
      
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              xedin Pavel Yaskevich
              Reporter:
              VladimirS Vladimir
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated: