Skip to content

Commit 3c136c0

Browse files
committed
GSB: Remove obsolete hack for well-founded requirements
This used to be necessary to handle this case: protocol P1 { associatedtype A } protocol P2 { associatedtype A : P1 } func foo<T : P1>(_: T) where T.A : P2, T.A.A == T {} We don't want to mark 'T : P1' as redundant, even though it could be recovered from T.A.A, because it uses the requirement T.A, and we cannot recover the type metadata for T.A without the witness table for T : P1. Now this is handled via a more general mechanism, so we no longer need this hack.
1 parent f6359e9 commit 3c136c0

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,33 +1021,15 @@ const RequirementSource *RequirementSource::getMinimalConformanceSource(
10211021
return addConstraint(equivClass, proto, source);
10221022
};
10231023

1024-
bool sawProtocolRequirement = false;
10251024
const ProtocolDecl *requirementSignatureSelfProto = nullptr;
10261025

1027-
Type rootType = nullptr;
10281026
Optional<std::pair<const RequirementSource *, const RequirementSource *>>
10291027
redundantSubpath;
10301028
bool isSelfDerived = visitPotentialArchetypesAlongPath(
10311029
[&](Type parentType, const RequirementSource *source) {
10321030
switch (source->kind) {
10331031
case ProtocolRequirement:
10341032
case InferredProtocolRequirement: {
1035-
// Special handling for top-level requirement signature requirements;
1036-
// pretend the root type is the subject type as written in the
1037-
// protocol, and not 'Self', so that we can consider this requirement
1038-
// self-derived if it depends on one of the conformances that make
1039-
// the root type valid.
1040-
if (requirementSignatureSelfProto) {
1041-
if (source->getProtocolDecl() == requirementSignatureSelfProto &&
1042-
source->parent->kind == RequirementSource::RequirementSignatureSelf) {
1043-
rootType = source->getAffectedType();
1044-
return false;
1045-
}
1046-
}
1047-
1048-
// Note that we've seen a protocol requirement.
1049-
sawProtocolRequirement = true;
1050-
10511033
// If the base has been made concrete, note it.
10521034
auto parentEquivClass =
10531035
builder.resolveEquivalenceClass(parentType,
@@ -1099,7 +1081,6 @@ const RequirementSource *RequirementSource::getMinimalConformanceSource(
10991081
case Explicit:
11001082
case Inferred:
11011083
case NestedTypeNameMatch:
1102-
rootType = parentType;
11031084
return false;
11041085
}
11051086
llvm_unreachable("unhandled kind");
@@ -1129,20 +1110,6 @@ const RequirementSource *RequirementSource::getMinimalConformanceSource(
11291110
if (isSelfDerived)
11301111
return nullptr;
11311112

1132-
// If we haven't seen a protocol requirement, we're done.
1133-
if (!sawProtocolRequirement) return this;
1134-
1135-
// The root might be a nested type, which implies constraints
1136-
// for each of the protocols of the associated types referenced (if any).
1137-
for (auto depMemTy = rootType->getAs<DependentMemberType>(); depMemTy;
1138-
depMemTy = depMemTy->getBase()->getAs<DependentMemberType>()) {
1139-
auto assocType = depMemTy->getAssocType();
1140-
assert(assocType);
1141-
if (addTypeConstraint(depMemTy->getBase(), assocType->getProtocol(),
1142-
nullptr))
1143-
return nullptr;
1144-
}
1145-
11461113
return this;
11471114
}
11481115

0 commit comments

Comments
 (0)