@@ -1139,7 +1139,7 @@ class SubstGenericParametersFromWrittenArgs {
11391139 : allGenericArgs(allGenericArgs),
11401140 genericParamCounts(genericParamCounts) {}
11411141
1142- const Metadata * getMetadata (unsigned depth, unsigned index) const ;
1142+ MetadataOrPack getMetadata (unsigned depth, unsigned index) const ;
11431143 const WitnessTable *getWitnessTable (const Metadata *type,
11441144 unsigned index) const ;
11451145};
@@ -1332,7 +1332,7 @@ _gatherGenericParameters(const ContextDescriptor *context,
13321332 auto error = _checkGenericRequirements (
13331333 generics->getGenericRequirements (), allGenericArgsVec,
13341334 [&substitutions](unsigned depth, unsigned index) {
1335- return substitutions.getMetadata (depth, index);
1335+ return substitutions.getMetadata (depth, index). Ptr ;
13361336 },
13371337 [&substitutions](const Metadata *type, unsigned index) {
13381338 return substitutions.getWitnessTable (type, index);
@@ -1577,7 +1577,8 @@ class DecodedMetadataBuilder {
15771577 swift_getTypeByMangledName (MetadataState::Complete,
15781578 mangledName, allGenericArgsVec.data (),
15791579 [&substitutions](unsigned depth, unsigned index) {
1580- return substitutions.getMetadata (depth, index);
1580+ // FIXME: Variadic generics
1581+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
15811582 },
15821583 [&substitutions](const Metadata *type, unsigned index) {
15831584 return substitutions.getWitnessTable (type, index);
@@ -2172,7 +2173,8 @@ swift_getTypeByMangledNameInEnvironment(
21722173 MetadataState::Complete, typeName,
21732174 genericArgs,
21742175 [&substitutions](unsigned depth, unsigned index) {
2175- return substitutions.getMetadata (depth, index);
2176+ // FIXME: Variadic generics
2177+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
21762178 },
21772179 [&substitutions](const Metadata *type, unsigned index) {
21782180 return substitutions.getWitnessTable (type, index);
@@ -2204,7 +2206,8 @@ swift_getTypeByMangledNameInEnvironmentInMetadataState(
22042206 (MetadataState)metadataState, typeName,
22052207 genericArgs,
22062208 [&substitutions](unsigned depth, unsigned index) {
2207- return substitutions.getMetadata (depth, index);
2209+ // FIXME: Variadic generics
2210+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
22082211 },
22092212 [&substitutions](const Metadata *type, unsigned index) {
22102213 return substitutions.getWitnessTable (type, index);
@@ -2235,7 +2238,8 @@ swift_getTypeByMangledNameInContext(
22352238 MetadataState::Complete, typeName,
22362239 genericArgs,
22372240 [&substitutions](unsigned depth, unsigned index) {
2238- return substitutions.getMetadata (depth, index);
2241+ // FIXME: Variadic generics
2242+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
22392243 },
22402244 [&substitutions](const Metadata *type, unsigned index) {
22412245 return substitutions.getWitnessTable (type, index);
@@ -2267,7 +2271,8 @@ swift_getTypeByMangledNameInContextInMetadataState(
22672271 (MetadataState)metadataState, typeName,
22682272 genericArgs,
22692273 [&substitutions](unsigned depth, unsigned index) {
2270- return substitutions.getMetadata (depth, index);
2274+ // FIXME: Variadic generics
2275+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
22712276 },
22722277 [&substitutions](const Metadata *type, unsigned index) {
22732278 return substitutions.getWitnessTable (type, index);
@@ -2453,7 +2458,8 @@ swift_func_getReturnTypeInfo(const char *typeNameStart, size_t typeNameLength,
24532458 demangler,
24542459 /* substGenericParam=*/
24552460 [&substFn](unsigned depth, unsigned index) {
2456- return substFn.getMetadata (depth, index);
2461+ // FIXME: Variadic generics
2462+ return substFn.getMetadata (depth, index).getMetadataOrNull ();
24572463 },
24582464 /* SubstDependentWitnessTableFn=*/
24592465 [&substFn](const Metadata *type, unsigned index) {
@@ -2494,7 +2500,8 @@ swift_func_getParameterTypeInfo(
24942500 demangler,
24952501 /* substGenericParam=*/
24962502 [&substFn](unsigned depth, unsigned index) {
2497- return substFn.getMetadata (depth, index);
2503+ // FIXME: Variadic generics
2504+ return substFn.getMetadata (depth, index).getMetadataOrNull ();
24982505 },
24992506 /* SubstDependentWitnessTableFn=*/
25002507 [&substFn](const Metadata *type, unsigned index) {
@@ -2537,7 +2544,8 @@ swift_distributed_getWitnessTables(GenericEnvironmentDescriptor *genericEnv,
25372544 auto error = _checkGenericRequirements (
25382545 genericEnv->getGenericRequirements (), witnessTables,
25392546 [&substFn](unsigned depth, unsigned index) {
2540- return substFn.getMetadata (depth, index);
2547+ // FIXME: Variadic generics
2548+ return substFn.getMetadata (depth, index).getMetadataOrNull ();
25412549 },
25422550 [&substFn](const Metadata *type, unsigned index) {
25432551 return substFn.getWitnessTable (type, index);
@@ -2571,7 +2579,8 @@ swift_getOpaqueTypeMetadata(MetadataRequest request,
25712579 return swift_getTypeByMangledName (request.getState (),
25722580 mangledName, arguments,
25732581 [&substitutions](unsigned depth, unsigned index) {
2574- return substitutions.getMetadata (depth, index);
2582+ // FIXME: Variadic generics
2583+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
25752584 },
25762585 [&substitutions](const Metadata *type, unsigned index) {
25772586 return substitutions.getWitnessTable (type, index);
@@ -2823,22 +2832,22 @@ void SubstGenericParametersFromMetadata::setup() const {
28232832 }
28242833}
28252834
2826- const Metadata *
2835+ MetadataOrPack
28272836SubstGenericParametersFromMetadata::getMetadata (
28282837 unsigned depth, unsigned index) const {
28292838 // On first access, compute the descriptor path.
28302839 setup ();
28312840
28322841 // If the depth is too great, there is nothing to do.
28332842 if (depth >= descriptorPath.size ())
2834- return nullptr ;
2843+ return MetadataOrPack () ;
28352844
28362845 // / Retrieve the descriptor path element at this depth.
28372846 auto &pathElement = descriptorPath[depth];
28382847
28392848 // Check whether the index is clearly out of bounds.
28402849 if (index >= pathElement.numTotalGenericParams )
2841- return nullptr ;
2850+ return MetadataOrPack () ;
28422851
28432852 // Compute the flat index.
28442853 unsigned flatIndex = pathElement.numKeyGenericParamsInParent ;
@@ -2849,7 +2858,7 @@ SubstGenericParametersFromMetadata::getMetadata(
28492858
28502859 // Make sure that the requested parameter itself has a key argument.
28512860 if (!genericParams[index].hasKeyArgument ())
2852- return nullptr ;
2861+ return MetadataOrPack () ;
28532862
28542863 // Increase the flat index for each parameter with a key argument, up to
28552864 // the given index.
@@ -2861,7 +2870,7 @@ SubstGenericParametersFromMetadata::getMetadata(
28612870 flatIndex += index;
28622871 }
28632872
2864- return ( const Metadata *) genericArgs[flatIndex];
2873+ return MetadataOrPack ( genericArgs[flatIndex]) ;
28652874}
28662875
28672876const WitnessTable *
@@ -2873,17 +2882,16 @@ SubstGenericParametersFromMetadata::getWitnessTable(const Metadata *type,
28732882 return (const WitnessTable *)genericArgs[index + numKeyGenericParameters];
28742883}
28752884
2876- const Metadata * SubstGenericParametersFromWrittenArgs::getMetadata (
2885+ MetadataOrPack SubstGenericParametersFromWrittenArgs::getMetadata (
28772886 unsigned depth, unsigned index) const {
28782887 if (auto flatIndex =
28792888 _depthIndexToFlatIndex (depth, index, genericParamCounts)) {
28802889 if (*flatIndex < allGenericArgs.size ()) {
2881- // FIXME: variadic generics
2882- return allGenericArgs[*flatIndex].getMetadata ();
2890+ return MetadataOrPack (allGenericArgs[*flatIndex]);
28832891 }
28842892 }
28852893
2886- return nullptr ;
2894+ return MetadataOrPack () ;
28872895}
28882896
28892897const WitnessTable *
@@ -3009,7 +3017,8 @@ static void _gatherWrittenGenericArgs(
30093017 req.getMangledTypeName (),
30103018 (const void * const *)allGenericArgs.data (),
30113019 [&substitutions](unsigned depth, unsigned index) {
3012- return substitutions.getMetadata (depth, index);
3020+ // FIXME: Variadic generics
3021+ return substitutions.getMetadata (depth, index).getMetadataOrNull ();
30133022 },
30143023 [&substitutions](const Metadata *type, unsigned index) {
30153024 return substitutions.getWitnessTable (type, index);
0 commit comments