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

Automatic initializer inheritance doesn't work for generic types.

    XMLWordPrintable

    Details

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

      Description

      For such code:

      public class A<T : Any> { 
          public init(n : Int) { 
              print("A")
          } 
      } 
      public class B : A<Int> {
      }
      let x = B(n: 123)
      
      

      The two rules from documation have no effect.

      Rule 1 “If your subclass doesn’t define any designated initializers, it automatically inherits all of its superclass designated initializers.”
      Rule 2 “If your subclass provides an implementation of all of its superclass designated initializers—either by inheriting them as per rule 1, or by providing a custom implementation as part of its definition—then it automatically inherits all of the superclass convenience initializers.”

      For more details see http://stackoverflow.com/questions/34525368/initializers-from-generic-types-wont-be-inherited-in-swift

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                slavapestov Slava Pestov
                Reporter:
                AntiMoron Boyuan Gao
              • Votes:
                8 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: