Skip to content

Commit f14604e

Browse files
committed
Demangle: Test demangling of nested types with contextual where clauses
1 parent c498ad0 commit f14604e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/Runtime/demangleToMetadata.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,18 @@ struct ConformsToP1: P1 { }
245245
struct ConformsToP2: P2 { }
246246
struct ConformsToP3: P3 { }
247247

248+
struct ContextualWhere1<T> {
249+
class Nested1 where T: P1 { }
250+
struct Nested2 where T == Int { }
251+
}
252+
248253
DemangleToMetadataTests.test("protocol conformance requirements") {
249254
expectEqual(CG4<ConformsToP1, ConformsToP2>.self,
250255
_typeByName("4main3CG4CyAA12ConformsToP1VAA12ConformsToP2VG")!)
251256
expectEqual(CG4<ConformsToP1, ConformsToP2>.InnerGeneric<ConformsToP3>.self,
252257
_typeByName("4main3CG4C12InnerGenericVyAA12ConformsToP1VAA12ConformsToP2V_AA12ConformsToP3VG")!)
258+
expectEqual(ContextualWhere1<ConformsToP1>.Nested1.self,
259+
_typeByName("4main16ContextualWhere1V7Nested1CyAA12ConformsToP1V_G")!)
253260

254261
// Failure cases: failed conformance requirements.
255262
expectNil(_typeByName("4main3CG4CyAA12ConformsToP1VAA12ConformsToP1VG"))
@@ -274,9 +281,16 @@ struct ConformsToP4c : P4 {
274281
typealias Assoc2 = ConformsToP2
275282
}
276283

284+
struct ContextualWhere2<U: P4> {
285+
struct Nested1 where U.Assoc1: P1, U.Assoc2: P2 { }
286+
enum Nested2 where U.Assoc1 == U.Assoc2 { }
287+
}
288+
277289
DemangleToMetadataTests.test("associated type conformance requirements") {
278290
expectEqual(SG5<ConformsToP4a>.self,
279291
_typeByName("4main3SG5VyAA13ConformsToP4aVG")!)
292+
expectEqual(ContextualWhere2<ConformsToP4a>.Nested1.self,
293+
_typeByName("4main16ContextualWhere2V7Nested1VyAA13ConformsToP4aV_G")!)
280294

281295
// Failure cases: failed conformance requirements.
282296
expectNil(_typeByName("4main3SG5VyAA13ConformsToP4bVG"))
@@ -297,12 +311,16 @@ DemangleToMetadataTests.test("same-type requirements") {
297311
// Concrete type.
298312
expectEqual(SG7<S>.self,
299313
_typeByName("4main3SG7VyAA1SVG")!)
314+
expectEqual(ContextualWhere1<Int>.Nested2.self,
315+
_typeByName("4main16ContextualWhere1V7Nested2VySi_G")!)
300316

301317
// Other associated type.
302318
expectEqual(SG6<ConformsToP4b>.self,
303319
_typeByName("4main3SG6VyAA13ConformsToP4bVG")!)
304320
expectEqual(SG6<ConformsToP4c>.self,
305321
_typeByName("4main3SG6VyAA13ConformsToP4cVG")!)
322+
expectEqual(ContextualWhere2<ConformsToP4b>.Nested2.self,
323+
_typeByName("4main16ContextualWhere2V7Nested2OyAA13ConformsToP4bV_G")!)
306324

307325
// Structural type.
308326
expectEqual(SG8<ConformsToP4d>.self,

0 commit comments

Comments
 (0)