Skip to content

Commit 8539782

Browse files
committed
[Sema] Rename convertInferableTypes to replaceInferableTypesWithTypeVars
1 parent ddd4842 commit 8539782

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3766,7 +3766,8 @@ class ConstraintSystem {
37663766
/// \param type The type on which to perform the conversion.
37673767
///
37683768
/// \returns The converted type.
3769-
Type convertInferableTypes(Type type, ConstraintLocatorBuilder locator);
3769+
Type replaceInferableTypesWithTypeVars(Type type,
3770+
ConstraintLocatorBuilder locator);
37703771

37713772
/// "Open" the given type by replacing any occurrences of generic
37723773
/// parameter types and dependent member types with fresh type variables.

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
16461646
auto *dstLocator = TypeVar->getImpl().getLocator();
16471647

16481648
if (Binding.hasDefaultedLiteralProtocol()) {
1649-
type = cs.convertInferableTypes(type, dstLocator);
1649+
type = cs.replaceInferableTypesWithTypeVars(type, dstLocator);
16501650
type = type->reconstituteSugar(/*recursive=*/false);
16511651
}
16521652

lib/Sema/CSGen.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,8 @@ namespace {
12411241
if (knownType &&
12421242
(knownType->hasUnboundGenericType() ||
12431243
knownType->hasPlaceholder())) {
1244-
knownType = CS.convertInferableTypes(knownType, locator);
1244+
knownType = CS.replaceInferableTypesWithTypeVars(knownType,
1245+
locator);
12451246
}
12461247

12471248
CS.setType(
@@ -1311,7 +1312,7 @@ namespace {
13111312
if (E->isImplicit()) {
13121313
type = CS.getInstanceType(CS.cacheType(E));
13131314
assert(type && "Implicit type expr must have type set!");
1314-
type = CS.convertInferableTypes(type, locator);
1315+
type = CS.replaceInferableTypesWithTypeVars(type, locator);
13151316
} else if (CS.hasType(E)) {
13161317
// If there's a type already set into the constraint system, honor it.
13171318
// FIXME: This supports the result builder transform, which sneakily
@@ -1992,7 +1993,8 @@ namespace {
19921993
Type externalType;
19931994
if (param->getTypeRepr()) {
19941995
auto declaredTy = CS.getVarType(param);
1995-
externalType = CS.convertInferableTypes(declaredTy, paramLoc);
1996+
externalType = CS.replaceInferableTypesWithTypeVars(declaredTy,
1997+
paramLoc);
19961998
} else {
19971999
// Let's allow parameters which haven't been explicitly typed
19982000
// to become holes by default, this helps in situations like
@@ -2208,7 +2210,7 @@ namespace {
22082210
// Look through reference storage types.
22092211
type = type->getReferenceStorageReferent();
22102212

2211-
Type openedType = CS.convertInferableTypes(type, locator);
2213+
Type openedType = CS.replaceInferableTypesWithTypeVars(type, locator);
22122214
assert(openedType);
22132215

22142216
auto *subPattern = cast<TypedPattern>(pattern)->getSubPattern();
@@ -2369,7 +2371,8 @@ namespace {
23692371
// contained within the type resolver.
23702372
if (const auto preresolvedTy = enumPattern->getParentType()) {
23712373
const auto openedTy =
2372-
CS.convertInferableTypes(preresolvedTy, patternMatchLoc);
2374+
CS.replaceInferableTypesWithTypeVars(preresolvedTy,
2375+
patternMatchLoc);
23732376
assert(openedTy);
23742377
return openedTy;
23752378
}
@@ -3575,7 +3578,8 @@ static bool generateWrappedPropertyTypeConstraints(
35753578
auto *typeRepr = wrapperAttributes[i]->getTypeRepr();
35763579
auto *locator =
35773580
cs.getConstraintLocator(typeRepr, LocatorPathElt::ContextualType());
3578-
wrapperType = cs.convertInferableTypes(rawWrapperType, locator);
3581+
wrapperType = cs.replaceInferableTypesWithTypeVars(rawWrapperType,
3582+
locator);
35793583
cs.addConstraint(ConstraintKind::Equal, wrapperType, wrappedValueType,
35803584
locator);
35813585
cs.setContextualType(typeRepr, TypeLoc::withoutLoc(wrappedValueType),
@@ -3886,8 +3890,8 @@ bool ConstraintSystem::generateConstraints(
38863890
auto *wrappedVar = target.getAsUninitializedWrappedVar();
38873891
auto *outermostWrapper = wrappedVar->getAttachedPropertyWrappers().front();
38883892
auto *typeRepr = outermostWrapper->getTypeRepr();
3889-
auto backingType = convertInferableTypes(outermostWrapper->getType(),
3890-
getConstraintLocator(typeRepr));
3893+
auto backingType = replaceInferableTypesWithTypeVars(
3894+
outermostWrapper->getType(),getConstraintLocator(typeRepr));
38913895
setType(typeRepr, backingType);
38923896

38933897
auto propertyType = getVarType(wrappedVar);

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ Optional<std::pair<unsigned, Expr *>> ConstraintSystem::getExprDepthAndParent(
652652
Type ConstraintSystem::openUnboundGenericType(
653653
GenericTypeDecl *decl, Type parentTy, ConstraintLocatorBuilder locator) {
654654
if (parentTy) {
655-
parentTy = convertInferableTypes(parentTy, locator);
655+
parentTy = replaceInferableTypesWithTypeVars(parentTy, locator);
656656
}
657657

658658
// Open up the generic type.
@@ -777,7 +777,7 @@ static void checkNestedTypeConstraints(ConstraintSystem &cs, Type type,
777777
checkNestedTypeConstraints(cs, parentTy, locator);
778778
}
779779

780-
Type ConstraintSystem::convertInferableTypes(
780+
Type ConstraintSystem::replaceInferableTypesWithTypeVars(
781781
Type type, ConstraintLocatorBuilder locator) {
782782
assert(!type->getCanonicalType()->hasTypeParameter());
783783

@@ -1231,7 +1231,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
12311231
checkNestedTypeConstraints(*this, type, locator);
12321232

12331233
// Convert any placeholder types and open generics.
1234-
type = convertInferableTypes(type, locator);
1234+
type = replaceInferableTypesWithTypeVars(type, locator);
12351235

12361236
// Module types are not wrapped in metatypes.
12371237
if (type->is<ModuleType>())
@@ -1487,7 +1487,7 @@ ConstraintSystem::getTypeOfMemberReference(
14871487
checkNestedTypeConstraints(*this, memberTy, locator);
14881488

14891489
// Convert any placeholders and open any generics.
1490-
memberTy = convertInferableTypes(memberTy, locator);
1490+
memberTy = replaceInferableTypesWithTypeVars(memberTy, locator);
14911491

14921492
// Wrap it in a metatype.
14931493
memberTy = MetatypeType::get(memberTy);

0 commit comments

Comments
 (0)