@@ -814,12 +814,9 @@ class TypeDecoder {
814814 }
815815 case NodeKind::ImplFunctionType: {
816816 auto calleeConvention = ImplParameterConvention::Direct_Unowned;
817- BuiltRequirement *witnessMethodConformanceRequirement = nullptr ;
818817 llvm::SmallVector<ImplFunctionParam<BuiltType>, 8 > parameters;
819818 llvm::SmallVector<ImplFunctionResult<BuiltType>, 8 > results;
820819 llvm::SmallVector<ImplFunctionResult<BuiltType>, 8 > errorResults;
821- llvm::SmallVector<BuiltType, 4 > genericParameters;
822- llvm::SmallVector<BuiltRequirement, 4 > requirements;
823820 ImplFunctionTypeFlags flags;
824821
825822 for (unsigned i = 0 ; i < Node->getNumChildren (); i++) {
@@ -852,9 +849,6 @@ class TypeDecoder {
852849 } else if (text == " block" ) {
853850 flags =
854851 flags.withRepresentation (ImplFunctionRepresentation::Block);
855- } else if (text == " witness_method" ) {
856- flags = flags.withRepresentation (
857- ImplFunctionRepresentation::WitnessMethod);
858852 }
859853 } else if (child->getKind () == NodeKind::ImplFunctionAttribute) {
860854 if (!child->hasText ())
@@ -892,27 +886,6 @@ class TypeDecoder {
892886 if (decodeImplFunctionPart (child, errorResults))
893887 return MAKE_NODE_TYPE_ERROR0 (child,
894888 " failed to decode function part" );
895- } else if (child->getKind () == NodeKind::DependentGenericSignature) {
896- llvm::SmallVector<unsigned , 4 > genericParamsAtDepth;
897-
898- if (auto error = decodeDependentGenericSignatureNode (
899- child, requirements, genericParamsAtDepth))
900- return *error;
901- if (flags.getRepresentation () ==
902- ImplFunctionRepresentation::WitnessMethod) {
903- // By convention, the first requirement of a witness method is the
904- // conformance of Self to the protocol.
905- witnessMethodConformanceRequirement = &requirements[0 ];
906- }
907-
908- for (unsigned long depth = 0 , depths = genericParamsAtDepth.size ();
909- depth < depths; ++depth) {
910- for (unsigned index = 0 ; index < genericParamsAtDepth[depth];
911- ++index) {
912- genericParameters.emplace_back (
913- Builder.createGenericTypeParameterType (depth, index));
914- }
915- }
916889 } else {
917890 return MAKE_NODE_TYPE_ERROR0 (child, " unexpected kind" );
918891 }
@@ -933,11 +906,11 @@ class TypeDecoder {
933906 // TODO: Some cases not handled above, but *probably* they cannot
934907 // appear as the types of values in SIL (yet?):
935908 // - functions with yield returns
909+ // - functions with generic signatures
936910 // - foreign error conventions
937- return Builder.createImplFunctionType (
938- calleeConvention, witnessMethodConformanceRequirement,
939- genericParameters, requirements, parameters, results, errorResult,
940- flags);
911+ return Builder.createImplFunctionType (calleeConvention,
912+ parameters, results,
913+ errorResult, flags);
941914 }
942915
943916 case NodeKind::ArgumentTuple:
@@ -1108,12 +1081,35 @@ class TypeDecoder {
11081081 return MAKE_NODE_TYPE_ERROR0 (substNode, " expected type list" );
11091082
11101083 auto *dependentGenericSignatureNode = Node->getChild (1 );
1084+ if (dependentGenericSignatureNode->getKind () !=
1085+ NodeKind::DependentGenericSignature)
1086+ return MAKE_NODE_TYPE_ERROR0 (dependentGenericSignatureNode,
1087+ " expected dependent generic signature" );
1088+ if (dependentGenericSignatureNode->getNumChildren () < 1 )
1089+ return MAKE_NODE_TYPE_ERROR (
1090+ dependentGenericSignatureNode,
1091+ " fewer children (%zu) than required (1)" ,
1092+ dependentGenericSignatureNode->getNumChildren ());
1093+ decodeRequirement<BuiltType, BuiltRequirement, BuiltLayoutConstraint,
1094+ BuilderType>(
1095+ dependentGenericSignatureNode, requirements, Builder/* ,
1096+ [&](NodePointer Node) -> BuiltType {
1097+ return decodeMangledType(Node).getType();
1098+ },
1099+ [&](LayoutConstraintKind Kind) -> BuiltLayoutConstraint {
1100+ return {}; // Not implemented!
1101+ },
1102+ [&](LayoutConstraintKind Kind, unsigned SizeInBits,
1103+ unsigned Alignment) -> BuiltLayoutConstraint {
1104+ return {}; // Not Implemented!
1105+ }*/ );
1106+ // The number of generic parameters at each depth are in a mini
1107+ // state machine and come first.
11111108 llvm::SmallVector<unsigned , 4 > genericParamsAtDepth;
1112- if (auto error = decodeDependentGenericSignatureNode (
1113- dependentGenericSignatureNode, requirements,
1114- genericParamsAtDepth))
1115- return *error;
1116-
1109+ for (auto *reqNode : *dependentGenericSignatureNode)
1110+ if (reqNode->getKind () == NodeKind::DependentGenericParamCount)
1111+ if (reqNode->hasIndex ())
1112+ genericParamsAtDepth.push_back (reqNode->getIndex ());
11171113 unsigned depth = 0 ;
11181114 unsigned index = 0 ;
11191115 for (auto *subst : *substNode) {
@@ -1463,43 +1459,6 @@ class TypeDecoder {
14631459 params.push_back (std::move (param));
14641460 return true ;
14651461 }
1466-
1467- llvm::Optional<TypeLookupError> decodeDependentGenericSignatureNode (
1468- NodePointer dependentGenericSignatureNode,
1469- llvm::SmallVectorImpl<BuiltRequirement> &requirements,
1470- llvm::SmallVectorImpl<unsigned > &genericParamsAtDepth) {
1471- using NodeKind = Demangle::Node::Kind;
1472- if (dependentGenericSignatureNode->getKind () !=
1473- NodeKind::DependentGenericSignature)
1474- return llvm::Optional<TypeLookupError>(
1475- MAKE_NODE_TYPE_ERROR0 (dependentGenericSignatureNode,
1476- " expected dependent generic signature" ));
1477- if (dependentGenericSignatureNode->getNumChildren () < 1 )
1478- return llvm::Optional<TypeLookupError>(MAKE_NODE_TYPE_ERROR (
1479- dependentGenericSignatureNode,
1480- " fewer children (%zu) than required (1)" ,
1481- dependentGenericSignatureNode->getNumChildren ()));
1482- decodeRequirement<BuiltType, BuiltRequirement, BuiltLayoutConstraint,
1483- BuilderType>(dependentGenericSignatureNode, requirements,
1484- Builder /* ,
1485- [&](NodePointer Node) -> BuiltType {
1486- return decodeMangledType(Node).getType();
1487- },
1488- [&](LayoutConstraintKind Kind) -> BuiltLayoutConstraint {
1489- return {}; // Not implemented!
1490- },
1491- [&](LayoutConstraintKind Kind, unsigned SizeInBits,
1492- unsigned Alignment) -> BuiltLayoutConstraint {
1493- return {}; // Not Implemented!
1494- }*/ );
1495- // The number of generic parameters at each depth are in a mini
1496- // state machine and come first.
1497- for (auto *reqNode : *dependentGenericSignatureNode)
1498- if (reqNode->getKind () == NodeKind::DependentGenericParamCount)
1499- if (reqNode->hasIndex ())
1500- genericParamsAtDepth.push_back (reqNode->getIndex ());
1501- return llvm::None;
1502- }
15031462};
15041463
15051464template <typename BuilderType>
0 commit comments