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

Existential Metatype in generics

    XMLWordPrintable

    Details

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

      Swift 4.0 (57bb55f0bf)

      Description

      The bug appears with the following (supposedly correct) code:

       

       

      class C {
          let s: String
          required init(s: String) {
              self.s = s
          }
      }
       
      protocol D {
          var x: String { get set }
      }
       
      class V: C, D {
          var x: String = "123"
      }
       
      typealias X = C & D
       
      class B {
          func f<T>(_ type: T.Type, s: String) -> T where T: C, T: D {
              return type.init(s: s)
          }
       }
      let t: X.Type = V.self
      let x: C = B().f(t, s: "Test")
      

       

      Result is 

      error: generic parameter 'T' could not be inferred

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              morpheby Ilya Mikhaltsou
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: