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

Emit multiple vtable entries for overrides that change calling convention

    XMLWordPrintable

    Details

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

      Swift 2.2 (command line invocation of compiler)

      Description

      The code below generates a type error claiming that the "override" keyword is needed. Once it is added, the type checker will be happy, but the compiler will crash during an optimization phase. I don't believe that the demand for the "override" keyword is warranted since the code will compile and execute fine without it when the argument types are Int? and Int?? instead of Int and Int?.

      class BaseClass {
        func f(x: Int) { print("BaseClass.f(Int) [more specific]") }
      }
      
      class DerivedClass: BaseClass {
        //override
        func f(x: Int?) { print("DerivedClass.f(Int?) [more general]") }
      }
      
      class X: DerivedClass {}
      
      X().f(1)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                slavapestov Slava Pestov
                Reporter:
                gold_hat Aaron Bohannon
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: