mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[TypeCheck] Bad Self GTPTs from invalid protocols shouldn't crash.
This commit is contained in:
@@ -166,8 +166,11 @@ public:
|
||||
/// This should only be used when resolving/validating where clauses in
|
||||
/// protocols.
|
||||
class ProtocolRequirementTypeResolver : public GenericTypeResolver {
|
||||
ProtocolDecl *Proto;
|
||||
|
||||
public:
|
||||
explicit ProtocolRequirementTypeResolver() {}
|
||||
explicit ProtocolRequirementTypeResolver(ProtocolDecl *proto)
|
||||
: Proto(proto) {}
|
||||
|
||||
virtual Type resolveGenericTypeParamType(GenericTypeParamType *gp);
|
||||
|
||||
|
||||
@@ -4348,7 +4348,7 @@ public:
|
||||
if (auto whereClause = assocType->getTrailingWhereClause()) {
|
||||
DeclContext *lookupDC = assocType->getDeclContext();
|
||||
|
||||
ProtocolRequirementTypeResolver resolver;
|
||||
ProtocolRequirementTypeResolver resolver(PD);
|
||||
TypeResolutionOptions options;
|
||||
|
||||
for (auto &req : whereClause->getRequirements()) {
|
||||
|
||||
@@ -130,7 +130,7 @@ void GenericTypeToArchetypeResolver::recordParamType(ParamDecl *decl, Type type)
|
||||
|
||||
Type ProtocolRequirementTypeResolver::resolveGenericTypeParamType(
|
||||
GenericTypeParamType *gp) {
|
||||
assert(gp->getDepth() == 0 && gp->getIndex() == 0 &&
|
||||
assert(gp->isEqual(Proto->getSelfInterfaceType()) &&
|
||||
"found non-Self-shaped GTPT when resolving protocol requirement");
|
||||
return gp;
|
||||
}
|
||||
@@ -143,6 +143,7 @@ Type ProtocolRequirementTypeResolver::resolveDependentMemberType(
|
||||
|
||||
Type ProtocolRequirementTypeResolver::resolveSelfAssociatedType(
|
||||
Type selfTy, AssociatedTypeDecl *assocType) {
|
||||
assert(selfTy->isEqual(Proto->getSelfInterfaceType()));
|
||||
return assocType->getDeclaredInterfaceType();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user