Skip to content

Change spelling of "ParametrizedProtocolType" to "ParameterizedProtocolType" #41184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2780,8 +2780,8 @@ ERROR(inheritance_from_non_protocol_or_class,none,
"inheritance from non-protocol, non-class type %0", (Type))
ERROR(inheritance_from_non_protocol,none,
"inheritance from non-protocol type %0", (Type))
ERROR(inheritance_from_parametrized_protocol,none,
"cannot inherit from parametrized protocol type %0", (Type))
ERROR(inheritance_from_parameterized_protocol,none,
"cannot inherit from protocol type with generic argument %0", (Type))
ERROR(superclass_not_first,none,
"superclass %0 must appear first in the inheritance clause", (Type))
ERROR(superclass_not_open,none,
Expand Down Expand Up @@ -3723,7 +3723,7 @@ ERROR(not_a_generic_definition,none,
"cannot specialize a non-generic definition", ())
ERROR(not_a_generic_type,none,
"cannot specialize non-generic type %0", (Type))
ERROR(parametrized_protocol_not_supported,none,
ERROR(parameterized_protocol_not_supported,none,
"protocol type with generic argument can only be used as a generic constraint", ())
ERROR(protocol_does_not_have_primary_assoc_type,none,
"cannot specialize protocol type %0", (Type))
Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/ExistentialLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ExistentialLayout {

ExistentialLayout(ProtocolType *type);
ExistentialLayout(ProtocolCompositionType *type);
ExistentialLayout(ParametrizedProtocolType *type);
ExistentialLayout(ParameterizedProtocolType *type);

/// The explicit superclass constraint, if any.
Type explicitSuperclass;
Expand Down Expand Up @@ -116,7 +116,7 @@ struct ExistentialLayout {
ArrayRef<Type> protocols;

/// Zero or more primary associated type requirements from a
/// ParametrizedProtocolType
/// ParameterizedProtocolType
ArrayRef<PrimaryAssociatedTypeRequirement> sameTypeRequirements;
};

Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/TypeDifferenceVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ class CanTypeDifferenceVisitor : public CanTypePairVisitor<Impl, bool> {
type1->getMembers(), type2->getMembers());
}

bool visitParametrizedProtocolType(CanParametrizedProtocolType type1,
CanParametrizedProtocolType type2) {
bool visitParameterizedProtocolType(CanParameterizedProtocolType type1,
CanParameterizedProtocolType type2) {
if (asImpl().visit(type1.getBaseType(), type2.getBaseType()))
return true;

Expand Down
12 changes: 6 additions & 6 deletions include/swift/AST/TypeMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,20 @@ class TypeMatcher {
TRIVIAL_CASE(SILBoxType)
TRIVIAL_CASE(ProtocolCompositionType)

bool visitParametrizedProtocolType(CanParametrizedProtocolType firstParametrizedProto,
Type secondType,
Type sugaredFirstType) {
if (auto secondParametrizedProto = secondType->getAs<ParametrizedProtocolType>()) {
bool visitParameterizedProtocolType(CanParameterizedProtocolType firstParametrizedProto,
Type secondType,
Type sugaredFirstType) {
if (auto secondParametrizedProto = secondType->getAs<ParameterizedProtocolType>()) {
if (!this->visit(firstParametrizedProto.getBaseType(),
secondParametrizedProto->getBaseType(),
sugaredFirstType->castTo<ParametrizedProtocolType>()
sugaredFirstType->castTo<ParameterizedProtocolType>()
->getBaseType())) {
return false;
}

return this->visit(firstParametrizedProto.getArgumentType(),
secondParametrizedProto->getArgumentType(),
sugaredFirstType->castTo<ParametrizedProtocolType>()
sugaredFirstType->castTo<ParameterizedProtocolType>()
->getArgumentType());
}

Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/TypeNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ ARTIFICIAL_TYPE(SILBlockStorage, Type)
ARTIFICIAL_TYPE(SILBox, Type)
ARTIFICIAL_TYPE(SILToken, Type)
TYPE(ProtocolComposition, Type)
TYPE(ParametrizedProtocol, Type)
TYPE(ParameterizedProtocol, Type)
TYPE(Existential, Type)
TYPE(LValue, Type)
TYPE(InOut, Type)
Expand Down
19 changes: 10 additions & 9 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5243,7 +5243,7 @@ class ProtocolCompositionType final : public TypeBase,
BEGIN_CAN_TYPE_WRAPPER(ProtocolCompositionType, Type)
END_CAN_TYPE_WRAPPER(ProtocolCompositionType, Type)

/// ParametrizedProtocolType - A type that constrains the primary associated
/// ParameterizedProtocolType - A type that constrains the primary associated
/// type of a protocol to an argument type.
///
/// Written like a bound generic type, eg Sequence<Int>.
Expand All @@ -5259,7 +5259,7 @@ END_CAN_TYPE_WRAPPER(ProtocolCompositionType, Type)
/// \code
/// T : Sequence where T.Element == Int.
/// \endcode
class ParametrizedProtocolType final : public TypeBase,
class ParameterizedProtocolType final : public TypeBase,
public llvm::FoldingSetNode {
friend struct ExistentialLayout;

Expand Down Expand Up @@ -5294,18 +5294,18 @@ class ParametrizedProtocolType final : public TypeBase,

// Implement isa/cast/dyncast/etc.
static bool classof(const TypeBase *T) {
return T->getKind() == TypeKind::ParametrizedProtocol;
return T->getKind() == TypeKind::ParameterizedProtocol;
}

private:
ParametrizedProtocolType(const ASTContext *ctx,
ProtocolType *base, Type arg,
RecursiveTypeProperties properties);
ParameterizedProtocolType(const ASTContext *ctx,
ProtocolType *base, Type arg,
RecursiveTypeProperties properties);
};
BEGIN_CAN_TYPE_WRAPPER(ParametrizedProtocolType, Type)
BEGIN_CAN_TYPE_WRAPPER(ParameterizedProtocolType, Type)
PROXY_CAN_TYPE_SIMPLE_GETTER(getBaseType)
PROXY_CAN_TYPE_SIMPLE_GETTER(getArgumentType)
END_CAN_TYPE_WRAPPER(ParametrizedProtocolType, Type)
END_CAN_TYPE_WRAPPER(ParameterizedProtocolType, Type)

/// An existential type, spelled with \c any .
///
Expand Down Expand Up @@ -6365,7 +6365,8 @@ inline bool TypeBase::isConstraintType() const {

inline bool CanType::isConstraintTypeImpl(CanType type) {
return (isa<ProtocolType>(type) ||
isa<ProtocolCompositionType>(type));
isa<ProtocolCompositionType>(type) ||
isa<ParameterizedProtocolType>(type));
}

inline bool TypeBase::isExistentialType() {
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ namespace swift {
/// keyword.
bool EnableExplicitExistentialTypes = true;

/// Enable support for protocol types parametrized by primary
/// Enable support for protocol types parameterized by primary
/// associated type.
bool EnableParametrizedProtocolTypes = false;
bool EnableParameterizedProtocolTypes = false;

/// Enable experimental flow-sensitive concurrent captures.
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
Expand Down
6 changes: 3 additions & 3 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,9 @@ def enable_explicit_existential_types :
Flag<["-"], "enable-explicit-existential-types">,
HelpText<"Enable experimental support for explicit existential types">;

def enable_parametrized_protocol_types :
Flag<["-"], "enable-parametrized-protocol-types">,
HelpText<"Enable experimental support for primary associated types and parametrized protocols">;
def enable_parameterized_protocol_types :
Flag<["-"], "enable-parameterized-protocol-types">,
HelpText<"Enable experimental support for primary associated types and parameterized protocols">;

def enable_deserialization_recovery :
Flag<["-"], "enable-deserialization-recovery">,
Expand Down
16 changes: 8 additions & 8 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ struct ASTContext::Implementation {
llvm::FoldingSet<UnboundGenericType> UnboundGenericTypes;
llvm::FoldingSet<BoundGenericType> BoundGenericTypes;
llvm::FoldingSet<ProtocolCompositionType> ProtocolCompositionTypes;
llvm::FoldingSet<ParametrizedProtocolType> ParametrizedProtocolTypes;
llvm::FoldingSet<ParameterizedProtocolType> ParameterizedProtocolTypes;
llvm::FoldingSet<LayoutConstraintInfo> LayoutConstraints;
llvm::DenseMap<std::pair<OpaqueTypeDecl *, SubstitutionMap>,
GenericEnvironment *> OpaqueArchetypeEnvironments;
Expand Down Expand Up @@ -3404,9 +3404,9 @@ ProtocolCompositionType::build(const ASTContext &C, ArrayRef<Type> Members,
return compTy;
}

Type ParametrizedProtocolType::get(const ASTContext &C,
ProtocolType *baseTy,
Type argTy) {
Type ParameterizedProtocolType::get(const ASTContext &C,
ProtocolType *baseTy,
Type argTy) {
bool isCanonical = baseTy->isCanonical();
RecursiveTypeProperties properties = baseTy->getRecursiveProperties();
properties |= argTy->getRecursiveProperties();
Expand All @@ -3416,16 +3416,16 @@ Type ParametrizedProtocolType::get(const ASTContext &C,

void *InsertPos = nullptr;
llvm::FoldingSetNodeID ID;
ParametrizedProtocolType::Profile(ID, baseTy, argTy);
ParameterizedProtocolType::Profile(ID, baseTy, argTy);

if (auto paramTy
= C.getImpl().getArena(arena).ParametrizedProtocolTypes
= C.getImpl().getArena(arena).ParameterizedProtocolTypes
.FindNodeOrInsertPos(ID, InsertPos))
return paramTy;

auto paramTy = new (C, arena) ParametrizedProtocolType(
auto paramTy = new (C, arena) ParameterizedProtocolType(
isCanonical ? &C : nullptr, baseTy, argTy, properties);
C.getImpl().getArena(arena).ParametrizedProtocolTypes.InsertNode(
C.getImpl().getArena(arena).ParameterizedProtocolTypes.InsertNode(
paramTy, InsertPos);
return paramTy;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3942,9 +3942,9 @@ namespace {
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}

void visitParametrizedProtocolType(ParametrizedProtocolType *T,
StringRef label) {
printCommon(label, "parametrized_protocol_type");
void visitParameterizedProtocolType(ParameterizedProtocolType *T,
StringRef label) {
printCommon(label, "parameterized_protocol_type");
printRec("base", T->getBaseType());
printRec("arg", T->getArgumentType());
PrintWithColorRAII(OS, ParenthesisColor) << ')';
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
return appendExistentialLayout(layout, sig, forDecl);
}

case TypeKind::ParametrizedProtocol: {
case TypeKind::ParameterizedProtocol: {
llvm::errs() << "Not implemented\n";
abort();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5921,7 +5921,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
}
}

void visitParametrizedProtocolType(ParametrizedProtocolType *T) {
void visitParameterizedProtocolType(ParameterizedProtocolType *T) {
visit(T->getBaseType());
Printer << "<";
visit(T->getArgumentType());
Expand Down
6 changes: 2 additions & 4 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4500,9 +4500,7 @@ ConstraintResult GenericSignatureBuilder::addTypeRequirement(
}

// Check whether we have a reasonable constraint type at all.
if (!constraintType->is<ProtocolType>() &&
!constraintType->is<ProtocolCompositionType>() &&
!constraintType->is<ParametrizedProtocolType>() &&
if (!constraintType->isConstraintType() &&
!constraintType->getClassOrBoundGenericClass()) {
if (source.getLoc().isValid() && !constraintType->hasError()) {
Impl->HadAnyError = true;
Expand All @@ -4516,7 +4514,7 @@ ConstraintResult GenericSignatureBuilder::addTypeRequirement(
}

// Parametrized protocol requirements.
if (auto *paramProtoType = constraintType->getAs<ParametrizedProtocolType>()) {
if (auto *paramProtoType = constraintType->getAs<ParameterizedProtocolType>()) {
bool anyErrors = false;

auto *protoDecl = paramProtoType->getBaseType()->getDecl();
Expand Down
6 changes: 2 additions & 4 deletions lib/AST/RequirementMachine/RequirementLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void desugarConformanceRequirement(Type subjectType, Type constraintType,
return;
}

if (auto *paramType = constraintType->getAs<ParametrizedProtocolType>()) {
if (auto *paramType = constraintType->getAs<ParameterizedProtocolType>()) {
auto *protoDecl = paramType->getBaseType()->getDecl();

desugarConformanceRequirement(subjectType, paramType->getBaseType(),
Expand Down Expand Up @@ -212,9 +212,7 @@ static void realizeTypeRequirement(Type subjectType, Type constraintType,
SmallVectorImpl<StructuralRequirement> &result) {
SmallVector<Requirement, 2> reqs;

if (constraintType->is<ProtocolType>() ||
constraintType->is<ProtocolCompositionType>() ||
constraintType->is<ParametrizedProtocolType>()) {
if (constraintType->isConstraintType()) {
// Handle conformance requirements.
desugarConformanceRequirement(subjectType, constraintType, reqs);
} else if (constraintType->getClassOrBoundGenericClass()) {
Expand Down
34 changes: 17 additions & 17 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ bool CanType::isReferenceTypeImpl(CanType type, const GenericSignatureImpl *sig,
return cast<ProtocolType>(type)->requiresClass();
case TypeKind::ProtocolComposition:
return cast<ProtocolCompositionType>(type)->requiresClass();
case TypeKind::ParametrizedProtocol:
return cast<ParametrizedProtocolType>(type)->getBaseType()->requiresClass();
case TypeKind::ParameterizedProtocol:
return cast<ParameterizedProtocolType>(type)->getBaseType()->requiresClass();
case TypeKind::Existential:
return isReferenceTypeImpl(cast<ExistentialType>(type).getConstraintType(),
sig, functionsCount);
Expand Down Expand Up @@ -295,7 +295,7 @@ ExistentialLayout::ExistentialLayout(ProtocolCompositionType *type) {
protocols = { members.data(), members.size() };
}

ExistentialLayout::ExistentialLayout(ParametrizedProtocolType *type) {
ExistentialLayout::ExistentialLayout(ParameterizedProtocolType *type) {
assert(type->isCanonical());

*this = ExistentialLayout(type->getBaseType());
Expand All @@ -319,7 +319,7 @@ ExistentialLayout CanType::getExistentialLayout() {
if (auto proto = dyn_cast<ProtocolType>(*this))
return ExistentialLayout(proto);

if (auto param = dyn_cast<ParametrizedProtocolType>(*this))
if (auto param = dyn_cast<ParameterizedProtocolType>(*this))
return ExistentialLayout(param);

auto comp = cast<ProtocolCompositionType>(*this);
Expand Down Expand Up @@ -1553,12 +1553,12 @@ CanType TypeBase::computeCanonicalType() {
Result = Composition.getPointer();
break;
}
case TypeKind::ParametrizedProtocol: {
auto *PPT = cast<ParametrizedProtocolType>(this);
case TypeKind::ParameterizedProtocol: {
auto *PPT = cast<ParameterizedProtocolType>(this);
auto Base = cast<ProtocolType>(PPT->getBaseType()->getCanonicalType());
auto Arg = PPT->getArgumentType()->getCanonicalType();
auto &C = Base->getASTContext();
Result = ParametrizedProtocolType::get(C, Base, Arg).getPointer();
Result = ParameterizedProtocolType::get(C, Base, Arg).getPointer();
break;
}
case TypeKind::Existential: {
Expand Down Expand Up @@ -3873,20 +3873,20 @@ void ProtocolCompositionType::Profile(llvm::FoldingSetNodeID &ID,
ID.AddPointer(T.getPointer());
}

ParametrizedProtocolType::ParametrizedProtocolType(
ParameterizedProtocolType::ParameterizedProtocolType(
const ASTContext *ctx,
ProtocolType *base, Type arg,
RecursiveTypeProperties properties)
: TypeBase(TypeKind::ParametrizedProtocol, /*Context=*/ctx, properties),
: TypeBase(TypeKind::ParameterizedProtocol, /*Context=*/ctx, properties),
Base(base), AssocType(base->getDecl()->getPrimaryAssociatedType()),
Arg(arg) {
assert(AssocType != nullptr &&
"Protocol doesn't have a primary associated type");
}

void ParametrizedProtocolType::Profile(llvm::FoldingSetNodeID &ID,
ProtocolType *baseTy,
Type argTy) {
void ParameterizedProtocolType::Profile(llvm::FoldingSetNodeID &ID,
ProtocolType *baseTy,
Type argTy) {
ID.AddPointer(baseTy);
ID.AddPointer(argTy.getPointer());
}
Expand Down Expand Up @@ -5676,8 +5676,8 @@ case TypeKind::Id:
pc->hasExplicitAnyObject());
}

case TypeKind::ParametrizedProtocol: {
auto *ppt = cast<ParametrizedProtocolType>(base);
case TypeKind::ParameterizedProtocol: {
auto *ppt = cast<ParameterizedProtocolType>(base);
Type base = ppt->getBaseType();
Type arg = ppt->getArgumentType();

Expand All @@ -5700,7 +5700,7 @@ case TypeKind::Id:
if (!anyChanged)
return *this;

return ParametrizedProtocolType::get(
return ParameterizedProtocolType::get(
Ptr->getASTContext(),
substBase->castTo<ProtocolType>(),
substArg);
Expand Down Expand Up @@ -5863,8 +5863,8 @@ ReferenceCounting TypeBase::getReferenceCounting() {
return ReferenceCounting::Unknown;
}

case TypeKind::ParametrizedProtocol: {
return cast<ParametrizedProtocolType>(this)
case TypeKind::ParameterizedProtocol: {
return cast<ParameterizedProtocolType>(this)
->getBaseType()
->getReferenceCounting();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/TypeWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Traversal : public TypeVisitor<Traversal, bool>
return false;
}

bool visitParametrizedProtocolType(ParametrizedProtocolType *ty) {
bool visitParameterizedProtocolType(ParameterizedProtocolType *ty) {
if (doIt(ty->getBaseType()))
return true;

Expand Down
4 changes: 2 additions & 2 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableExplicitExistentialTypes |=
Args.hasArg(OPT_enable_explicit_existential_types);

Opts.EnableParametrizedProtocolTypes |=
Args.hasArg(OPT_enable_parametrized_protocol_types);
Opts.EnableParameterizedProtocolTypes |=
Args.hasArg(OPT_enable_parameterized_protocol_types);

Opts.EnableExperimentalDistributed |=
Args.hasArg(OPT_enable_experimental_distributed);
Expand Down
Loading