-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathprotocol.swift
132 lines (116 loc) · 4.68 KB
/
protocol.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// REQUIRES: VENDOR=apple
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s
// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing
// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -O
// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -O
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O
// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
public protocol Public {
func publicMethod()
associatedtype PublicAT
var publicVarGet: Int { get }
var publicVarGetSet: Int { get set }
}
protocol Internal {
func internalMethod()
associatedtype InternalAT
var internalVarGet: Int { get }
var internalVarGetSet: Int { get set }
}
private protocol Private {
func privateMethod()
associatedtype PrivateAT
var privateVarGet: Int { get }
var privateVarGetSet: Int { get set }
}
// Naming scheme: type access, protocol access, witness access, type kind
public struct PublicPublicPublicStruct: Public {
public func publicMethod() {}
public typealias PublicAT = Int
public let publicVarGet: Int = 0
public var publicVarGetSet: Int = 0
}
public struct PublicInternalPublicStruct: Internal {
public func internalMethod() {}
public typealias InternalAT = Int
public let internalVarGet: Int = 0
public var internalVarGetSet: Int = 0
}
public struct PublicPrivatePublicStruct: Private {
public func privateMethod() {}
public typealias PrivateAT = Int
public let privateVarGet: Int = 0
public var privateVarGetSet: Int = 0
}
public struct PublicInternalInternalStruct: Internal {
func internalMethod() {}
typealias InternalAT = Int
let internalVarGet: Int = 0
var internalVarGetSet: Int = 0
}
public struct PublicPrivateInternalStruct: Private {
func privateMethod() {}
typealias PrivateAT = Int
let privateVarGet: Int = 0
var privateVarGetSet: Int = 0
}
public struct PublicPrivateFileprivateStruct: Private {
fileprivate func privateMethod() {}
fileprivate typealias PrivateAT = Int
fileprivate let privateVarGet: Int = 0
fileprivate var privateVarGetSet: Int = 0
}
struct InternalPublicInternalStruct: Public {
func publicMethod() {}
typealias PublicAT = Int
let publicVarGet: Int = 0
var publicVarGetSet: Int = 0
}
struct InternalInternalInternalStruct: Internal {
func internalMethod() {}
typealias InternalAT = Int
let internalVarGet: Int = 0
var internalVarGetSet: Int = 0
}
struct InternalPrivateInternalStruct: Private {
func privateMethod() {}
typealias PrivateAT = Int
let privateVarGet: Int = 0
var privateVarGetSet: Int = 0
}
struct InternalPrivateFileprivateStruct: Private {
fileprivate func privateMethod() {}
fileprivate typealias PrivateAT = Int
fileprivate let privateVarGet: Int = 0
fileprivate var privateVarGetSet: Int = 0
}
private struct PrivatePublicInternalStruct: Public {
func publicMethod() {}
typealias PublicAT = Int
let publicVarGet: Int = 0
var publicVarGetSet: Int = 0
}
private struct PrivateInternalInternalStruct: Internal {
func internalMethod() {}
typealias InternalAT = Int
let internalVarGet: Int = 0
var internalVarGetSet: Int = 0
}
private struct PrivatePrivateInternalStruct: Private {
func privateMethod() {}
typealias PrivateAT = Int
let privateVarGet: Int = 0
var privateVarGetSet: Int = 0
}
private struct PrivatePrivateFileprivateStruct: Private {
fileprivate func privateMethod() {}
fileprivate typealias PrivateAT = Int
fileprivate let privateVarGet: Int = 0
fileprivate var privateVarGetSet: Int = 0
}