title: Confused by Ambiguous Reference Member Reference error in Swift
body: <p>Given this workspace example:</p>
  
  <pre><code>import Foundation
  import CoreBluetooth
  
  class Something: NSObject, CBPeripheralDelegate {
      var peripheral:CBPeripheral!
  
      func peripheral(peripheral: CBPeripheral, didUpdateValueForDescriptor descriptor: CBDescriptor, error: NSError?) {
  
      }
  
      func foobar() {
          self.peripheral.writeValue([], forDescriptor: 0) // I use a real value instead of 0 in real code
      }
  }
  </code></pre>
  
  <p>I get errors that look like:</p>
  
  <pre><code>Playground execution failed: Playground2.playground:6:3: error: ambiguous reference to member 'peripheral'
                  self.peripheral.writeValue([], forDescriptor: 0)
                  ^~~~
  Playground2.playground:5:6: note: found this candidate
          var peripheral:CBPeripheral!
              ^
  Playground2.playground:1:7: note: found this candidate
          func peripheral(peripheral: CBPeripheral, didUpdateValueForDescriptor descriptor: CBDescriptor, error: NSError?) {
  </code></pre>
  
  <p>So, it can't seem to decide if my <code>self.peripheral</code> code is a reference to my variable named <code>peripheral</code> or one of the delegate functions I've chosen to implement? I guess I could rename my <code>peripheral</code> variable to be something else... </p>
  
  <p>But what surprises me is that if I construct what seems like a similar example, it has no issues disambiguating:</p>
  
  <pre><code>import Foundation
  
  extension Int {
      func frobnicate() { }
      func barf() { }
  }
  
  class YakAttack: NSObject {
      var something:Int!
  
      func something(something:Int, else:Int) {
  
      }
  
      func foobar() {
          self.something.frobnicate()
      }
  }
  </code></pre>
  
  <p>The <code>foobar()</code> function should have the same issue with the <code>self.something</code> reference, but it has no such problem. What's the difference?</p>
  
  <p>(I am using XCode 7.3 Beta 5, which has the latest Swift version in it)</p>