mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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:
@@ -650,6 +650,7 @@ Type Mangler::getDeclTypeForMangling(const ValueDecl *decl,
|
||||
continue;
|
||||
|
||||
case RequirementKind::Conformance:
|
||||
case RequirementKind::Superclass:
|
||||
// We don't need the requirement if the constrained type is above the
|
||||
// method depth.
|
||||
if (!genericParamIsBelowDepth(reqt.getFirstType(), initialParamDepth))
|
||||
@@ -766,26 +767,28 @@ mangle_requirements:
|
||||
case RequirementKind::WitnessMarker:
|
||||
break;
|
||||
|
||||
case RequirementKind::Conformance: {
|
||||
case RequirementKind::Conformance:
|
||||
if (!didMangleRequirement) {
|
||||
Buffer << 'R';
|
||||
didMangleRequirement = true;
|
||||
}
|
||||
SmallVector<ProtocolDecl *, 2> protocols;
|
||||
if (reqt.getSecondType()->isExistentialType(protocols)
|
||||
&& protocols.size() == 1) {
|
||||
// Protocol constraints are the common case, so mangle them more
|
||||
// efficiently.
|
||||
// TODO: We could golf this a little more by assuming the first type
|
||||
// is a dependent type.
|
||||
mangleConstrainedType(reqt.getFirstType()->getCanonicalType());
|
||||
mangleProtocolName(protocols[0]);
|
||||
break;
|
||||
// Protocol constraints are the common case, so mangle them more
|
||||
// efficiently.
|
||||
// TODO: We could golf this a little more by assuming the first type
|
||||
// is a dependent type.
|
||||
mangleConstrainedType(reqt.getFirstType()->getCanonicalType());
|
||||
mangleProtocolName(
|
||||
reqt.getSecondType()->castTo<ProtocolType>()->getDecl());
|
||||
break;
|
||||
|
||||
case RequirementKind::Superclass:
|
||||
if (!didMangleRequirement) {
|
||||
Buffer << 'R';
|
||||
didMangleRequirement = true;
|
||||
}
|
||||
mangleConstrainedType(reqt.getFirstType()->getCanonicalType());
|
||||
mangleType(reqt.getSecondType()->getCanonicalType(), 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case RequirementKind::SameType:
|
||||
if (!didMangleRequirement) {
|
||||
|
||||
Reference in New Issue
Block a user