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
|
/// This should only be used when resolving/validating where clauses in
|
||||||
/// protocols.
|
/// protocols.
|
||||||
class ProtocolRequirementTypeResolver : public GenericTypeResolver {
|
class ProtocolRequirementTypeResolver : public GenericTypeResolver {
|
||||||
|
ProtocolDecl *Proto;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProtocolRequirementTypeResolver() {}
|
explicit ProtocolRequirementTypeResolver(ProtocolDecl *proto)
|
||||||
|
: Proto(proto) {}
|
||||||
|
|
||||||
virtual Type resolveGenericTypeParamType(GenericTypeParamType *gp);
|
virtual Type resolveGenericTypeParamType(GenericTypeParamType *gp);
|
||||||
|
|
||||||
|
|||||||
@@ -4348,7 +4348,7 @@ public:
|
|||||||
if (auto whereClause = assocType->getTrailingWhereClause()) {
|
if (auto whereClause = assocType->getTrailingWhereClause()) {
|
||||||
DeclContext *lookupDC = assocType->getDeclContext();
|
DeclContext *lookupDC = assocType->getDeclContext();
|
||||||
|
|
||||||
ProtocolRequirementTypeResolver resolver;
|
ProtocolRequirementTypeResolver resolver(PD);
|
||||||
TypeResolutionOptions options;
|
TypeResolutionOptions options;
|
||||||
|
|
||||||
for (auto &req : whereClause->getRequirements()) {
|
for (auto &req : whereClause->getRequirements()) {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ void GenericTypeToArchetypeResolver::recordParamType(ParamDecl *decl, Type type)
|
|||||||
|
|
||||||
Type ProtocolRequirementTypeResolver::resolveGenericTypeParamType(
|
Type ProtocolRequirementTypeResolver::resolveGenericTypeParamType(
|
||||||
GenericTypeParamType *gp) {
|
GenericTypeParamType *gp) {
|
||||||
assert(gp->getDepth() == 0 && gp->getIndex() == 0 &&
|
assert(gp->isEqual(Proto->getSelfInterfaceType()) &&
|
||||||
"found non-Self-shaped GTPT when resolving protocol requirement");
|
"found non-Self-shaped GTPT when resolving protocol requirement");
|
||||||
return gp;
|
return gp;
|
||||||
}
|
}
|
||||||
@@ -143,6 +143,7 @@ Type ProtocolRequirementTypeResolver::resolveDependentMemberType(
|
|||||||
|
|
||||||
Type ProtocolRequirementTypeResolver::resolveSelfAssociatedType(
|
Type ProtocolRequirementTypeResolver::resolveSelfAssociatedType(
|
||||||
Type selfTy, AssociatedTypeDecl *assocType) {
|
Type selfTy, AssociatedTypeDecl *assocType) {
|
||||||
|
assert(selfTy->isEqual(Proto->getSelfInterfaceType()));
|
||||||
return assocType->getDeclaredInterfaceType();
|
return assocType->getDeclaredInterfaceType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user