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

Generic argument deduction disabled in generic context

    XMLWordPrintable

    Details

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

      Description

      This should work, but doesn't:

      (swift) struct X<T> {
                init(_: T) {}
                func f() {
                  print(X(3))
              }
              }
      <REPL Input>:4:13: error: 'Int' is not convertible to 'T'
          print(X(3))
                 ~^~
      (swift)
      

      The problem is that inside X, all mentions of X without explicit generic parameters are assumed to be Self, rather than only using that deduction as a last resort. It's very inconvenient in my particular use-case!

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dabrahams Dave Abrahams
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: