mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
These classes don't show up well in generated headers (rdar://problem/20855568), can't actually be allocated from Objective-C (rdar://problem/17184317), and make the story of "what is exposed to Objective-C" more complicated. Better to just disallow them. All classes are still "id-compatible" in that they can be converted to AnyObject and passed to Objective-C, they secretly implement NSObjectProtocol (via our SwiftObject root class), and their members can still be individually exposed to Objective-C. The frontend flag -disable-objc-attr-requires-foundation-module will disable this requirement as well, which is still necessary for both the standard library and a variety of tests I didn't feel like transforming. Swift SVN r29760
62 lines
2.9 KiB
Swift
62 lines
2.9 KiB
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse -module-name ZZZ %s -disable-objc-attr-requires-foundation-module -verify
|
|
|
|
import Foundation
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
@objc class Redecl1 { // expected-note{{implicit deinitializer declared here}}
|
|
@objc init() { } // expected-note{{initializer 'init()' declared here}}
|
|
|
|
@objc
|
|
func method1() { } // expected-note 2{{method 'method1()' declared here}}
|
|
|
|
@objc var value: Int // expected-note{{setter for 'value' declared here}}
|
|
|
|
@objc(wibble) var other: Int
|
|
// expected-note@-1{{getter for 'other' declared here}}
|
|
// expected-note@-2{{setter for 'other' declared here}}
|
|
}
|
|
|
|
extension Redecl1 {
|
|
@objc(method1)
|
|
func method1_alias() { } // expected-error{{method 'method1_alias()' with Objective-C selector 'method1' conflicts with method 'method1()' with the same Objective-C selector}}
|
|
}
|
|
|
|
extension Redecl1 {
|
|
@objc var method1_var_alias: Int {
|
|
@objc(method1) get { return 5 } // expected-error{{getter for 'method1_var_alias' with Objective-C selector 'method1' conflicts with method 'method1()' with the same Objective-C selector}}
|
|
|
|
@objc(method2:) set { } // expected-note{{setter for 'method1_var_alias' declared here}}
|
|
}
|
|
|
|
@objc subscript (i: Int) -> Redecl1 {
|
|
get { return self } // expected-note{{subscript getter declared here}}
|
|
set { }
|
|
}
|
|
}
|
|
|
|
extension Redecl1 {
|
|
@objc
|
|
func method2(x: Int) { } // expected-error{{method 'method2' with Objective-C selector 'method2:' conflicts with setter for 'method1_var_alias' with the same Objective-C selector}}
|
|
|
|
@objc(objectAtIndexedSubscript:)
|
|
func indexed(x: Int) { } // expected-error{{method 'indexed' with Objective-C selector 'objectAtIndexedSubscript:' conflicts with subscript getter with the same Objective-C selector}}
|
|
|
|
@objc(init)
|
|
func initialize() { } // expected-error{{method 'initialize()' with Objective-C selector 'init' conflicts with initializer 'init()' with the same Objective-C selector}}
|
|
|
|
@objc
|
|
func dealloc() { } // expected-error{{method 'dealloc()' with Objective-C selector 'dealloc' conflicts with implicit deinitializer with the same Objective-C selector}}
|
|
|
|
@objc func setValue(x: Int) { } // expected-error{{method 'setValue' with Objective-C selector 'setValue:' conflicts with setter for 'value' with the same Objective-C selector}}
|
|
}
|
|
|
|
extension Redecl1 {
|
|
@objc func setWibble(other: Int) { } // expected-error{{method 'setWibble' with Objective-C selector 'setWibble:' conflicts with setter for 'other' with the same Objective-C selector}}
|
|
@objc func wibble() -> Int { return 0 } // expected-error{{method 'wibble()' with Objective-C selector 'wibble' conflicts with getter for 'other' with the same Objective-C selector}}
|
|
}
|
|
|
|
extension DummyClass {
|
|
func nsstringProperty2() -> Int { return 0 } // expected-error{{method 'nsstringProperty2()' with Objective-C selector 'nsstringProperty2' conflicts with previous declaration with the same Objective-C selector}}
|
|
}
|