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

Redeclaring a variable with a type in a generic extension doesn't error

    XMLWordPrintable

    Details

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

      Swift version 4.2-dev (LLVM cef3fe6d75, Clang bdc970d89c, Swift 5b60ace4b3)
      Target: x86_64-apple-darwin17.4.0

      Description

      This correctly doesn't compile:

      struct S {}
      extension S {
        static var i: Int { return 0 }
        struct i {} // error: Invalid redeclaration of 'i'
      }
      

      But this does compile:

      struct S1<T> {}
      extension S1 {
        static var i: Int { return 0 }
        struct i {} // This is fine!
      }
      

        Attachments

          Activity

            People

            • Assignee:
              originaluser2 Hamish Knight
              Reporter:
              originaluser2 Hamish Knight
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: