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

Types in modules cannot be uniquely referenced if a type and module have the same name.

    XMLWordPrintable

    Details

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

      OS X 10.11.4 (15E65), Xcode 7.3, snapshot: swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a.xctoolchain

      Description

      Scenario:

      import MyFramework // <- has a public struct "A"
      
      struct A {} // internal to my project
      
      let a = MyFramework.A()  // <- Type MyFramework has no member "A"
      

      It seems one can't reference the imported struct of the module MyFramework. If one uses `let a = A()` the internal struct is used (which, of course, makes sense).

      A related issue came up recently on Stackoverflow: http://stackoverflow.com/questions/36991735/how-to-reference-a-type-in-a-module-that-has-a-type-with-the-same-name-as-the-mo

      The problem here is only a little bit different (the class/struct with the same name as the framework is in another framework, not in the local project as above):

      // in framework Something
      public struct A {}
      public class Something {}
      
      // in framework OtherThing
      public struct A {}
      
      // in the project
      import Something
      import OtherThing
      
      let a = Something.A()  // <- "A" is not a member of type "Something"
      

      I have attached a workspace with 2 framework projects and an iOS project that demonstrates the issue.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              Dennis Dennis Weissmann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: