title: Compile error with simple Swift extension on NSObject
body: <p>I'm trying to write a set of extensions that make dealing with JSON objects simpler in swift.  Here is a sample of the extension code I have set up:</p>
  
  <pre><code>import Foundation
  
  extension NSData {
      var JSONObject: AnyObject? {
          return parseJSONObject(self)
      }
  }
  
  extension String {
      var JSONObject: AnyObject? {
          return self.dataUsingEncoding(NSUTF8StringEncoding).JSONObject
      }
  }
  
  func parseJSONObject(object: NSData) -&gt; AnyObject? {
      var error: NSError?
      var result : AnyObject? = NSJSONSerialization.JSONObjectWithData(object as NSData, options: NSJSONReadingOptions.MutableContainers, error: &amp;error)
  
      if error {
          println("Error parsing JSON object from: \(object)");
      }
  
      return result
  }
  </code></pre>
  
  <p>This code works when I use it for String objects, but it does not work on NSData objects external to this file.  The strange part is that the String extension calls the NSData extension code and works fine from within the file.  Does anyone know what the problem may be?</p>
  
  <pre><code>import XCTest
  
  let testJSONString = "{\"foo\":\"bar\"}"
  
  class JSONTests: XCTestCase {
      let testJSONData = testJSONString.dataUsingEncoding(NSUTF8StringEncoding)
  
      override func setUp() {
          super.setUp()
      }
  
      override func tearDown() {
          super.tearDown()
      }
  
      // This test compiles with no problem, as I am using the extension on a Swift String.
      func testParseString() {
          var fooValue: String? = testJSONString.JSONObject!["foo"] as? String
          XCTAssertTrue(fooValue == "bar", "Value for key 'foo' should be 'bar' for parsed JSON string")
      }
  
      // This method causes a compiler error I assume, because I am using the NSData extension
      func testParseData() {
          var fooValue: String? = testJSONData.JSONObject!["foo"] as? String
          XCTAssertTrue(fooValue == "bar", "Value for key 'foo' should be 'bar' for parsed JSON string")
      }
  }
  </code></pre>
  
  <p>Here is the error that I am seeing:</p>
  
  <pre><code>CompileSwift normal i386 com.apple.xcode.tools.swift.compiler
      cd /Users/phogan/Software/BanDedo/SwiftKit
      export PATH="/Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode6-Beta.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
      /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -target i386-apple-ios8.0 -module-name SwiftKitTests -O0 -sdk /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -g -module-cache-path /Users/phogan/Library/Developer/Xcode/DerivedData/ModuleCache -I /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Products/Debug-iphonesimulator -F /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Products/Debug-iphonesimulator -F /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/Developer/Library/Frameworks -F /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -F /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/Developer/Library/Frameworks -c -j8 /Users/phogan/Software/BanDedo/SwiftKit/SwiftKit/Application/PlanckTags.swift /Users/phogan/Software/BanDedo/SwiftKit/Belt/JSON.swift /Users/phogan/Software/BanDedo/SwiftKit/SwiftKitTests/Belt/JSONTests.swift /Users/phogan/Software/BanDedo/SwiftKit/Planck/Planck.swift /Users/phogan/Software/BanDedo/SwiftKit/Belt/RingBuffer.swift /Users/phogan/Software/BanDedo/SwiftKit/SwiftKitTests/Planck/PlanckTests.swift /Users/phogan/Software/BanDedo/SwiftKit/SwiftKitTests/Belt/RingBufferTests.swift -output-file-map /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/SwiftKitTests-OutputFileMap.json -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/SwiftKitTests.swiftmodule -Xcc -iquote -Xcc /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-generated-files.hmap -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-own-target-headers.hmap -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-project-headers.hmap -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Products/Debug-iphonesimulator/include -Xcc -I/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/DerivedSources/i386 -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DDEBUG=1 -emit-objc-header -emit-objc-header-path /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/SwiftKitTests-Swift.h
  
  0  swift                    0x000000010c4c0608 llvm::sys::PrintStackTrace(__sFILE*) + 40
  1  swift                    0x000000010c4c0af4 SignalHandler(int) + 452
  2  libsystem_platform.dylib 0x00007fff914b25aa _sigtramp + 26
  3  libsystem_platform.dylib 0x0000000000000004 _sigtramp + 1857346164
  4  swift                    0x000000010b8c47b2 swift::irgen::emitVirtualMethodValue(swift::irgen::IRGenFunction&amp;, llvm::Value*, swift::SILType, swift::SILDeclRef, swift::CanTypeWrapper&lt;swift::SILFunctionType&gt;, swift::ResilienceExpansion) + 434
  5  swift                    0x000000010b9300d3 swift::SILVisitor&lt;(anonymous namespace)::IRGenSILFunction, void&gt;::visit(swift::ValueBase*) + 42611
  6  swift                    0x000000010b925266 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8678
  7  swift                    0x000000010b8a66f8 swift::irgen::IRGenModule::emitGlobalTopLevel() + 184
  8  swift                    0x000000010b9126e3 performIRGeneration(swift::IRGenOptions&amp;, swift::Module*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&amp;, swift::SourceFile*, unsigned int) + 1859
  9  swift                    0x000000010b913033 swift::performIRGeneration(swift::IRGenOptions&amp;, swift::SourceFile&amp;, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&amp;, unsigned int) + 51
  10 swift                    0x000000010b88565a frontend_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) + 4842
  11 swift                    0x000000010b88435d main + 1533
  12 libdyld.dylib            0x00007fff8d5c55fd start + 1
  13 libdyld.dylib            0x0000000000000042 start + 1923328582
  Stack dump:
  0.  Program arguments: /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/phogan/Software/BanDedo/SwiftKit/SwiftKit/Application/PlanckTags.swift /Users/phogan/Software/BanDedo/SwiftKit/Belt/JSON.swift -primary-file /Users/phogan/Software/BanDedo/SwiftKit/SwiftKitTests/Belt/JSONTests.swift /Users/phogan/Software/BanDedo/SwiftKit/Planck/Planck.swift /Users/phogan/Software/BanDedo/SwiftKit/Belt/RingBuffer.swift /Users/phogan/Software/BanDedo/SwiftKit/SwiftKitTests/Planck/PlanckTests.swift /Users/phogan/Software/BanDedo/SwiftKit/SwiftKitTests/Belt/RingBufferTests.swift -enable-objc-attr-requires-objc-module -target i386-apple-ios8.0 -module-name SwiftKitTests -sdk /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -I /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Products/Debug-iphonesimulator -F /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Products/Debug-iphonesimulator -F /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/Developer/Library/Frameworks -F /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -F /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/Developer/Library/Frameworks -g -module-cache-path /Users/phogan/Library/Developer/Xcode/DerivedData/ModuleCache -Xcc -iquote -Xcc /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-generated-files.hmap -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-own-target-headers.hmap -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/SwiftKitTests-project-headers.hmap -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Products/Debug-iphonesimulator/include -Xcc -I/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/DerivedSources/i386 -Xcc -I/Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DDEBUG=1 -emit-module-doc-path /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/JSONTests~partial.swiftdoc -O0 -emit-module-path /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/JSONTests~partial.swiftmodule -serialize-diagnostics-path /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/JSONTests.dia -emit-dependencies-path /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/JSONTests.d -o /Users/phogan/Library/Developer/Xcode/DerivedData/SwiftKit-btmjklrksylmiohgevkkbihmktno/Build/Intermediates/SwiftKit.build/Debug-iphonesimulator/SwiftKitTests.build/Objects-normal/i386/JSONTests.o 
  1.  While emitting IR SIL function @_TFC13SwiftKitTests9JSONTests13testParseDatafS0_FT_T_ for 'testParseData' at /Users/phogan/Software/BanDedo/SwiftKit/SwiftKitTests/Belt/JSONTests.swift:29:5
  &lt;unknown&gt;:0: error: unable to execute command: Segmentation fault: 11
  &lt;unknown&gt;:0: error: swift frontend command failed due to signal (use -v to see invocation)
  Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254
  </code></pre>