forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjc_redeclaration.swift
81 lines (59 loc) · 3.77 KB
/
objc_redeclaration.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -module-name ZZZ %s -disable-objc-attr-requires-foundation-module -verify -verify-ignore-unknown
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-error{{setter for 'method1_var_alias' with Objective-C selector 'method2:' conflicts with method 'method2' with the same Objective-C selector}}
}
@objc subscript (i: Int) -> Redecl1 {
get { return self } // expected-note{{subscript getter declared here}}
set { }
}
}
extension Redecl1 {
@objc
func method2(_ x: Int) { } // expected-note{{method 'method2' declared here}}
@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 {
@objc func nsstringProperty2() -> Int { return 0 } // expected-error{{method 'nsstringProperty2()' with Objective-C selector 'nsstringProperty2' conflicts with getter for 'nsstringProperty2' with the same Objective-C selector}}
}
open class MyObject: NSObject {} // expected-note{{implicit initializer 'init()' declared here}}
extension MyObject {
public override convenience init() {} // expected-error{{initializer 'init()' with Objective-C selector 'init' conflicts with implicit initializer 'init()' with the same Objective-C selector}}
}
// Ensure that we don't have cycles with the "renamed decl" request.
@available(SwiftStdlib 5.1, *)
@objc protocol MyProtocolWithAsync {
@available(*, renamed: "confirm(thing:)")
@objc(confirmThing:completion:)
optional func confirm(thing: AnyObject, completion: @escaping (AnyObject) -> Void)
@objc(confirmThing:completion:)
optional func confirm(thing: AnyObject) async -> AnyObject
}
// FIXME: Remove -verify-ignore-unknown.
// <unknown>:0: error: unexpected note produced: 'nsstringProperty2' previously declared here