Skip to content

Commit 3b60ae1

Browse files
committed
AST: Rename AnyFunctionType::Param::getType() to getOldType()
1 parent 4975f3a commit 3b60ae1

29 files changed

+100
-94
lines changed

include/swift/AST/TypeMatcher.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,14 @@ class TypeMatcher {
217217
if (firstElt.getLabel() != secondElt.getLabel() ||
218218
firstElt.isVariadic() != secondElt.isVariadic() ||
219219
firstElt.isInOut() != secondElt.isInOut())
220-
return mismatch(firstElt.getType().getPointer(),
221-
secondElt.getType(),
222-
sugaredFirstFunc->getParams()[i].getType());
220+
return mismatch(firstElt.getOldType().getPointer(),
221+
secondElt.getOldType(),
222+
sugaredFirstFunc->getParams()[i].getOldType());
223223

224224
// Recurse on parameter components.
225-
if (!this->visit(firstElt.getType()->getCanonicalType(),
226-
secondElt.getType(),
227-
sugaredFirstFunc->getParams()[i].getType()))
225+
if (!this->visit(firstElt.getOldType()->getCanonicalType(),
226+
secondElt.getOldType(),
227+
sugaredFirstFunc->getParams()[i].getOldType()))
228228
return false;
229229
}
230230

