Revision 42e827e6e7247224c068a9dce8f6eabd2ab892ba authored by Devin Coughlin on 21 January 2016, 00:12:56 UTC, committed by Devin Coughlin on 21 January 2016, 01:22:15 UTC
1 parent ac1f5a6
Raw File
objc_bridging_generics.swift
// RUN: %target-swift-frontend -sdk %S/../Inputs/clang-importer-sdk -I %S/../Inputs/clang-importer-sdk/swift-modules -enable-source-import -parse -parse-as-library -verify %s

// REQUIRES: objc_interop

import Foundation

func testNSArrayBridging(hive: Hive) {
  _ = hive.bees as [Bee]
}

func testNSDictionaryBridging(hive: Hive) {
  _ = hive.beesByName as [String : Bee] // expected-error{{value of optional type '[String : Bee]?' not unwrapped; did you mean to use '!' or '?'?}}

  var dict1 = hive.anythingToBees
  let dict2: [NSObject : Bee] = dict1
  dict1 = dict2
}

func testNSSetBridging(hive: Hive) {
  _ = hive.allBees as Set<Bee>
}

public func expectType<T>(_: T.Type, inout _ x: T) {}

func testNSMutableDictionarySubscript(
  dict: NSMutableDictionary, key: NSCopying, value: AnyObject) {
  var oldValue = dict[key]
  expectType(Optional<AnyObject>.self, &oldValue)

  dict[key] = value
}
back to top