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

Name resolution problem for packages with same-named data types

    XMLWordPrintable

    Details

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

      Problem originally spotted:
      Xcode Version 8.2.1 (8C1002)

      Attached test case:
      Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1) on macOS 10.12.4

      Description

      Normally in Swift you can resolve naming collisions using the syntax ModuleName.ObjectName. For example, if you have two packages, Foo and Bar, both with a class Snafu, you can specify Foo.Snafu and Bar.Snafu.

      However, if the package shares a name with one of the data types declared in the package, this breaks down. So, for example, in the attached test case, there is a package Sample with a struct named Sample. If you import that package into other code and then attempt to access the struct as follows

      var s = Sample.Sample()

      you get a compiler error: type 'Sample' has no member 'Sample'

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              mb2016 Matthew Burke
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: