File tree Expand file tree Collapse file tree 4 files changed +103
-0
lines changed Expand file tree Collapse file tree 4 files changed +103
-0
lines changed Original file line number Diff line number Diff line change 3
3
public func printMessage( ) {
4
4
printMessageMoved ( )
5
5
}
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
+ }
Original file line number Diff line number Diff line change @@ -10,3 +10,40 @@ public struct Entity {
10
10
public init ( ) { }
11
11
public func location( ) -> String { return " Entity from " + value }
12
12
}
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
+ }
Original file line number Diff line number Diff line change @@ -9,3 +9,38 @@ public struct Entity {
9
9
public init ( ) { }
10
10
public func location( ) -> String { return " Entity from " + value }
11
11
}
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
+ }
Original file line number Diff line number Diff line change @@ -49,3 +49,27 @@ let e = Entity()
49
49
print ( e. location ( ) )
50
50
// BEFORE_MOVE: Entity from HighLevel
51
51
// 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
You can’t perform that action at this time.
0 commit comments