Skip to content

Commit 95252cc

Browse files
authored
Merge pull request swiftlang#18347 from rudkx/function-types
Replace more uses of getInput() with getParams().
2 parents 65738ea + fb31a02 commit 95252cc

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

lib/AST/Decl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -3815,9 +3815,12 @@ ProtocolDecl::findProtocolSelfReferences(const ValueDecl *value,
38153815
// Methods of non-final classes can only contain a covariant 'Self'
38163816
// as a function result type.
38173817
if (!allowCovariantParameters) {
3818-
auto inputType = type->castTo<AnyFunctionType>()->getInput();
3819-
auto inputKind = ::findProtocolSelfReferences(this, inputType,
3820-
skipAssocTypes);
3818+
auto inputKind = SelfReferenceKind::None();
3819+
for (auto &elt : type->castTo<AnyFunctionType>()->getParams()) {
3820+
inputKind |= ::findProtocolSelfReferences(this, elt.getType(),
3821+
skipAssocTypes);
3822+
}
3823+
38213824
if (inputKind.parameter)
38223825
return SelfReferenceKind::Other();
38233826
}

lib/ClangImporter/ImportDecl.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -6110,7 +6110,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
61106110

61116111
// Look for other imported constructors that occur in this context with
61126112
// the same name.
6113-
Type allocParamType = oldFnType->getInput();
6113+
auto allocParams = oldFnType->getParams();
61146114
bool ignoreNewExtensions = isa<ClassDecl>(dc);
61156115
for (auto other : ownerNominal->lookupDirect(importedName.getDeclName(),
61166116
ignoreNewExtensions)) {
@@ -6127,12 +6127,12 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
61276127
// If the types don't match, this is a different constructor with
61286128
// the same selector. This can happen when an overlay overloads an
61296129
// existing selector with a Swift-only signature.
6130-
Type ctorParamType = ctor->getInterfaceType()
6131-
->castTo<AnyFunctionType>()
6132-
->getResult()
6133-
->castTo<AnyFunctionType>()
6134-
->getInput();
6135-
if (!ctorParamType->isEqual(allocParamType)) {
6130+
auto ctorParams = ctor->getInterfaceType()
6131+
->castTo<AnyFunctionType>()
6132+
->getResult()
6133+
->castTo<AnyFunctionType>()
6134+
->getParams();
6135+
if (!AnyFunctionType::equalParams(ctorParams, allocParams)) {
61366136
continue;
61376137
}
61386138

lib/ClangImporter/ImportType.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -407,8 +407,9 @@ namespace {
407407
FunctionType *fTy = pointeeType->castTo<FunctionType>();
408408

409409
auto rep = FunctionType::Representation::Block;
410-
auto funcTy = FunctionType::get(fTy->getInput(), fTy->getResult(),
411-
fTy->getExtInfo().withRepresentation(rep));
410+
auto funcTy =
411+
FunctionType::get(fTy->getParams(), fTy->getResult(),
412+
fTy->getExtInfo().withRepresentation(rep));
412413
return { funcTy, ImportHint::Block };
413414
}
414415

@@ -1537,7 +1538,7 @@ static Type applyNoEscape(Type type) {
15371538

15381539
// Apply @noescape to function types.
15391540
if (auto funcType = type->getAs<FunctionType>()) {
1540-
return FunctionType::get(funcType->getInput(), funcType->getResult(),
1541+
return FunctionType::get(funcType->getParams(), funcType->getResult(),
15411542
funcType->getExtInfo().withNoEscape());
15421543
}
15431544

lib/SILGen/RValue.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -315,10 +315,12 @@ class RValue {
315315
// Allow function types to disagree about 'noescape'.
316316
if (auto lf = dyn_cast<FunctionType>(l)) {
317317
if (auto rf = dyn_cast<FunctionType>(r)) {
318-
return lf.getInput() == rf.getInput()
319-
&& lf.getResult() == rf.getResult()
320-
&& lf->getExtInfo().withNoEscape(false) ==
321-
lf->getExtInfo().withNoEscape(false);
318+
auto lParams = lf.getParams();
319+
auto rParams = rf.getParams();
320+
return AnyFunctionType::equalParams(lParams, rParams) &&
321+
lf.getResult() == rf.getResult() &&
322+
lf->getExtInfo().withNoEscape(false) ==
323+
lf->getExtInfo().withNoEscape(false);
322324
}
323325
}
324326
return false;

0 commit comments

Comments
 (0)