Skip to content

Commit 38fdb6b

Browse files
committed
Update various tests to not use Swift 3 code
Completely mechanical changes: - Explicit @objc in a few places - Some imported APIs changed - For the mix-and-match tests, just test version 4/5 instead of 3/4
1 parent 812c56c commit 38fdb6b

22 files changed

+296
-296
lines changed

test/Compatibility/MixAndMatch/Inputs/SomeObjCModule.apinotes

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Classes:
33
- Name: NSRuncibleSpoon
44
SwiftBridge: RuncibleSpoon
55
SwiftVersions:
6-
- Version: 3
6+
- Version: 4
77
Classes:
88
- Name: NSRuncibleSpoon
99
SwiftBridge: ""

test/Compatibility/MixAndMatch/Inputs/witness_change_swift3_leaf.swift test/Compatibility/MixAndMatch/Inputs/witness_change_swift4_leaf.swift

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
11

2-
// Swift 3 sees the ObjC class NSRuncibleSpoon as the class, and uses methods
2+
// Swift 4 sees the ObjC class NSRuncibleSpoon as the class, and uses methods
33
// with type signatures involving NSRuncibleSpoon to conform to protocols
4-
// across the language boundary. Swift 4 sees the type as bridged to
4+
// across the language boundary. Swift 5 sees the type as bridged to
55
// a RuncibleSpoon value type, but still needs to be able to use conformances
6-
// declared by Swift 3.
6+
// declared by Swift 4.
77

8-
// Swift 3, importing Swift 3 and Swift 4 code
8+
// Swift 4, importing Swift 4 and Swift 5 code
99

1010
import SomeObjCModule
11-
import SomeSwift3Module
1211
import SomeSwift4Module
12+
import SomeSwift5Module
1313

1414
func testMatchAndMix(bridged: RuncibleSpoon, unbridged: NSRuncibleSpoon) {
1515
let objcInstanceViaClass
1616
= SomeObjCClass(someSwiftInitRequirement: unbridged)
1717

18-
let objcClassAsS3Protocol: SomeSwift3Protocol.Type = SomeObjCClass.self
19-
let objcInstanceViaS3Protocol
20-
= objcClassAsS3Protocol.init(someSwiftInitRequirement: unbridged)
21-
2218
let objcClassAsS4Protocol: SomeSwift4Protocol.Type = SomeObjCClass.self
2319
let objcInstanceViaS4Protocol
24-
= objcClassAsS4Protocol.init(someSwiftInitRequirement: bridged)
20+
= objcClassAsS4Protocol.init(someSwiftInitRequirement: unbridged)
21+
22+
let objcClassAsS5Protocol: SomeSwift5Protocol.Type = SomeObjCClass.self
23+
let objcInstanceViaS5Protocol
24+
= objcClassAsS5Protocol.init(someSwiftInitRequirement: bridged)
2525

2626
var bridgedSink: RuncibleSpoon
2727
var unbridgedSink: NSRuncibleSpoon
2828

2929
let swiftPropertyViaClass = objcInstanceViaClass.someSwiftPropertyRequirement
3030
unbridgedSink = swiftPropertyViaClass
31-
let swiftPropertyViaS3Protocol = objcInstanceViaS3Protocol.someSwiftPropertyRequirement
32-
unbridgedSink = swiftPropertyViaS3Protocol
3331
let swiftPropertyViaS4Protocol = objcInstanceViaS4Protocol.someSwiftPropertyRequirement
34-
bridgedSink = swiftPropertyViaS4Protocol
32+
unbridgedSink = swiftPropertyViaS4Protocol
33+
let swiftPropertyViaS5Protocol = objcInstanceViaS5Protocol.someSwiftPropertyRequirement
34+
bridgedSink = swiftPropertyViaS5Protocol
3535

3636
objcInstanceViaClass.someSwiftMethodRequirement(unbridged)
37-
objcInstanceViaS3Protocol.someSwiftMethodRequirement(unbridged)
38-
objcInstanceViaS4Protocol.someSwiftMethodRequirement(bridged)
39-
40-
let swift3InstanceViaClass
41-
= SomeSwift3Class(someObjCInitRequirement: unbridged)
42-
let swift3ClassAsProtocol: SomeObjCProtocol.Type = SomeSwift3Class.self
43-
let swift3InstanceViaProtocol
44-
= swift3ClassAsProtocol.init(someObjCInitRequirement: unbridged)
45-
46-
let objcPropertyViaClassS3 = swift3InstanceViaClass.someObjCPropertyRequirement
47-
unbridgedSink = objcPropertyViaClassS3
48-
let objcPropertyViaProtocolS3 = swift3InstanceViaProtocol.someObjCPropertyRequirement
49-
unbridgedSink = objcPropertyViaProtocolS3
50-
51-
swift3InstanceViaClass.someObjCMethodRequirement(unbridged)
52-
swift3InstanceViaProtocol.someObjCMethodRequirement(unbridged)
37+
objcInstanceViaS4Protocol.someSwiftMethodRequirement(unbridged)
38+
objcInstanceViaS5Protocol.someSwiftMethodRequirement(bridged)
5339

5440
let swift4InstanceViaClass
55-
= SomeSwift4Class(someObjCInitRequirement: bridged)
41+
= SomeSwift4Class(someObjCInitRequirement: unbridged)
5642
let swift4ClassAsProtocol: SomeObjCProtocol.Type = SomeSwift4Class.self
5743
let swift4InstanceViaProtocol
5844
= swift4ClassAsProtocol.init(someObjCInitRequirement: unbridged)
5945

6046
let objcPropertyViaClassS4 = swift4InstanceViaClass.someObjCPropertyRequirement
61-
bridgedSink = objcPropertyViaClassS4
47+
unbridgedSink = objcPropertyViaClassS4
6248
let objcPropertyViaProtocolS4 = swift4InstanceViaProtocol.someObjCPropertyRequirement
6349
unbridgedSink = objcPropertyViaProtocolS4
6450

65-
swift4InstanceViaClass.someObjCMethodRequirement(bridged)
51+
swift4InstanceViaClass.someObjCMethodRequirement(unbridged)
6652
swift4InstanceViaProtocol.someObjCMethodRequirement(unbridged)
6753

54+
let swift5InstanceViaClass
55+
= SomeSwift5Class(someObjCInitRequirement: bridged)
56+
let swift5ClassAsProtocol: SomeObjCProtocol.Type = SomeSwift5Class.self
57+
let swift5InstanceViaProtocol
58+
= swift5ClassAsProtocol.init(someObjCInitRequirement: unbridged)
59+
60+
let objcPropertyViaClassS5 = swift5InstanceViaClass.someObjCPropertyRequirement
61+
bridgedSink = objcPropertyViaClassS5
62+
let objcPropertyViaProtocolS5 = swift5InstanceViaProtocol.someObjCPropertyRequirement
63+
unbridgedSink = objcPropertyViaProtocolS5
64+
65+
swift5InstanceViaClass.someObjCMethodRequirement(bridged)
66+
swift5InstanceViaProtocol.someObjCMethodRequirement(unbridged)
67+
6868
_ = bridgedSink
6969
_ = unbridgedSink
7070
}

