Skip to content

Commit 7399eeb

Browse files
committed
AST: Remove type parameter from ProtocolConformanceRef::getWitnessByName()
1 parent 26543d1 commit 7399eeb

File tree

7 files changed

+13
-15
lines changed

7 files changed

+13
-15
lines changed

include/swift/AST/ProtocolConformanceRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class ProtocolConformanceRef {
242242
/// \param type The conforming type.
243243
///
244244
/// \param name The name of the requirement.
245-
ConcreteDeclRef getWitnessByName(Type type, DeclName name) const;
245+
ConcreteDeclRef getWitnessByName(DeclName name) const;
246246

247247
/// Determine whether this conformance is canonical.
248248
bool isCanonical() const;

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ ASTContext::getBuiltinInitDecl(NominalTypeDecl *decl,
16781678
}
16791679

16801680
auto *ctx = const_cast<ASTContext *>(this);
1681-
witness = builtinConformance.getWitnessByName(type, initName(*ctx));
1681+
witness = builtinConformance.getWitnessByName(initName(*ctx));
16821682
if (!witness) {
16831683
assert(false && "Missing required witness");
16841684
witness = ConcreteDeclRef();

lib/AST/ActorIsolation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ActorIsolation::forActorInstanceParameter(Expr *actor,
6161
if (auto globalActor = ctx.getProtocol(KnownProtocolKind::GlobalActor)) {
6262
auto conformance = checkConformance(baseType, globalActor);
6363
if (conformance &&
64-
conformance.getWitnessByName(baseType, ctx.Id_shared) == declRef) {
64+
conformance.getWitnessByName(ctx.Id_shared) == declRef) {
6565
return ActorIsolation::forGlobalActor(baseType);
6666
}
6767
}

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ProtocolConformanceRef::getTypeWitnessByName(Identifier name) const {
164164
}
165165

166166
ConcreteDeclRef
167-
ProtocolConformanceRef::getWitnessByName(Type type, DeclName name) const {
167+
ProtocolConformanceRef::getWitnessByName(DeclName name) const {
168168
// Find the named requirement.
169169
auto *proto = getProtocol();
170170
auto *requirement = proto->getSingleRequirement(name);
@@ -174,7 +174,7 @@ ProtocolConformanceRef::getWitnessByName(Type type, DeclName name) const {
174174
// For a type with dependent conformance, just return the requirement from
175175
// the protocol. There are no protocol conformance tables.
176176
if (!isConcrete()) {
177-
auto subs = SubstitutionMap::getProtocolSubstitutions(proto, type, *this);
177+
auto subs = SubstitutionMap::getProtocolSubstitutions(proto, getType(), *this);
178178
return ConcreteDeclRef(requirement, subs);
179179
}
180180

lib/Sema/CSApply.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,7 @@ namespace {
29702970
DeclName constrName(ctx, DeclBaseName::createConstructor(), argLabels);
29712971

29722972
ConcreteDeclRef witness =
2973-
conformance.getWitnessByName(type->getRValueType(), constrName);
2973+
conformance.getWitnessByName(constrName);
29742974
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
29752975
return nullptr;
29762976
return witness;
@@ -3108,8 +3108,7 @@ namespace {
31083108

31093109
auto constrName = TypeChecker::getObjectLiteralConstructorName(ctx, expr);
31103110

3111-
ConcreteDeclRef witness = conformance.getWitnessByName(
3112-
conformingType->getRValueType(), constrName);
3111+
ConcreteDeclRef witness = conformance.getWitnessByName(constrName);
31133112

31143113
auto selectedOverload = solution.getOverloadChoiceIfAvailable(
31153114
cs.getConstraintLocator(expr, ConstraintLocator::ConstructorMember));
@@ -3822,7 +3821,7 @@ namespace {
38223821
DeclName name(ctx, DeclBaseName::createConstructor(),
38233822
{ctx.Id_arrayLiteral});
38243823
ConcreteDeclRef witness =
3825-
conformance.getWitnessByName(arrayTy->getRValueType(), name);
3824+
conformance.getWitnessByName(name);
38263825
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
38273826
return nullptr;
38283827
expr->setInitializer(witness);
@@ -3868,7 +3867,7 @@ namespace {
38683867
DeclName name(ctx, DeclBaseName::createConstructor(),
38693868
{ctx.Id_dictionaryLiteral});
38703869
ConcreteDeclRef witness =
3871-
conformance.getWitnessByName(dictionaryTy->getRValueType(), name);
3870+
conformance.getWitnessByName(name);
38723871
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
38733872
return nullptr;
38743873
expr->setInitializer(witness);
@@ -8081,7 +8080,7 @@ Expr *ExprRewriter::convertLiteralInPlace(
80818080
// Find the witness that we'll use to initialize the type via a builtin
80828081
// literal.
80838082
auto witness = builtinConformance.getWitnessByName(
8084-
type->getRValueType(), builtinLiteralFuncName);
8083+
builtinLiteralFuncName);
80858084
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
80868085
return nullptr;
80878086

@@ -8120,7 +8119,7 @@ Expr *ExprRewriter::convertLiteralInPlace(
81208119

81218120
// Find the witness that we'll use to initialize the literal value.
81228121
auto witness =
8123-
conformance.getWitnessByName(type->getRValueType(), literalFuncName);
8122+
conformance.getWitnessByName(literalFuncName);
81248123
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
81258124
return nullptr;
81268125

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11726,7 +11726,7 @@ ConstraintSystem::simplifyValueWitnessConstraint(
1172611726
return formUnsolved();
1172711727

1172811728
auto witness =
11729-
conformance.getWitnessByName(baseObjectType, requirement->getName());
11729+
conformance.getWitnessByName(requirement->getName());
1173011730
if (!witness)
1173111731
return fail();
1173211732

lib/Sema/DerivedConformanceDifferentiable.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ static bool canInvokeMoveByOnProperty(
5050
return true;
5151
// When the property is a `let`, the only case that would be supported is when
5252
// it has a `move(by:)` protocol requirement witness that is non-mutating.
53-
auto interfaceType = vd->getInterfaceType();
5453
auto &C = vd->getASTContext();
5554
auto witness = diffableConformance.getWitnessByName(
56-
interfaceType, DeclName(C, C.Id_move, {C.Id_by}));
55+
DeclName(C, C.Id_move, {C.Id_by}));
5756
if (!witness)
5857
return false;
5958
auto *decl = cast<FuncDecl>(witness.getDecl());

0 commit comments

Comments
 (0)