include/swift/AST/Types.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,13 +2647,21 @@ class AnyFunctionType : public TypeBase {
26472647
ParameterTypeFlags Flags = {};
26482648

26492649
public:
2650-
/// FIXME(Remove InOutType): This is mostly for copying between param
2651-
/// types and should go away.
2652-
Type getType() const;
2650+
/// FIXME: Remove this. Return the formal type of the parameter in the
2651+
/// function type, including the InOutType if there is one.
2652+
///
2653+
/// For example, 'inout Int' => 'inout Int', 'Int...' => 'Int'.
2654+
Type getOldType() const;
26532655

2656+
/// Return the formal type of the parameter.
2657+
///
2658+
/// For example, 'inout Int' => 'Int', 'Int...' => 'Int'.
26542659
Type getPlainType() const { return Ty; }
26552660

2656-
/// The type of the parameter. Adjusts for varargs, but not inout.
2661+
/// The type of the parameter when referenced inside the function body
2662+
/// as an rvalue.
2663+
///
2664+
/// For example, 'inout Int' => 'Int', 'Int...' => '[Int]'.
26572665
Type getParameterType(bool forCanonical = false,
26582666
ASTContext *ctx = nullptr) const;
26592667

@@ -2699,7 +2707,7 @@ class AnyFunctionType : public TypeBase {
26992707
public:
27002708
static CanParam getFromParam(const Param &param) { return CanParam(param); }
27012709

2702-
CanType getType() const { return CanType(Param::getType()); }
2710+
CanType getOldType() const { return CanType(Param::getOldType()); }
27032711
CanType getPlainType() const { return CanType(Param::getPlainType()); }
27042712
CanType getParameterType() const {
27052713
return CanType(Param::getParameterType(/*forCanonical*/ true));

lib/AST/ASTContext.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,8 @@ FuncDecl *ASTContext::getEqualIntDecl() const {
10291029
intType, [=](FunctionType *type) {
10301030
// Check for the signature: (Int, Int) -> Bool
10311031
if (type->getParams().size() != 2) return false;
1032-
if (!type->getParams()[0].getType()->isEqual(intType) ||
1033-
!type->getParams()[1].getType()->isEqual(intType)) return false;
1032+
if (!type->getParams()[0].getOldType()->isEqual(intType) ||
1033+
!type->getParams()[1].getOldType()->isEqual(intType)) return false;
10341034
return type->getResult()->isEqual(boolType);
10351035
});
10361036
getImpl().EqualIntDecl = decl;
@@ -1046,7 +1046,7 @@ FuncDecl *ASTContext::getGetBoolDecl(LazyResolver *resolver) const {
10461046
resolver, [=](FunctionType *type) {
10471047
// Look for the signature (Builtin.Int1) -> Bool
10481048
if (type->getParams().size() != 1) return false;
1049-
if (!isBuiltinInt1Type(type->getParams()[0].getType())) return false;
1049+
if (!isBuiltinInt1Type(type->getParams()[0].getOldType())) return false;
10501050
return type->getResult()->isEqual(boolType);
10511051
});
10521052
getImpl().GetBoolDecl = decl;
@@ -1238,7 +1238,7 @@ FuncDecl *ASTContext::getIsOSVersionAtLeastDecl(LazyResolver *resolver) const {
12381238
return nullptr;
12391239

12401240
if (llvm::any_of(intrinsicsParams, [](const AnyFunctionType::Param &p) {
1241-
return !isBuiltinWordType(p.getType());
1241+
return !isBuiltinWordType(p.getOldType());
12421242
})) {
12431243
return nullptr;
12441244
}
@@ -3155,11 +3155,8 @@ Type TupleTypeElt::getType() const {
31553155
return ElementType;
31563156
}
31573157

3158-
Type AnyFunctionType::Param::getType() const {
3158+
Type AnyFunctionType::Param::getOldType() const {
31593159
if (Flags.isInOut()) return InOutType::get(Ty);
3160-
// FIXME: Callers are inconsistenly setting this flag and retrieving this
3161-
// type with and without the Array Slice type.
3162-
// if (Flags.isVariadic()) return ArraySliceType::get(Ty);
31633160
return Ty;
31643161
}
31653162

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3404,7 +3404,7 @@ namespace {
34043404
if (param.hasLabel())
34053405
printField("name", param.getLabel().str());
34063406
dumpParameterFlags(param.getParameterFlags());
3407-
printRec(param.getType());
3407+
printRec(param.getOldType());
34083408
OS << ")";
34093409
}
34103410
Indent -= 2;

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,7 +3772,7 @@ findProtocolSelfReferences(const ProtocolDecl *proto, Type type,
37723772
if (auto funcTy = type->getAs<AnyFunctionType>()) {
37733773
auto inputKind = SelfReferenceKind::None();
37743774
for (auto &elt : funcTy->getParams()) {
3775-
inputKind |= findProtocolSelfReferences(proto, elt.getType(),
3775+
inputKind |= findProtocolSelfReferences(proto, elt.getOldType(),
37763776
skipAssocTypes);
37773777
}
37783778
auto resultKind = findProtocolSelfReferences(proto, funcTy->getResult(),
@@ -3882,7 +3882,7 @@ ProtocolDecl::findProtocolSelfReferences(const ValueDecl *value,
38823882
if (!allowCovariantParameters) {
38833883
auto inputKind = SelfReferenceKind::None();
38843884
for (auto &elt : type->castTo<AnyFunctionType>()->getParams()) {
3885-
inputKind |= ::findProtocolSelfReferences(this, elt.getType(),
3885+
inputKind |= ::findProtocolSelfReferences(this, elt.getOldType(),
38863886
skipAssocTypes);
38873887
}
38883888

lib/AST/Type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,8 +1538,8 @@ bool TypeBase::isBindableTo(Type b) {
15381538
return false;
15391539

15401540
for (unsigned i : indices(func->getParams())) {
1541-
if (!visit(func->getParams()[i].getType(),
1542-
substFunc.getParams()[i].getType()))
1541+
if (!visit(func->getParams()[i].getOldType(),
1542+
substFunc.getParams()[i].getOldType()))
15431543
return false;
15441544
}
15451545

@@ -1916,7 +1916,7 @@ getForeignRepresentable(Type type, ForeignLanguage language,
19161916
for (const auto &param : functionType->getParams()) {
19171917
if (param.isVariadic())
19181918
return failure();
1919-
if (recurse(param.getType()))
1919+
if (recurse(param.getOldType()))
19201920
return failure();
19211921
}
19221922

@@ -2277,7 +2277,7 @@ static bool matches(CanType t1, CanType t2, TypeMatchOptions matchMode,
22772277

22782278
// Inputs are contravariant.
22792279
for (auto i : indices(fn2.getParams())) {
2280-
if (!matches(fn2Params[i].getType(), fn1Params[i].getType(),
2280+
if (!matches(fn2Params[i].getOldType(), fn1Params[i].getOldType(),
22812281
matchMode, ParameterPosition::ParameterTupleElement,
22822282
OptionalUnwrapping::None)) {
22832283
return false;

lib/AST/TypeWalker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Traversal : public TypeVisitor<Traversal, bool>
8585

8686
bool visitAnyFunctionType(AnyFunctionType *ty) {
8787
for (const auto &param : ty->getParams()) {
88-
if (doIt(param.getType()))
88+
if (doIt(param.getOldType()))
8989
return true;
9090
}
9191

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ static std::pair<Type, ParamDecl *> decomposeSubscriptSetter(FuncDecl *setter) {
16481648
->castTo<AnyFunctionType>()
16491649
->getResult()
16501650
->castTo<AnyFunctionType>()
1651-
->getParams().front().getType();
1651+
->getParams().front().getOldType();
16521652
ParamDecl *keyDecl = PL->get(1);
16531653

16541654
return {elementType, keyDecl};

lib/IDE/CodeCompletion.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ static bool hasTrivialTrailingClosure(const FuncDecl *FD,
15671567
if (defaultMap.size() - defaultMap.count() == 1) {
15681568
auto param = funcType->getParams().back();
15691569
if (!param.isAutoClosure()) {
1570-
if (auto Fn = param.getType()->getAs<AnyFunctionType>()) {
1570+
if (auto Fn = param.getOldType()->getAs<AnyFunctionType>()) {
15711571
return Fn->getParams().empty() && Fn->getResult()->isVoid();
15721572
}
15731573
}
@@ -3885,8 +3885,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
38853885
if (seenNames.insert(Param.getLabel()).second)
38863886
ExpectedNames.push_back(Param.getLabel().str());
38873887
} else {
3888-
if (seenTypes.insert(Param.getType().getPointer()).second)
3889-
ExpectedTypes.push_back(Param.getType());
3888+
if (seenTypes.insert(Param.getOldType().getPointer()).second)
3889+
ExpectedTypes.push_back(Param.getOldType());
38903890
}
38913891
}
38923892
}

lib/IDE/TypeReconstruction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ static void VisitNodeConstructor(
935935
// inits are typed as (Foo.Type) -> (args...) -> Foo, but don't
936936
// assert that in case we're dealing with broken code.
937937
if (identifier_func->getParams().size() == 1 &&
938-
identifier_func->getParams()[0].getType()->is<AnyMetatypeType>() &&
938+
identifier_func->getParams()[0].getOldType()->is<AnyMetatypeType>() &&
939939
identifier_func->getResult()->is<AnyFunctionType>()) {
940940
identifier_func =
941941
identifier_func->getResult()->getAs<AnyFunctionType>();
@@ -1227,7 +1227,8 @@ static bool CompareFunctionTypes(const AnyFunctionType *f,
12271227
auto label1 = getLabel(fLabels, param1, i);
12281228
auto label2 = getLabel(gLabels, param2, i);
12291229

1230-
if (label1.equals(label2) && param1.getType()->isEqual(param2.getType()))
1230+
if (label1.equals(label2) &&
1231+
param1.getOldType()->isEqual(param2.getOldType()))
12311232
continue;
12321233

12331234
in_matches = false;

0 commit comments

Comments
 (0)