@@ -814,12 +814,9 @@ class TypeDecoder {
814
814
}
815
815
case NodeKind::ImplFunctionType: {
816
816
auto calleeConvention = ImplParameterConvention::Direct_Unowned;
817
- BuiltRequirement *witnessMethodConformanceRequirement = nullptr ;
818
817
llvm::SmallVector<ImplFunctionParam<BuiltType>, 8 > parameters;
819
818
llvm::SmallVector<ImplFunctionResult<BuiltType>, 8 > results;
820
819
llvm::SmallVector<ImplFunctionResult<BuiltType>, 8 > errorResults;
821
- llvm::SmallVector<BuiltType, 4 > genericParameters;
822
- llvm::SmallVector<BuiltRequirement, 4 > requirements;
823
820
ImplFunctionTypeFlags flags;
824
821
825
822
for (unsigned i = 0 ; i < Node->getNumChildren (); i++) {
@@ -852,9 +849,6 @@ class TypeDecoder {
852
849
} else if (text == " block" ) {
853
850
flags =
854
851
flags.withRepresentation (ImplFunctionRepresentation::Block);
855
- } else if (text == " witness_method" ) {
856
- flags = flags.withRepresentation (
857
- ImplFunctionRepresentation::WitnessMethod);
858
852
}
859
853
} else if (child->getKind () == NodeKind::ImplFunctionAttribute) {
860
854
if (!child->hasText ())
@@ -892,27 +886,6 @@ class TypeDecoder {
892
886
if (decodeImplFunctionPart (child, errorResults))
893
887
return MAKE_NODE_TYPE_ERROR0 (child,
894
888
" 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
- }
916
889
} else {
917
890
return MAKE_NODE_TYPE_ERROR0 (child, " unexpected kind" );
918
891
}
@@ -933,11 +906,11 @@ class TypeDecoder {
933
906
// TODO: Some cases not handled above, but *probably* they cannot
934
907
// appear as the types of values in SIL (yet?):
935
908
// - functions with yield returns
909
+ // - functions with generic signatures
936
910
// - 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);
941
914
}
942
915
943
916
case NodeKind::ArgumentTuple:
@@ -1108,12 +1081,35 @@ class TypeDecoder {
1108
1081
return MAKE_NODE_TYPE_ERROR0 (substNode, " expected type list" );
1109
1082
1110
1083
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.
1111
1108
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 ());
1117
1113
unsigned depth = 0 ;
1118
1114
unsigned index = 0 ;
1119
1115
for (auto *subst : *substNode) {
@@ -1463,43 +1459,6 @@ class TypeDecoder {
1463
1459
params.push_back (std::move (param));
1464
1460
return true ;
1465
1461
}
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
- }
1503
1462
};
1504
1463
1505
1464
template <typename BuilderType>
0 commit comments