Skip to content

Commit 3f37b7c

Browse files
committed
[NFC] TypeChecker: Remove the old diagnosing 'checkGenericArguments'
1 parent bfbdbf6 commit 3f37b7c

File tree

2 files changed

+0
-130
lines changed

2 files changed

+0
-130
lines changed

lib/Sema/TypeCheckGeneric.cpp

-113
Original file line numberDiff line numberDiff line change
@@ -887,119 +887,6 @@ void TypeChecker::diagnoseRequirementFailure(
887887
ctx.Diags, noteLoc, reqFailureInfo.ReqPath);
888888
}
889889

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-
1003890
CheckGenericArgumentsResult TypeChecker::checkGenericArgumentsForDiagnostics(
1004891
ModuleDecl *module, ArrayRef<Requirement> requirements,
1005892
TypeSubstitutionFn substitutions) {

lib/Sema/TypeChecker.h

-17
Original file line numberDiff line numberDiff line change
@@ -510,23 +510,6 @@ void diagnoseRequirementFailure(
510510
TypeArrayView<GenericTypeParamType> genericParams,
511511
TypeSubstitutionFn substitutions, ModuleDecl *module);
512512

513-
/// Check the given set of generic arguments against the requirements in a
514-
/// generic signature.
515-
///
516-
/// \param module The module to use for conformace lookup.
517-
/// \param loc The location at which any diagnostics should be emitted.
518-
/// \param noteLoc The location at which any notes will be printed.
519-
/// \param owner The type that owns the generic signature.
520-
/// \param genericParams The generic parameters being substituted.
521-
/// \param requirements The requirements against which the generic arguments
522-
/// should be checked.
523-
/// \param substitutions Substitutions from interface types of the signature.
524-
RequirementCheckResult checkGenericArguments(
525-
ModuleDecl *module, SourceLoc loc, SourceLoc noteLoc, Type owner,
526-
TypeArrayView<GenericTypeParamType> genericParams,
527-
ArrayRef<Requirement> requirements, TypeSubstitutionFn substitutions,
528-
SubstOptions options = None);
529-
530513
/// Check the given generic parameter substitutions against the given
531514
/// requirements and report on any requirement failures in detail for
532515
/// diagnostic needs.

0 commit comments

Comments
 (0)