mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
61 lines
2.4 KiB
Swift
61 lines
2.4 KiB
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse %s -verify
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import AppKit
|
|
import NotificationCenter
|
|
|
|
func testInstanceTypeFactoryMethod(queen: B) {
|
|
var hive1 = Hive(queen: queen)
|
|
|
|
var of1 = NSObjectFactory() // okay, prefers init method
|
|
var of2 = NSObjectFactory(integer: 1)
|
|
var of3 = NSObjectFactory(double: 314159)
|
|
var of4 = NSObjectFactory(float: 314159)
|
|
}
|
|
|
|
func testInstanceTypeFactoryMethodInherited() {
|
|
var of1 = NSObjectFactorySub() // okay, prefers init method
|
|
var of2 = NSObjectFactorySub(integer: 1)
|
|
var of3 = NSObjectFactorySub(double: 314159)
|
|
var of4 = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}}
|
|
var of5 = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{cannot find an initializer for type 'NSObjectFactorySub' that accepts an argument list of type '(buildingWidgets: ())'}}
|
|
}
|
|
|
|
func testNSErrorFactoryMethod(path: String) throws {
|
|
var s1 = try NSString(contentsOfFile: path)
|
|
}
|
|
|
|
func testNonInstanceTypeFactoryMethod(s: String) {
|
|
var of1 = NSObjectFactory(string: s) // expected-error{{extra argument 'string' in call}}
|
|
}
|
|
|
|
func testUseOfFactoryMethod(queen: B) {
|
|
var of1 = Hive.hiveWithQueen(queen) // expected-error{{'hiveWithQueen' is unavailable: use object construction 'Hive(queen:)'}}
|
|
}
|
|
|
|
func testNonsplittableFactoryMethod() {
|
|
var of5 = NSObjectFactory.factoryBuildingWidgets()
|
|
}
|
|
|
|
func testFactoryMethodBlacklist() {
|
|
_ = NCWidgetController.widgetController()
|
|
_ = NSProcessInfo.processInfo()
|
|
}
|
|
|
|
func test17261609() {
|
|
let num1 = NSDecimalNumber(mantissa:1, exponent:1, isNegative:true)
|
|
NSDecimalNumber.decimalNumberWithMantissa(1, exponent:1, isNegative:true) // expected-error{{'decimalNumberWithMantissa(_:exponent:isNegative:)' is unavailable: use object construction 'NSDecimalNumber(mantissa:exponent:isNegative:)'}}
|
|
}
|
|
|
|
func testURL() {
|
|
let url = NSURL(string: "http://www.llvm.org")
|
|
NSURL.URLWithString("http://www.llvm.org") // expected-error{{'URLWithString' is unavailable: use object construction 'NSURL(string:)'}}
|
|
|
|
NSURLRequest(string: "http://www.llvm.org")
|
|
NSURLRequest(URL: url)
|
|
|
|
NSURLRequest.requestWithString("http://www.llvm.org") // expected-error{{'requestWithString' is unavailable: use object construction 'NSURLRequest(string:)'}}
|
|
NSURLRequest.URLRequestWithURL(url) // expected-error{{'URLRequestWithURL' is unavailable: use object construction 'NSURLRequest(URL:)'}}
|
|
}
|