Skip to content

Commit

Permalink
Merge pull request #32326 from AnthonyLatsis/openunbound-disambig
Browse files Browse the repository at this point in the history
[NFC] CS: Give the type-transforming openUnboundGenericType method a more accurate name
  • Loading branch information
AnthonyLatsis authored Jun 12, 2020
2 parents b5a8b51 + 86b7e98 commit 399e533
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/Sema/CSBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
auto *dstLocator = TypeVar->getImpl().getLocator();

if (Binding.hasDefaultedLiteralProtocol()) {
type = cs.openUnboundGenericType(type, dstLocator);
type = cs.openUnboundGenericTypes(type, dstLocator);
type = type->reconstituteSugar(/*recursive=*/false);
}

Expand Down
22 changes: 11 additions & 11 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ namespace {
if (auto *PD = dyn_cast<ParamDecl>(VD)) {
if (!CS.hasType(PD)) {
if (knownType && knownType->hasUnboundGenericType())
knownType = CS.openUnboundGenericType(knownType, locator);
knownType = CS.openUnboundGenericTypes(knownType, locator);

CS.setType(
PD, knownType ? knownType
Expand Down Expand Up @@ -1521,7 +1521,7 @@ namespace {
if (!type || type->hasError()) return Type();

auto locator = CS.getConstraintLocator(E);
type = CS.openUnboundGenericType(type, locator);
type = CS.openUnboundGenericTypes(type, locator);
return MetatypeType::get(type);
}

Expand Down Expand Up @@ -2205,7 +2205,7 @@ namespace {
Type externalType;
if (param->getTypeRepr()) {
auto declaredTy = param->getType();
externalType = CS.openUnboundGenericType(declaredTy, paramLoc);
externalType = CS.openUnboundGenericTypes(declaredTy, paramLoc);
} else {
// Let's allow parameters which haven't been explicitly typed
// to become holes by default, this helps in situations like
Expand Down Expand Up @@ -2439,7 +2439,7 @@ namespace {
// Look through reference storage types.
type = type->getReferenceStorageReferent();

Type openedType = CS.openUnboundGenericType(type, locator);
Type openedType = CS.openUnboundGenericTypes(type, locator);
assert(openedType);

auto *subPattern = cast<TypedPattern>(pattern)->getSubPattern();
Expand Down Expand Up @@ -2541,7 +2541,7 @@ namespace {
if (!castType)
return Type();

castType = CS.openUnboundGenericType(
castType = CS.openUnboundGenericTypes(
castType,
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));

Expand Down Expand Up @@ -2607,7 +2607,7 @@ namespace {
if (!parentType)
return Type();

parentType = CS.openUnboundGenericType(
parentType = CS.openUnboundGenericTypes(
parentType, CS.getConstraintLocator(
locator, {LocatorPathElt::PatternMatch(pattern),
ConstraintLocator::ParentType}));
Expand Down Expand Up @@ -3100,7 +3100,7 @@ namespace {

// Open the type we're casting to.
const auto toType =
CS.openUnboundGenericType(type, CS.getConstraintLocator(expr));
CS.openUnboundGenericTypes(type, CS.getConstraintLocator(expr));
if (repr) CS.setType(repr, toType);

auto fromType = CS.getType(fromExpr);
Expand All @@ -3127,7 +3127,7 @@ namespace {

// Open the type we're casting to.
const auto toType =
CS.openUnboundGenericType(type, CS.getConstraintLocator(expr));
CS.openUnboundGenericTypes(type, CS.getConstraintLocator(expr));
if (repr) CS.setType(repr, toType);

auto fromType = CS.getType(expr->getSubExpr());
Expand Down Expand Up @@ -3160,7 +3160,7 @@ namespace {

// Open the type we're casting to.
const auto toType =
CS.openUnboundGenericType(type, CS.getConstraintLocator(expr));
CS.openUnboundGenericTypes(type, CS.getConstraintLocator(expr));
if (repr) CS.setType(repr, toType);

auto fromType = CS.getType(fromExpr);
Expand Down Expand Up @@ -3189,7 +3189,7 @@ namespace {
// Open up the type we're checking.
// FIXME: Locator for the cast type?
const auto toType =
CS.openUnboundGenericType(type, CS.getConstraintLocator(expr));
CS.openUnboundGenericTypes(type, CS.getConstraintLocator(expr));
CS.setType(expr->getCastTypeRepr(), toType);

// Add a checked cast constraint.
Expand Down Expand Up @@ -3469,7 +3469,7 @@ namespace {
rootRepr, TypeResolverContext::InExpression);
if (!rootObjectTy || rootObjectTy->hasError())
return Type();
rootObjectTy = CS.openUnboundGenericType(rootObjectTy, locator);
rootObjectTy = CS.openUnboundGenericTypes(rootObjectTy, locator);
// Allow \Derived.property to be inferred as \Base.property to
// simulate a sort of covariant conversion from
// KeyPath<Derived, T> to KeyPath<Base, T>.
Expand Down
8 changes: 4 additions & 4 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ ConstraintSystem::openUnboundGenericType(UnboundGenericType *unbound,
auto unboundDecl = unbound->getDecl();
auto parentTy = unbound->getParent();
if (parentTy) {
parentTy = openUnboundGenericType(parentTy, locator);
parentTy = openUnboundGenericTypes(parentTy, locator);
unbound = UnboundGenericType::get(unboundDecl, parentTy,
getASTContext());
}
Expand Down Expand Up @@ -782,7 +782,7 @@ static void checkNestedTypeConstraints(ConstraintSystem &cs, Type type,
checkNestedTypeConstraints(cs, parentTy, locator);
}

Type ConstraintSystem::openUnboundGenericType(
Type ConstraintSystem::openUnboundGenericTypes(
Type type, ConstraintLocatorBuilder locator) {
assert(!type->getCanonicalType()->hasTypeParameter());

Expand Down Expand Up @@ -1235,7 +1235,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
checkNestedTypeConstraints(*this, type, locator);

// Open the type.
type = openUnboundGenericType(type, locator);
type = openUnboundGenericTypes(type, locator);

// Module types are not wrapped in metatypes.
if (type->is<ModuleType>())
Expand Down Expand Up @@ -1491,7 +1491,7 @@ ConstraintSystem::getTypeOfMemberReference(
checkNestedTypeConstraints(*this, memberTy, locator);

// Open the type if it was a reference to a generic type.
memberTy = openUnboundGenericType(memberTy, locator);
memberTy = openUnboundGenericTypes(memberTy, locator);

// Wrap it in a metatype.
memberTy = MetatypeType::get(memberTy);
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -3420,7 +3420,7 @@ class ConstraintSystem {
/// \param type The type to open.
///
/// \returns The opened type.
Type openUnboundGenericType(Type type, ConstraintLocatorBuilder locator);
Type openUnboundGenericTypes(Type type, ConstraintLocatorBuilder locator);

/// "Open" the given type by replacing any occurrences of generic
/// parameter types and dependent member types with fresh type variables.
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckPropertyWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ PropertyWrapperBackingPropertyTypeRequest::evaluate(

// Open the type.
Type openedWrapperType =
cs.openUnboundGenericType(rawWrapperType, emptyLocator);
cs.openUnboundGenericTypes(rawWrapperType, emptyLocator);
if (!outermostOpenedWrapperType)
outermostOpenedWrapperType = openedWrapperType;

Expand Down

0 comments on commit 399e533

Please sign in to comment.