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
Dispatch_test.swift
// RUN: %target-parse-verify-swift %clang-importer-sdk

// REQUIRES: objc_interop

// This test is deliberately using the importer SDK because not all SDKs have
// the protocols underlying the dispatch types ultimately inheriting from
// NSObjectProtocol.

import Dispatch
import Foundation

func test(queue: dispatch_queue_t) {
  let base: NSObjectProtocol = queue
  let _: dispatch_object_t = queue

  let _ = base as? dispatch_queue_t

  // Make sure the dispatch types are actually distinct types!
  let _ = queue as dispatch_source_t // expected-error {{'dispatch_queue_t' (aka 'OS_dispatch_queue') is not convertible to 'dispatch_source_t'}} {{17-19=as!}}
}

// Make sure you can extend a dispatch type via its common name.
extension dispatch_queue_t {
  func async(block: () -> Void) {
    dispatch_async(self, block)
  }
}
back to top