mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Distinguish conformance and superclass generic requirements.
As part of this, use a different enum for parsed generic requirements. NFC except that I noticed that ASTWalker wasn't visiting the second type in a conformance constraint; fixing this seems to have no effect beyond producing better IDE annotations.
This commit is contained in:
@@ -54,10 +54,22 @@ bool AbstractionPattern::isOpaqueType(CanGenericSignature signature,
|
||||
// Enormous hack! We need to be asking the signature about this
|
||||
// in a more principled way.
|
||||
for (auto &reqt : signature->getRequirements()) {
|
||||
if (reqt.getKind() != RequirementKind::Conformance) continue;
|
||||
if (CanType(reqt.getFirstType()) != type) continue;
|
||||
if (reqt.getSecondType()->isClassExistentialType())
|
||||
switch (reqt.getKind()) {
|
||||
case RequirementKind::Superclass:
|
||||
if (CanType(reqt.getFirstType()) != type) continue;
|
||||
return false;
|
||||
|
||||
case RequirementKind::Conformance:
|
||||
if (CanType(reqt.getFirstType()) != type) continue;
|
||||
if (cast<ProtocolType>(CanType(reqt.getSecondType()))->requiresClass())
|
||||
return false;
|
||||
continue;
|
||||
|
||||
case RequirementKind::SameType:
|
||||
case RequirementKind::WitnessMarker:
|
||||
continue;
|
||||
}
|
||||
llvm_unreachable("bad requirement kind");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user