1- // RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking)
1+ // RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -enable-experimental-feature ValueGenerics )
22// REQUIRES: executable_test
33
44// UNSUPPORTED: CPU=arm64e
@@ -13,6 +13,8 @@ struct Variadic<each T> {
1313 struct Nested < U, each V : Equatable > { }
1414}
1515
16+ struct Value < let N: Int , let M: Int > { }
17+
1618@_silgen_name ( " swift_allocateMetadataPack " )
1719func allocateMetadataPack(
1820 _ packPointer: UnsafeRawPointer ,
@@ -30,7 +32,7 @@ func metaPointer(_ x: Any.Type) -> UnsafeRawPointer {
3032 unsafeBitCast ( x, to: UnsafeRawPointer . self)
3133}
3234
33- testSuite. test ( " _swift_checkedCreateType non-variadic" ) {
35+ testSuite. test ( " _swift_instantiateCheckedGenericMetadata non-variadic" ) {
3436 let dictMeta = unsafeBitCast (
3537 [ Int : Int ] . self as Any . Type ,
3638 to: UnsafeRawPointer . self
@@ -53,7 +55,7 @@ testSuite.test("_swift_checkedCreateType non-variadic") {
5355 }
5456}
5557
56- testSuite. test ( " _swift_checkedCreateType variadic" ) {
58+ testSuite. test ( " _swift_instantiateCheckedGenericMetadata variadic" ) {
5759 let variMeta = unsafeBitCast (
5860 Variadic< > . self as Any . Type ,
5961 to: UnsafeRawPointer . self
@@ -84,7 +86,7 @@ testSuite.test("_swift_checkedCreateType variadic") {
8486 }
8587}
8688
87- testSuite. test ( " _swift_checkedCreateType variadic nested with requirements" ) {
89+ testSuite. test ( " _swift_instantiateCheckedGenericMetadata variadic nested with requirements" ) {
8890 let nestedMeta = unsafeBitCast (
8991 Variadic< > . Nested< ( ) > . self as Any . Type ,
9092 to: UnsafeRawPointer . self
@@ -271,4 +273,28 @@ testSuite.test("_swift_instantiateCheckedGenericMetadata concrete generic types
271273 }
272274}
273275
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+
274300runAllTests ( )
0 commit comments