@@ -138,24 +138,36 @@ func classMetatypePreservesIdentityGenerically<T>(original: T.Type,
138
138
expectTrue(original as Any.Type as AnyObject === bridged)
139
139
}
140
140
141
+ func protocolObjectPreservesIdentity(original: NSCopying.Protocol,
142
+ bridged: AnyObject) {
143
+ let proto: Protocol = original
144
+ expectTrue(proto === bridged)
145
+ }
146
+
147
+ protocol P {}
148
+
141
149
// We want to exhaustively check all paths through the bridging and dynamic
142
150
// casting infrastructure, so expand out test cases that wrap the different
143
151
// interesting bridging cases in different kinds of existential container.
144
152
%{
145
153
testCases = [
146
- ("classes", "LifetimeTracked(0)", "bridgedObjectPreservesIdentity", True),
147
- ("strings", '"vitameatavegamin"', "stringBridgesToEqualNSString", True),
148
- ("unbridged type", "KnownUnbridged()", "boxedTypeRoundTripsThroughDynamicCasting", True),
149
- ("tuple", '(1, "2")', "tupleCanBeDynamicallyCast", False),
150
- ("metatype", 'Int.self', "metatypeCanBeDynamicallyCast", False),
151
- ("generic metatype", 'Int.self', "metatypeCanBeDynamicallyCastGenerically", False),
152
- ("CF metatype", 'CFString.self', "metatypeCanBeDynamicallyCast", False),
153
- ("generic CF metatype", 'CFString.self', "metatypeCanBeDynamicallyCastGenerically", False),
154
- ("class metatype", 'LifetimeTracked.self', "classMetatypePreservesIdentity", False),
155
- ("objc metatype", 'NSObject.self', "classMetatypePreservesIdentity", False),
156
- ("generic class metatype", 'LifetimeTracked.self', "classMetatypePreservesIdentityGenerically", False),
157
- ("generic objc metatype", 'NSObject.self', "classMetatypePreservesIdentityGenerically", False),
158
- ("function", 'guineaPigFunction', "functionCanBeDynamicallyCast", False),
154
+ ("classes", "LifetimeTracked(0)", "bridgedObjectPreservesIdentity", True),
155
+ ("strings", '"vitameatavegamin"', "stringBridgesToEqualNSString", True),
156
+ ("unbridged type", "KnownUnbridged()", "boxedTypeRoundTripsThroughDynamicCasting", True),
157
+ ("tuple", '(1, "2")', "tupleCanBeDynamicallyCast", False),
158
+ ("metatype", 'Int.self', "metatypeCanBeDynamicallyCast", False),
159
+ ("generic metatype", 'Int.self', "metatypeCanBeDynamicallyCastGenerically", False),
160
+ ("CF metatype", 'CFString.self', "metatypeCanBeDynamicallyCast", False),
161
+ ("generic CF metatype", 'CFString.self', "metatypeCanBeDynamicallyCastGenerically", False),
162
+ ("class metatype", 'LifetimeTracked.self', "classMetatypePreservesIdentity", False),
163
+ ("objc metatype", 'NSObject.self', "classMetatypePreservesIdentity", False),
164
+ ("protocol", 'P.self', "metatypeCanBeDynamicallyCastGenerically", False),
165
+ ("objc protocol", 'NSCopying.self', "protocolObjectPreservesIdentity", False),
166
+ ("objc protocol composition", '(NSCopying & NSCoding).self', "metatypeCanBeDynamicallyCastGenerically", False),
167
+ ("mixed protocol composition", '(NSCopying & P).self', "metatypeCanBeDynamicallyCastGenerically", False),
168
+ ("generic class metatype", 'LifetimeTracked.self', "classMetatypePreservesIdentityGenerically", False),
169
+ ("generic objc metatype", 'NSObject.self', "classMetatypePreservesIdentityGenerically", False),
170
+ ("function", 'guineaPigFunction', "functionCanBeDynamicallyCast", False),
159
171
]
160
172
}%
161
173
0 commit comments