Skip to content

Commit dc4b7db

Browse files
committed
[NFC] Extract a function to canonicalize an individual FunctionType::Param.
1 parent 4a8a3ac commit dc4b7db

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,6 +3103,8 @@ class AnyFunctionType : public TypeBase {
31033103
return true;
31043104
return false;
31053105
}
3106+
3107+
Param getCanonical(CanGenericSignature genericSig) const;
31063108

31073109
ParameterTypeFlags getParameterFlags() const { return Flags; }
31083110

lib/AST/Type.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,14 +1606,19 @@ getCanonicalParams(AnyFunctionType *funcType,
16061606
SmallVectorImpl<AnyFunctionType::Param> &canParams) {
16071607
auto origParams = funcType->getParams();
16081608
for (auto param : origParams) {
1609-
// Canonicalize the type and drop the internal label to canonicalize the
1610-
// Param.
1611-
canParams.emplace_back(param.getPlainType()->getReducedType(genericSig),
1612-
param.getLabel(), param.getParameterFlags(),
1613-
/*InternalLabel=*/Identifier());
1609+
canParams.emplace_back(param.getCanonical(genericSig));
16141610
}
16151611
}
16161612

1613+
AnyFunctionType::Param
1614+
AnyFunctionType::Param::getCanonical(CanGenericSignature genericSig) const {
1615+
// Canonicalize the type and drop the internal label to canonicalize the
1616+
// Param.
1617+
return Param(getPlainType()->getReducedType(genericSig),
1618+
getLabel(), getParameterFlags(),
1619+
/*InternalLabel=*/Identifier());
1620+
}
1621+
16171622
CanType TypeBase::computeCanonicalType() {
16181623
assert(!hasCanonicalTypeComputed() && "called unnecessarily");
16191624

0 commit comments

Comments
 (0)