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

KeyPath: should infer class from argument types

    XMLWordPrintable

    Details

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

      Description

      From https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20180108/006876.html

      This code does not compile, although you would expect that the compiler has everything it needs to infer the class for the keypath.

      class ThePath {
          var isWinding:Bool?
      }
      
      func walk<T>(aPath:T, forKey:PartialKeyPath<T>) {}
      
      func walkThePath(aPath:ThePath, forKey:PartialKeyPath<ThePath>) {}
      
      func test() {
          let path = ThePath()
          walkThePath(aPath:path, forKey:\.isWinding)
          walk(aPath:path, forKey:\.isWinding)
      }

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              hexdreamer Kenny Leung
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: