Skip to content

Commit 6be82b3

Browse files
committed
test: add more ABI stability test for @_originallyDefinedIn
1 parent 9cbc761 commit 6be82b3

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

test/attr/Inputs/SymbolMove/HighLevel.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@
33
public func printMessage() {
44
printMessageMoved()
55
}
6+
public class CandyBox: Box {
7+
public typealias Item = Candy
8+
public var ItemKind: String { return getItem().kind }
9+
let itemInBox: Item
10+
public init(_ itemInBox: Item) { self.itemInBox = itemInBox }
11+
public func getItem() -> Item { return itemInBox }
12+
}

test/attr/Inputs/SymbolMove/HighlevelOriginal.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,40 @@ public struct Entity {
1010
public init() {}
1111
public func location() -> String { return "Entity from " + value }
1212
}
13+
14+
// =================== Move protocol ================================= //
15+
public protocol Box {
16+
associatedtype Item
17+
var ItemKind: String { get }
18+
func getItem() -> Item
19+
func shape() -> String
20+
}
21+
22+
extension Box {
23+
public func shape() -> String { return "square"}
24+
}
25+
26+
public struct Candy {
27+
public var kind = "candy"
28+
public init() {}
29+
}
30+
31+
public class CandyBox: Box {
32+
public typealias Item = Candy
33+
public var ItemKind: String { return getItem().kind }
34+
let itemInBox: Item
35+
public init(_ itemInBox: Item) { self.itemInBox = itemInBox }
36+
public func getItem() -> Item { return itemInBox }
37+
}
38+
39+
// =================== Move enum ============================ //
40+
public enum LanguageKind: Int {
41+
case Cpp = -1
42+
case Swift = -2
43+
case ObjC = -3
44+
}
45+
46+
open class Vehicle {
47+
public init() {}
48+
public var currentSpeed = -40.0
49+
}

test/attr/Inputs/SymbolMove/LowLevel.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,38 @@ public struct Entity {
99
public init() {}
1010
public func location() -> String { return "Entity from " + value }
1111
}
12+
13+
// =================== Move protocol =================================//
14+
@_originallyDefinedIn(module: "HighLevel", OSX 10.10)
15+
public protocol Box {
16+
associatedtype Item
17+
var ItemKind: String { get }
18+
func getItem() -> Item
19+
func shape() -> String
20+
}
21+
22+
@_originallyDefinedIn(module: "HighLevel", OSX 10.10)
23+
extension Box {
24+
public func shape() -> String { return "round"}
25+
}
26+
27+
@_originallyDefinedIn(module: "HighLevel", OSX 10.10)
28+
public struct Candy {
29+
public var kind = "candy"
30+
public init() {}
31+
}
32+
33+
// =================== Move enum ============================ //
34+
@_originallyDefinedIn(module: "HighLevel", OSX 10.10)
35+
public enum LanguageKind: Int {
36+
case Cpp = 1
37+
case Swift = 2
38+
case ObjC = 3
39+
}
40+
41+
// =================== Move class ============================ //
42+
@_originallyDefinedIn(module: "HighLevel", OSX 10.10)
43+
open class Vehicle {
44+
public init() {}
45+
public var currentSpeed = 40.0
46+
}

test/attr/attr_originally_definedin_backward_compatibility.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,27 @@ let e = Entity()
4949
print(e.location())
5050
// BEFORE_MOVE: Entity from HighLevel
5151
// AFTER_MOVE: Entity from LowLevel
52+
53+
print(CandyBox(Candy()).ItemKind)
54+
// BEFORE_MOVE: candy
55+
// AFTER_MOVE: candy
56+
57+
print(CandyBox(Candy()).shape())
58+
// BEFORE_MOVE: square
59+
// AFTER_MOVE: round
60+
61+
print(LanguageKind.Cpp.rawValue)
62+
// BEFORE_MOVE: -1
63+
// AFTER_MOVE: 1
64+
65+
print("\(Vehicle().currentSpeed)")
66+
// BEFORE_MOVE: -40
67+
// AFTER_MOVE: 40
68+
69+
class Bicycle: Vehicle {}
70+
let bicycle = Bicycle()
71+
bicycle.currentSpeed = 15.0
72+
print("\(bicycle.currentSpeed)")
73+
74+
// BEFORE_MOVE: 15.0
75+
// AFTER_MOVE: 15.0

0 commit comments

Comments
 (0)