1
- // RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking)
1
+ // RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -enable-experimental-feature ValueGenerics )
2
2
// REQUIRES: executable_test
3
3
4
4
// UNSUPPORTED: CPU=arm64e
@@ -13,6 +13,8 @@ struct Variadic<each T> {
13
13
struct Nested < U, each V : Equatable > { }
14
14
}
15
15
16
+ struct Value < let N: Int , let M: Int > { }
17
+
16
18
@_silgen_name ( " swift_allocateMetadataPack " )
17
19
func allocateMetadataPack(
18
20
_ packPointer: UnsafeRawPointer ,
@@ -30,7 +32,7 @@ func metaPointer(_ x: Any.Type) -> UnsafeRawPointer {
30
32
unsafeBitCast ( x, to: UnsafeRawPointer . self)
31
33
}
32
34
33
- testSuite. test ( " _swift_checkedCreateType non-variadic" ) {
35
+ testSuite. test ( " _swift_instantiateCheckedGenericMetadata non-variadic" ) {
34
36
let dictMeta = unsafeBitCast (
35
37
[ Int : Int ] . self as Any . Type ,
36
38
to: UnsafeRawPointer . self
@@ -53,7 +55,7 @@ testSuite.test("_swift_checkedCreateType non-variadic") {
53
55
}
54
56
}
55
57
56
- testSuite. test ( " _swift_checkedCreateType variadic" ) {
58
+ testSuite. test ( " _swift_instantiateCheckedGenericMetadata variadic" ) {
57
59
let variMeta = unsafeBitCast (
58
60
Variadic< > . self as Any . Type ,
59
61
to: UnsafeRawPointer . self
@@ -84,7 +86,7 @@ testSuite.test("_swift_checkedCreateType variadic") {
84
86
}
85
87
}
86
88
87
- testSuite. test ( " _swift_checkedCreateType variadic nested with requirements" ) {
89
+ testSuite. test ( " _swift_instantiateCheckedGenericMetadata variadic nested with requirements" ) {
88
90
let nestedMeta = unsafeBitCast (
89
91
Variadic< > . Nested< ( ) > . self as Any . Type ,
90
92
to: UnsafeRawPointer . self
@@ -271,4 +273,28 @@ testSuite.test("_swift_instantiateCheckedGenericMetadata concrete generic types
271
273
}
272
274
}
273
275
276
+ extension Value where N == M {
277
+ struct NestedNEqualsM { }
278
+ }
279
+
280
+ testSuite. test ( " _swift_instantiateCheckedGenericMetadata value generics " ) {
281
+ let nestedMeta1 = metaPointer ( Value< 0 , 0 > . NestedNEqualsM. self)
282
+ let nestedDesc1 = nestedMeta1. load (
283
+ fromByteOffset: MemoryLayout< Int> . size,
284
+ as: UnsafeRawPointer . self
285
+ )
286
+
287
+ let genericArgs1 : [ Int ] = [ 123 ]
288
+
289
+ genericArgs1. withUnsafeBufferPointer {
290
+ let nested = _instantiateCheckedGenericMetadata (
291
+ nestedDesc1,
292
+ UnsafeRawPointer ( $0. baseAddress!) ,
293
+ UInt ( $0. count)
294
+ )
295
+
296
+ expectTrue ( nested == Value< 123 , 123 > . NestedNEqualsM. self)
297
+ }
298
+ }
299
+
274
300
runAllTests ( )
0 commit comments