title: Type extensions from a framework's dependency available in app
body: <p>OK... this is difficult to explain (and to come up with a title for) but I'll try my best.</p>
  
  <p>We first discovered this when using Carthage to import stuff but setting up a sample project in Xcode (without using Carthage) it seems to have done the same thing.</p>
  
  <p>First, here's a screenshot of the sample project we set up...</p>
  
  <p><a href="https://i.stack.imgur.com/3HkKB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3HkKB.png" alt="enter image description here"></a></p>
  
  <p>The have a target <strong>Test20000</strong> and it has a dependency <strong>A</strong>.</p>
  
  <p>The <strong>A</strong> framework then has a dependency on <strong>B</strong>.</p>
  
  <h2>Important</h2>
  
  <p>The <strong>Test20000</strong> app does <em>NOT</em> add <strong>B</strong> as a direct dependency.</p>
  
  <h2>The frameworks</h2>
  
  <p>In <strong>B</strong> there is a struct like...</p>
  
  <pre><code>import Foundation
  
  public struct BType {
      public let value = "Hello, B!"
  }
  </code></pre>
  
  <p>In <strong>A</strong> there is a file like...</p>
  
  <pre><code>import Foundation
  import B
  
  public struct AType {
      public let value = "Hello, A!"
  
      public func doAThing() {
          print(BType().value)
      }
  }
  </code></pre>
  
  <h2>The App</h2>
  
  <p>Now in the <strong>Test20000</strong> app we do something like...</p>
  
  <pre><code>import Foundation
  import A
  
  struct TestType {
      func doSomething() {
          let aType = AType()
  
          print(aType.value)
          aType.doAThing()
      }
  }
  </code></pre>
  
  <p>This works as expected. It prints...</p>
  
  <blockquote>
    <p>Hello, A!
    Hello, B!</p>
  </blockquote>
  
  <p>If I change the function to something like this...</p>
  
  <pre><code>import Foundation
  import A
  
  struct TestType {
      func doSomething() {
          let bType = BType()
  
          print(bType.value)
      }
  }
  </code></pre>
  
  <p>Then this doesn't compile as <strong>B</strong> is not imported and so <code>BType</code> can't be accessed.</p>
  
  <h2>The catch!</h2>
  
  <p>However! If you declare an extension in <strong>B</strong> something like...</p>
  
  <pre><code>extension String {
      func doAThingInB() {
          print(self)
      }
  }
  </code></pre>
  
  <p>Then now... without any changes to the imports and the dependencies, I can now change my app code to...</p>
  
  <pre><code>import Foundation
  import A
  
  struct TestType {
      func doSomething() {
          "Hello, bug!".doAThingInB()
      }
  }
  </code></pre>
  
  <p>And this will print out as though the extension is public to the actual App. It sort of "bunny hops" from B, over A and into the app.</p>
  
  <p>I feel like this shouldn't happen at all.</p>
  
  <p>We can't find a way to turn this off or to stop this happening.</p>
  
  <p>Is this a bug?</p>
  
  <p>Is there something we need to do to stop this?</p>
  
  <p>Thanks</p>