test/Compatibility/MixAndMatch/Inputs/witness_change_swift4.swift test/Compatibility/MixAndMatch/Inputs/witness_change_swift5.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

2-
// Swift 3 sees the ObjC class NSRuncibleSpoon as the class, and uses methods
2+
// Swift 4 sees the ObjC class NSRuncibleSpoon as the class, and uses methods
33
// with type signatures involving NSRuncibleSpoon to conform to protocols
4-
// across the language boundary. Swift 4 sees the type as bridged to
4+
// across the language boundary. Swift 5 sees the type as bridged to
55
// a RuncibleSpoon value type, but still needs to be able to use conformances
6-
// declared by Swift 3.
6+
// declared by Swift 4.
77

8-
// Swift 4
8+
// Swift 5
99

1010
import SomeObjCModule
11-
import SomeSwift3Module
11+
import SomeSwift4Module
1212

1313
public func testMixAndMatch(bridged: RuncibleSpoon, unbridged: NSRuncibleSpoon) {
1414
let objcInstanceViaClass
1515
= SomeObjCClass(someSwiftInitRequirement: bridged)
16-
let objcClassAsProtocol: SomeSwift3Protocol.Type = SomeObjCClass.self
16+
let objcClassAsProtocol: SomeSwift4Protocol.Type = SomeObjCClass.self
1717
let objcInstanceViaProtocol
1818
= objcClassAsProtocol.init(someSwiftInitRequirement: unbridged)
1919

@@ -29,8 +29,8 @@ public func testMixAndMatch(bridged: RuncibleSpoon, unbridged: NSRuncibleSpoon)
2929
objcInstanceViaProtocol.someSwiftMethodRequirement(unbridged)
3030

3131
let swiftInstanceViaClass
32-
= SomeSwift3Class(someObjCInitRequirement: unbridged)
33-
let swiftClassAsProtocol: SomeObjCProtocol.Type = SomeSwift3Class.self
32+
= SomeSwift4Class(someObjCInitRequirement: unbridged)
33+
let swiftClassAsProtocol: SomeObjCProtocol.Type = SomeSwift4Class.self
3434
let swiftInstanceViaProtocol
3535
= swiftClassAsProtocol.init(someObjCInitRequirement: bridged)
3636

@@ -46,20 +46,20 @@ public func testMixAndMatch(bridged: RuncibleSpoon, unbridged: NSRuncibleSpoon)
4646
_ = unbridgedSink
4747
}
4848

