mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Change omitNeedlessWords to be based on ParameterList instead of TupleType.
This commit is contained in:
@@ -2045,22 +2045,13 @@ static Optional<DeclName> omitNeedlessWords(AbstractFunctionDecl *afd) {
|
||||
|
||||
// String'ify the parameter types.
|
||||
SmallVector<OmissionTypeName, 4> paramTypes;
|
||||
Type functionType = afd->getInterfaceType();
|
||||
Type argumentType;
|
||||
for (unsigned i = 0, n = afd->getNaturalArgumentCount()-1; i != n; ++i)
|
||||
functionType = functionType->getAs<AnyFunctionType>()->getResult();
|
||||
argumentType = functionType->getAs<AnyFunctionType>()->getInput();
|
||||
if (auto tupleTy = argumentType->getAs<TupleType>()) {
|
||||
if (tupleTy->getNumElements() == argNameStrs.size()) {
|
||||
for (const auto &elt : tupleTy->getElements())
|
||||
paramTypes.push_back(getTypeNameForOmission(elt.getType())
|
||||
.withDefaultArgument(elt.hasDefaultArg()));
|
||||
}
|
||||
|
||||
// Always look at the parameters in the last parameter list.
|
||||
for (auto ¶m : *afd->getParameterLists().back()) {
|
||||
paramTypes.push_back(getTypeNameForOmission(param.decl->getType())
|
||||
.withDefaultArgument(param.hasDefaultValue()));
|
||||
}
|
||||
|
||||
if (argNameStrs.size() == 1 && paramTypes.empty())
|
||||
paramTypes.push_back(getTypeNameForOmission(argumentType));
|
||||
|
||||
|
||||
// Handle contextual type, result type, and returnsSelf.
|
||||
Type contextType = afd->getDeclContext()->getDeclaredInterfaceType();
|
||||
Type resultType;
|
||||
|
||||
Reference in New Issue
Block a user