@@ -887,119 +887,6 @@ void TypeChecker::diagnoseRequirementFailure(
887
887
ctx.Diags , noteLoc, reqFailureInfo.ReqPath );
888
888
}
889
889
890
- RequirementCheckResult TypeChecker::checkGenericArguments (
891
- ModuleDecl *module, SourceLoc loc, SourceLoc noteLoc, Type owner,
892
- TypeArrayView<GenericTypeParamType> genericParams,
893
- ArrayRef<Requirement> requirements,
894
- TypeSubstitutionFn substitutions,
895
- SubstOptions options) {
896
- bool valid = true ;
897
-
898
- struct RequirementSet {
899
- ArrayRef<Requirement> Requirements;
900
- SmallVector<ParentConditionalConformance, 4 > Parents;
901
- };
902
-
903
- SmallVector<RequirementSet, 8 > pendingReqs;
904
- pendingReqs.push_back ({requirements, {}});
905
-
906
- ASTContext &ctx = module->getASTContext ();
907
- while (!pendingReqs.empty ()) {
908
- auto current = pendingReqs.pop_back_val ();
909
-
910
- for (const auto &rawReq : current.Requirements ) {
911
- auto req = rawReq;
912
- if (current.Parents .empty ()) {
913
- auto substed = rawReq.subst (
914
- substitutions, LookUpConformanceInModule (module), options);
915
- if (!substed) {
916
- // Another requirement will fail later; just continue.
917
- valid = false ;
918
- continue ;
919
- }
920
-
921
- req = *substed;
922
- }
923
-
924
- ArrayRef<Requirement> conditionalRequirements;
925
- if (req.isSatisfied (conditionalRequirements, /* allowMissing=*/ true )) {
926
- if (!conditionalRequirements.empty ()) {
927
- assert (req.getKind () == RequirementKind::Conformance);
928
-
929
- auto history = current.Parents ;
930
- history.push_back ({req.getFirstType (), req.getProtocolDecl ()});
931
- pendingReqs.push_back ({conditionalRequirements, std::move (history)});
932
- }
933
- continue ;
934
- }
935
-
936
- if (loc.isValid ()) {
937
- Diag<Type, Type, Type> diagnostic;
938
- Diag<Type, Type, StringRef> diagnosticNote;
939
-
940
- switch (req.getKind ()) {
941
- case RequirementKind::Conformance: {
942
- diagnoseConformanceFailure (req.getFirstType (), req.getProtocolDecl (),
943
- module, loc);
944
-
945
- if (current.Parents .empty ())
946
- return RequirementCheckResult::Failure;
947
-
948
- diagnostic = diag::type_does_not_conform_owner;
949
- diagnosticNote = diag::type_does_not_inherit_or_conform_requirement;
950
- break ;
951
- }
952
-
953
- case RequirementKind::Layout:
954
- diagnostic = diag::type_is_not_a_class;
955
- diagnosticNote = diag::anyobject_requirement;
956
- break ;
957
-
958
- case RequirementKind::Superclass:
959
- diagnostic = diag::type_does_not_inherit;
960
- diagnosticNote = diag::type_does_not_inherit_or_conform_requirement;
961
- break ;
962
-
963
- case RequirementKind::SameType:
964
- diagnostic = diag::types_not_equal;
965
- diagnosticNote = diag::types_not_equal_requirement;
966
- break ;
967
- }
968
-
969
- Type rawSecondType, secondType;
970
- if (req.getKind () != RequirementKind::Layout) {
971
- rawSecondType = rawReq.getSecondType ();
972
- secondType = req.getSecondType ();
973
- }
974
-
975
- // FIXME: Poor source-location information.
976
- ctx.Diags .diagnose (loc, diagnostic, owner,
977
- req.getFirstType (), secondType);
978
-
979
- std::string genericParamBindingsText;
980
- if (!genericParams.empty ()) {
981
- genericParamBindingsText =
982
- gatherGenericParamBindingsText (
983
- {rawReq.getFirstType (), rawSecondType},
984
- genericParams, substitutions);
985
- }
986
- ctx.Diags .diagnose (noteLoc, diagnosticNote,
987
- rawReq.getFirstType (), rawSecondType,
988
- genericParamBindingsText);
989
-
990
- ParentConditionalConformance::diagnoseConformanceStack (
991
- ctx.Diags , noteLoc, current.Parents );
992
- }
993
-
994
- return RequirementCheckResult::Failure;
995
- }
996
- }
997
-
998
- if (valid)
999
- return RequirementCheckResult::Success;
1000
- return RequirementCheckResult::SubstitutionFailure;
1001
- }
1002
-
1003
890
CheckGenericArgumentsResult TypeChecker::checkGenericArgumentsForDiagnostics (
1004
891
ModuleDecl *module, ArrayRef<Requirement> requirements,
1005
892
TypeSubstitutionFn substitutions) {
0 commit comments