49-
public protocol SomeSwift4Protocol {
49+
public protocol SomeSwift5Protocol {
5050
init(someSwiftInitRequirement: RuncibleSpoon)
5151
func someSwiftMethodRequirement(_: RuncibleSpoon)
5252
var someSwiftPropertyRequirement: RuncibleSpoon { get }
5353
}
5454

55-
extension SomeObjCClass: SomeSwift4Protocol {}
55+
extension SomeObjCClass: SomeSwift5Protocol {}
5656

57-
public class SomeSwift4Class: NSObject {
57+
public class SomeSwift5Class: NSObject {
5858
public required init(someObjCInitRequirement x: RuncibleSpoon) {
5959
someObjCPropertyRequirement = x
6060
}
6161
public func someObjCMethodRequirement(_: RuncibleSpoon) {}
6262
public var someObjCPropertyRequirement: RuncibleSpoon
6363
}
6464

65-
extension SomeSwift4Class: SomeObjCProtocol {}
65+
extension SomeSwift5Class: SomeObjCProtocol {}
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/SomeObjCModule.swiftmodule -module-name SomeObjCModule -I %t -I %S/Inputs -swift-version 3 %S/Inputs/SomeObjCModuleX.swift
3-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/SomeSwift3Module.swiftmodule -module-name SomeSwift3Module -I %t -I %S/Inputs -swift-version 3 %s
4-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/SomeSwift4Module.swiftmodule -module-name SomeSwift4Module -I %t -I %S/Inputs -swift-version 4 %S/Inputs/witness_change_swift4.swift
5-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -c -I %t -I %S/Inputs -swift-version 3 %S/Inputs/witness_change_swift3_leaf.swift
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/SomeObjCModule.swiftmodule -module-name SomeObjCModule -I %t -I %S/Inputs -swift-version 4 %S/Inputs/SomeObjCModuleX.swift
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/SomeSwift4Module.swiftmodule -module-name SomeSwift4Module -I %t -I %S/Inputs -swift-version 4 %s
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t/SomeSwift5Module.swiftmodule -module-name SomeSwift5Module -I %t -I %S/Inputs -swift-version 5 %S/Inputs/witness_change_swift5.swift
5+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -c -I %t -I %S/Inputs -swift-version 4 %S/Inputs/witness_change_swift4_leaf.swift
66

77
// REQUIRES: objc_interop
88

9-
// Swift 3 sees the ObjC class NSRuncibleSpoon as the class, and uses methods
9+
// Swift 4 sees the ObjC class NSRuncibleSpoon as the class, and uses methods
1010
// with type signatures involving NSRuncibleSpoon to conform to protocols
11-
// across the language boundary. Swift 4 sees the type as bridged to
11+
// across the language boundary. Swift 5 sees the type as bridged to
1212
// a RuncibleSpoon value type, but still needs to be able to use conformances
13-
// declared by Swift 3.
13+
// declared by Swift 4.
1414

15-
// Swift 3
15+
// Swift 4
1616

1717
import SomeObjCModule
1818

1919
_ = RuncibleSpoon()
2020

21-
public class SomeSwift3Class: NSObject {
21+
public class SomeSwift4Class: NSObject {
2222
public required init(someObjCInitRequirement x: NSRuncibleSpoon) {
2323
someObjCPropertyRequirement = x
2424
}
2525
public func someObjCMethodRequirement(_: NSRuncibleSpoon) {}
2626
public var someObjCPropertyRequirement: NSRuncibleSpoon
2727
}
28-
extension SomeSwift3Class: SomeObjCProtocol {}
28+
extension SomeSwift4Class: SomeObjCProtocol {}
2929

30-
public protocol SomeSwift3Protocol {
30+
public protocol SomeSwift4Protocol {
3131
init(someSwiftInitRequirement: NSRuncibleSpoon)
3232
func someSwiftMethodRequirement(_: NSRuncibleSpoon)
3333
var someSwiftPropertyRequirement: NSRuncibleSpoon { get }
3434
}
35-
extension SomeObjCClass: SomeSwift3Protocol {}
35+
extension SomeObjCClass: SomeSwift4Protocol {}
3636

test/DebugInfo/ASTSection_linker.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN: %empty-directory(%t)
44

5-
// RUN: %target-swift-frontend -c -sdk /fake/sdk/path -Xcc -DA -Xcc -DB -emit-module -o %t %S/ASTSection.swift -swift-version 3
5+
// RUN: %target-swift-frontend -c -sdk /fake/sdk/path -Xcc -DA -Xcc -DB -emit-module -o %t %S/ASTSection.swift -swift-version 4
66
// RUN: %swift-ide-test -test-CompilerInvocation-from-module -source-filename=%t/ASTSection.swiftmodule
77

88
// Test the inline section mechanism.
@@ -16,7 +16,7 @@
1616
// REQUIRES: OS=macosx
1717

1818
// CHECK: - Swift Version: {{.+}}.{{.+}}
19-
// CHECK: - Compatibility Version: 3
19+
// CHECK: - Compatibility Version: 4
2020
// CHECK: - Target: {{.+}}-{{.+}}-{{.+}}
2121
// CHECK: - SDK path: /fake/sdk/path{{$}}
2222
// CHECK: - -Xcc options: -working-directory {{.+}} -DA -DB

test/Interpreter/SDK/KVO.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop
@@ -8,12 +8,12 @@ import Foundation
88
var kvoContext = 0
99

1010
class Model : NSObject {
11-
dynamic var name = ""
12-
dynamic var number = 0
11+
@objc dynamic var name = ""
12+
@objc dynamic var number = 0
1313
}
1414

1515
class Observer : NSObject {
16-
let model = Model()
16+
@objc let model = Model()
1717

1818
override init() {
1919
super.init()

test/Interpreter/SDK/Reflection_KVO.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
class ObservedValue: NSObject {
11-
dynamic var amount = 0
11+
@objc dynamic var amount = 0
1212
}
1313

1414
class ValueObserver: NSObject {

test/Interpreter/SDK/autorelease.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop
@@ -11,7 +11,7 @@ import Foundation
1111

1212
class PrintOnDeinit: NSObject {
1313
// Result should get autoreleased.
14-
dynamic class func create() -> PrintOnDeinit {
14+
@objc dynamic class func create() -> PrintOnDeinit {
1515
return PrintOnDeinit()
1616
}
1717

test/Interpreter/SDK/objc_extensions.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop
55

66
import Foundation
77

88
extension NSObject {
9-
func frob() {
9+
@objc func frob() {
1010
print("I've been frobbed!")
1111
}
1212

13-
var asHerself : NSObject {
13+
@objc var asHerself : NSObject {
1414
return self
1515
}
1616

17-
var blackHoleWithHawkingRadiation : NSObject? {
17+
@objc var blackHoleWithHawkingRadiation : NSObject? {
1818
get {
1919
print("e+")
2020
return nil

test/Interpreter/SDK/objc_failable_initializers.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3
1+
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33
// REQUIRES: objc_interop
44

@@ -20,7 +20,7 @@ class Canary {
2020
}
2121

2222
extension NSDate {
23-
convenience init?(b: Bool) {
23+
@objc convenience init?(b: Bool) {
2424
guard b else { return nil }
2525
self.init()
2626
}

test/Interpreter/SDK/objc_keypath.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop
@@ -7,7 +7,7 @@ import Foundation
77

88
class Person : NSObject {
99
@objc(firstNameString) var firstName: String
10-
var lastName: String
10+
@objc var lastName: String
1111

1212
init(firstName: String, lastName: String) {
1313
self.firstName = firstName
@@ -20,11 +20,11 @@ class Person : NSObject {
2020
}
2121

2222
class Band : NSObject {
23-
var members: [Person] = []
23+
@objc var members: [Person] = []
2424
}
2525

2626
class RecordLabel : NSObject {
27-
var bands: [String : Band] = [:]
27+
@objc var bands: [String : Band] = [:]
2828
}
2929

3030
let band = Band()

test/Interpreter/SDK/objc_ns_enum.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3
1+
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33

44
// NSButtonType (from AppKit) and UIViewAnimationCurve (from UIKit) both have
@@ -11,7 +11,7 @@
1111
#if os(macOS)
1212
import AppKit
1313

14-
print(NSButtonType(rawValue: 20721)!.rawValue)
14+
print(NSButton.ButtonType(rawValue: 20721)!.rawValue)
1515
#endif
1616

1717
#if os(iOS)

test/Interpreter/static_objc_var.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop
@@ -7,9 +7,9 @@
77
import Foundation
88

99
class C : NSObject {
10-
static let i = 2
11-
static var j = "Hello"
12-
static var k: Double {
10+
@objc static let i = 2
11+
@objc static var j = "Hello"
12+
@objc static var k: Double {
1313
return 3.14
1414
}
1515
}

0 commit comments

Comments
 (0)