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

Extension methods visible without importing module in a file

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
      None

      Description

      The attached package contains three targets:
      1. foo - defines a Version struct which can be initialized by a string param.
      2. bar - depends on foo and defines an extension with an initializer to Version with no parameters
      3. exe - depends on foo and bar and has two files.
      other.swift - imports bar
      main.swift - imports foo and calls Version()

      This should not compile or run because Version() is defined in bar and bar is not imported in main.swift.
      It works as expected after removing `import bar` from other.swift (needs a swift package clean though).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                aciid Ankit Aggarwal
              • Votes:
                5 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated: