Skip to content

Commit 00766f7

Browse files
committed
AST: Remove type parameter from ProtocolConformanceRef::getTypeWitnessByName()
1 parent 9150371 commit 00766f7

11 files changed

+17
-20
lines changed

include/swift/AST/ProtocolConformanceRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class ProtocolConformanceRef {
234234
return llvm::hash_value(conformance.Union.getOpaqueValue());
235235
}
236236

237-
Type getTypeWitnessByName(Type type, Identifier name) const;
237+
Type getTypeWitnessByName(Identifier name) const;
238238

239239
/// Find a particular named function witness for a type that conforms to
240240
/// the given protocol.

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6486,7 +6486,7 @@ Type ASTContext::getBridgedToObjC(const DeclContext *dc, Type type,
64866486
*bridgedValueType = type;
64876487

64886488
// Find the Objective-C class type we bridge to.
6489-
Type witnessTy = conformance.getTypeWitnessByName(type, Id_ObjectiveCType);
6489+
Type witnessTy = conformance.getTypeWitnessByName(Id_ObjectiveCType);
64906490
// If Objective-C import is broken, witness type would be a dependent member
64916491
// with `<<error type>>` base.
64926492
return (witnessTy && !witnessTy->hasError()) ? witnessTy : Type();

lib/AST/DistributedDecl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Type swift::getDistributedActorSystemType(NominalTypeDecl *actor) {
203203
// Dig out the actor system type.
204204
Type selfType = actor->getSelfInterfaceType();
205205
auto conformance = lookupConformance(selfType, DA);
206-
return conformance.getTypeWitnessByName(selfType, C.Id_ActorSystem);
206+
return conformance.getTypeWitnessByName(C.Id_ActorSystem);
207207
}
208208

209209
Type swift::getDistributedActorIDType(NominalTypeDecl *actor) {
@@ -220,7 +220,7 @@ static Type getTypeWitnessByName(NominalTypeDecl *type, ProtocolDecl *protocol,
220220
auto conformance = lookupConformance(selfType, protocol);
221221
if (!conformance || conformance.isInvalid())
222222
return Type();
223-
return conformance.getTypeWitnessByName(selfType, member);
223+
return conformance.getTypeWitnessByName(member);
224224
}
225225

226226
Type swift::getDistributedActorSerializationType(
@@ -301,8 +301,7 @@ Type swift::getDistributedSerializationRequirementType(
301301
if (conformance.isInvalid())
302302
return Type();
303303

304-
return conformance.getTypeWitnessByName(selfType,
305-
ctx.Id_SerializationRequirement);
304+
return conformance.getTypeWitnessByName(ctx.Id_SerializationRequirement);
306305
}
307306

308307
AbstractFunctionDecl *

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ProtocolConformanceRef ProtocolConformanceRef::mapConformanceOutOfContext() cons
149149
}
150150

151151
Type
152-
ProtocolConformanceRef::getTypeWitnessByName(Type type, Identifier name) const {
152+
ProtocolConformanceRef::getTypeWitnessByName(Identifier name) const {
153153
assert(!isInvalid());
154154

155155
// Find the named requirement.

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,8 +2207,7 @@ class DeclAndTypePrinter::Implementation
22072207
return nullptr;
22082208

22092209
// Dig out the Objective-C type.
2210-
Type objcType = conformance.getTypeWitnessByName(
2211-
declaredType, ctx.Id_ObjectiveCType);
2210+
Type objcType = conformance.getTypeWitnessByName(ctx.Id_ObjectiveCType);
22122211

22132212
// Dig out the Objective-C class.
22142213
return objcType->getClassOrBoundGenericClass();

lib/SIL/IR/Bridging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Type TypeConverter::getLoweredCBridgedType(AbstractionPattern pattern,
240240
assert(conformance && "Missing conformance?");
241241
Type bridgedTy =
242242
ProtocolConformanceRef(conformance).getTypeWitnessByName(
243-
t, M.getASTContext().Id_ObjectiveCType);
243+
M.getASTContext().Id_ObjectiveCType);
244244
if (purpose == BridgedTypePurpose::ForResult && clangTy)
245245
bridgedTy = OptionalType::get(bridgedTy);
246246
return bridgedTy;

lib/Sema/CSApply.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8106,7 +8106,7 @@ Expr *ExprRewriter::convertLiteralInPlace(
81068106
if (!literalType.empty()) {
81078107
// Extract the literal type.
81088108
Type builtinLiteralType =
8109-
conformance.getTypeWitnessByName(type, literalType);
8109+
conformance.getTypeWitnessByName(literalType);
81108110
if (builtinLiteralType->hasError())
81118111
return nullptr;
81128112

@@ -8222,9 +8222,8 @@ std::pair<Expr *, ArgumentList *> ExprRewriter::buildDynamicCallable(
82228222
auto dictLitProto =
82238223
ctx.getProtocol(KnownProtocolKind::ExpressibleByDictionaryLiteral);
82248224
auto conformance = checkConformance(argumentType, dictLitProto);
8225-
auto keyType = conformance.getTypeWitnessByName(argumentType, ctx.Id_Key);
8226-
auto valueType =
8227-
conformance.getTypeWitnessByName(argumentType, ctx.Id_Value);
8225+
auto keyType = conformance.getTypeWitnessByName(ctx.Id_Key);
8226+
auto valueType = conformance.getTypeWitnessByName(ctx.Id_Value);
82288227
SmallVector<Identifier, 4> names;
82298228
SmallVector<Expr *, 4> dictElements;
82308229
for (auto arg : *args) {

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3302,7 +3302,7 @@ bool ContextualFailure::diagnoseThrowsTypeMismatch() const {
33023302
if (conformance && toErrorExistential) {
33033303
Type errorType =
33043304
conformance
3305-
.getTypeWitnessByName(errorCodeType, getASTContext().Id_ErrorType)
3305+
.getTypeWitnessByName(getASTContext().Id_ErrorType)
33063306
->getCanonicalType();
33073307
if (errorType) {
33083308
auto diagnostic = emitDiagnostic(diag::cannot_throw_error_code,

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3886,7 +3886,7 @@ Type constraints::isRawRepresentable(ConstraintSystem &cs, Type type) {
38863886
if (conformance.isInvalid())
38873887
return Type();
38883888

3889-
return conformance.getTypeWitnessByName(type, cs.getASTContext().Id_RawValue);
3889+
return conformance.getTypeWitnessByName(cs.getASTContext().Id_RawValue);
38903890
}
38913891

38923892
void ConstraintSystem::generateOverloadConstraints(

lib/Sema/DerivedConformanceDifferentiable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static Type getTangentVectorInterfaceType(Type contextualType,
121121
assert(conf && "Contextual type must conform to `Differentiable`");
122122
if (!conf)
123123
return nullptr;
124-
auto tanType = conf.getTypeWitnessByName(contextualType, C.Id_TangentVector);
124+
auto tanType = conf.getTypeWitnessByName(C.Id_TangentVector);
125125
return tanType->hasArchetype() ? tanType->mapTypeOutOfContext() : tanType;
126126
}
127127

@@ -150,7 +150,7 @@ static bool canDeriveTangentVectorAsSelf(NominalTypeDecl *nominal,
150150
auto conf = checkConformance(fieldType, diffableProto);
151151
if (!conf)
152152
return false;
153-
auto tangentType = conf.getTypeWitnessByName(fieldType, C.Id_TangentVector);
153+
auto tangentType = conf.getTypeWitnessByName(C.Id_TangentVector);
154154
if (!fieldType->isEqual(tangentType))
155155
return false;
156156
}

0 commit comments

Comments
 (0)