Skip to content

Commit aa3a075

Browse files
authored
Merge pull request #84115 from slavapestov/remove-covariant-result-type
Remove TypeBase::replaceCovariantResultType()
2 parents 706348a + 55082c4 commit aa3a075

File tree

3 files changed

+240
-215
lines changed

3 files changed

+240
-215
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,10 +1350,6 @@ class alignas(1 << TypeAlignInBits) TypeBase
13501350
/// Hack to deal with ConstructorDecl interface types.
13511351
Type withCovariantResultType();
13521352

1353-
/// Deprecated in favor of the above.
1354-
Type replaceCovariantResultType(Type newResultType,
1355-
unsigned uncurryLevel);
1356-
13571353
/// Returns a new function type exactly like this one but with the self
13581354
/// parameter replaced. Only makes sense for function members of types.
13591355
Type replaceSelfParameterType(Type newSelf);

lib/AST/Type.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,37 +1393,6 @@ Type TypeBase::withCovariantResultType() {
13931393
fnType->getExtInfo());
13941394
}
13951395

1396-
Type TypeBase::replaceCovariantResultType(Type newResultType,
1397-
unsigned uncurryLevel) {
1398-
if (uncurryLevel == 0) {
1399-
bool isLValue = is<LValueType>();
1400-
1401-
auto loadedTy = getWithoutSpecifierType();
1402-
if (auto objectType = loadedTy->getOptionalObjectType()) {
1403-
newResultType = OptionalType::get(
1404-
objectType->replaceCovariantResultType(newResultType, uncurryLevel));
1405-
}
1406-
1407-
return isLValue ? LValueType::get(newResultType) : newResultType;
1408-
}
1409-
1410-
// Determine the input and result types of this function.
1411-
auto fnType = this->castTo<AnyFunctionType>();
1412-
auto inputType = fnType->getParams();
1413-
Type resultType =
1414-
fnType->getResult()->replaceCovariantResultType(newResultType,
1415-
uncurryLevel - 1);
1416-
1417-
// Produce the resulting function type.
1418-
if (auto genericFn = dyn_cast<GenericFunctionType>(fnType)) {
1419-
return GenericFunctionType::get(genericFn->getGenericSignature(),
1420-
inputType, resultType,
1421-
fnType->getExtInfo());
1422-
}
1423-
1424-
return FunctionType::get(inputType, resultType, fnType->getExtInfo());
1425-
}
1426-
14271396
/// Whether this parameter accepts an unlabeled trailing closure argument
14281397
/// using the more-restrictive forward-scan rule.
14291398
static bool allowsUnlabeledTrailingClosureParameter(const ParamDecl *param) {

0 commit comments

Comments
 (0)