Skip to content

Commit 852686b

Browse files
committed
Manually add _unconditionallyBridgeFromObjectiveC throughout test cases. NFC
1 parent de7ef4b commit 852686b

File tree

7 files changed

+64
-72
lines changed

7 files changed

+64
-72
lines changed

test/1_stdlib/ArrayBridge.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@
2424
import Foundation
2525
import ArrayBridgeObjC
2626

27-
// FIXME: Should go into the standard library.
28-
public extension _ObjectiveCBridgeable {
29-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectiveCType?)
30-
-> Self {
31-
var result: Self? = nil
32-
_forceBridgeFromObjectiveC(source!, result: &result)
33-
return result!
34-
}
35-
}
36-
3727
// CHECK: testing...
3828
print("testing...")
3929

@@ -137,7 +127,14 @@ struct BridgedSwift : CustomStringConvertible, _ObjectiveCBridgeable {
137127
result = nil
138128
return false
139129
}
140-
130+
131+
static func _unconditionallyBridgeFromObjectiveC(_ source: BridgedObjC?)
132+
-> BridgedSwift {
133+
var result: BridgedSwift? = nil
134+
_forceBridgeFromObjectiveC(source!, result: &result)
135+
return result!
136+
}
137+
141138
var description: String {
142139
assert(trak.serialNumber > 0, "dead Tracked!")
143140
return "BridgedSwift#\(trak.serialNumber)(\(trak.value))"

test/1_stdlib/BridgeNonVerbatim.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ import SwiftShims
2626
import ObjectiveC
2727
import StdlibUnittest
2828

29-
// FIXME: Should go into the standard library.
30-
public extension _ObjectiveCBridgeable {
31-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectiveCType?)
32-
-> Self {
33-
var result: Self? = nil
34-
_forceBridgeFromObjectiveC(source!, result: &result)
35-
return result!
36-
}
37-
}
38-
3929
struct X : _ObjectiveCBridgeable {
4030
static func _isBridgedToObjectiveC() -> Bool {
4131
return true
@@ -64,6 +54,13 @@ struct X : _ObjectiveCBridgeable {
6454
return true
6555
}
6656

57+
static func _unconditionallyBridgeFromObjectiveC(_ source: LifetimeTracked?)
58+
-> X {
59+
var result: X? = nil
60+
_forceBridgeFromObjectiveC(source!, result: &result)
61+
return result!
62+
}
63+
6764
var value: Int
6865
}
6966

test/1_stdlib/DictionaryTraps.swift

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@
1313
import StdlibUnittest
1414
import Foundation
1515

16-
// FIXME: Should go into the standard library.
17-
public extension _ObjectiveCBridgeable {
18-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectiveCType?)
19-
-> Self {
20-
var result: Self? = nil
21-
_forceBridgeFromObjectiveC(source!, result: &result)
22-
return result!
23-
}
24-
}
25-
26-
2716
struct NotBridgedKeyTy : Equatable, Hashable {
2817
init(_ value: Int) {
2918
self.value = value
@@ -196,6 +185,13 @@ struct TestBridgedKeyTy : Hashable, _ObjectiveCBridgeable {
196185
return true
197186
}
198187

188+
static func _unconditionallyBridgeFromObjectiveC(_ source: TestObjCKeyTy?)
189+
-> TestBridgedKeyTy {
190+
var result: TestBridgedKeyTy? = nil
191+
_forceBridgeFromObjectiveC(source!, result: &result)
192+
return result!
193+
}
194+
199195
var value: Int
200196
}
201197

test/1_stdlib/RuntimeObjC.swift

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ import CoreGraphics
1515
import SwiftShims
1616
import MirrorObjC
1717

18-
// FIXME: Should go into the standard library.
19-
public extension _ObjectiveCBridgeable {
20-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectiveCType?)
21-
-> Self {
22-
var result: Self? = nil
23-
_forceBridgeFromObjectiveC(source!, result: &result)
24-
return result!
25-
}
26-
}
27-
2818
var nsObjectCanaryCount = 0
2919
@objc class NSObjectCanary : NSObject {
3020
override init() {
@@ -100,6 +90,13 @@ struct BridgedValueType : _ObjectiveCBridgeable {
10090
return false
10191
}
10292

93+
static func _unconditionallyBridgeFromObjectiveC(_ source: ClassA?)
94+
-> BridgedValueType {
95+
var result: BridgedValueType? = nil
96+
_forceBridgeFromObjectiveC(source!, result: &result)
97+
return result!
98+
}
99+
103100
var value: Int
104101
var canaryRef = SwiftObjectCanary()
105102
}
@@ -146,6 +143,13 @@ struct BridgedLargeValueType : _ObjectiveCBridgeable {
146143
return false
147144
}
148145

146+
static func _unconditionallyBridgeFromObjectiveC(_ source: ClassA?)
147+
-> BridgedLargeValueType {
148+
var result: BridgedLargeValueType? = nil
149+
_forceBridgeFromObjectiveC(source!, result: &result)
150+
return result!
151+
}
152+
149153
var value: Int {
150154
let x = value0
151155
assert(value0 == x && value1 == x && value2 == x && value3 == x &&
@@ -189,6 +193,13 @@ struct ConditionallyBridgedValueType<T> : _ObjectiveCBridgeable {
189193
return false
190194
}
191195

196+
static func _unconditionallyBridgeFromObjectiveC(_ source: ClassA?)
197+
-> ConditionallyBridgedValueType {
198+
var result: ConditionallyBridgedValueType? = nil
199+
_forceBridgeFromObjectiveC(source!, result: &result)
200+
return result!
201+
}
202+
192203
static func _isBridgedToObjectiveC() -> Bool {
193204
return ((T.self as Any) as? String.Type) == nil
194205
}

test/1_stdlib/SetTrapsObjC.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ import StdlibUnittest
1212
import Foundation
1313

1414

15-
// FIXME: Should go into the standard library.
16-
public extension _ObjectiveCBridgeable {
17-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectiveCType?)
18-
-> Self {
19-
var result: Self? = nil
20-
_forceBridgeFromObjectiveC(source!, result: &result)
21-
return result!
22-
}
23-
}
24-
2515
struct NotBridgedKeyTy : Equatable, Hashable {
2616
init(_ value: Int) {
2717
self.value = value
@@ -116,6 +106,13 @@ struct TestBridgedKeyTy : Hashable, _ObjectiveCBridgeable {
116106
return true
117107
}
118108

109+
static func _unconditionallyBridgeFromObjectiveC(_ source: TestObjCKeyTy?)
110+
-> TestBridgedKeyTy {
111+
var result: TestBridgedKeyTy? = nil
112+
_forceBridgeFromObjectiveC(source!, result: &result)
113+
return result!
114+
}
115+
119116
var value: Int
120117
}
121118

test/Constraints/bridging.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44

55
import Foundation
66

7-
// FIXME: Should go into the standard library.
8-
public extension _ObjectiveCBridgeable {
9-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectiveCType?)
10-
-> Self {
11-
var result: Self? = nil
12-
_forceBridgeFromObjectiveC(source!, result: &result)
13-
return result!
14-
}
15-
}
16-
177
public class BridgedClass : NSObject, NSCopying {
188
@objc(copyWithZone:)
199
public func copy(with zone: NSZone?) -> AnyObject {
@@ -75,6 +65,13 @@ struct BridgedStruct : Hashable, _ObjectiveCBridgeable {
7565
) -> Bool {
7666
return true
7767
}
68+
69+
static func _unconditionallyBridgeFromObjectiveC(_ source: BridgedClass?)
70+
-> BridgedStruct {
71+
var result: BridgedStruct? = nil
72+
_forceBridgeFromObjectiveC(source!, result: &result)
73+
return result!
74+
}
7875
}
7976

8077
func ==(x: BridgedStruct, y: BridgedStruct) -> Bool { return true }

test/SILOptimizer/cast_folding_objc.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010

1111
import Foundation
1212

13-
// FIXME: Should go into the standard library.
14-
public extension _ObjectiveCBridgeable {
15-
static func _unconditionallyBridgeFromObjectiveC(_ source: _ObjectiveCType?)
16-
-> Self {
17-
var result: Self? = nil
18-
_forceBridgeFromObjectiveC(source!, result: &result)
19-
return result!
20-
}
21-
}
22-
2313
class ObjCX : NSObject {}
2414

2515
struct CX: _ObjectiveCBridgeable {
@@ -36,6 +26,13 @@ struct CX: _ObjectiveCBridgeable {
3626
static func _conditionallyBridgeFromObjectiveC(_ source: ObjCX, result: inout CX?) -> Bool {
3727
return false
3828
}
29+
30+
static func _unconditionallyBridgeFromObjectiveC(_ source: ObjCX?)
31+
-> CX {
32+
var result: CX? = nil
33+
_forceBridgeFromObjectiveC(source!, result: &result)
34+
return result!
35+
}
3936
}
4037

4138
// Check casts to types which are _ObjectiveCBridgeable

0 commit comments

Comments
 (0)