Skip to content

Commit b28b44b

Browse files
authored
Merge pull request #26138 from slavapestov/remove-get-witness-type
Remove TypeChecker::getWitnessType()
2 parents 768b91e + 6025608 commit b28b44b

File tree

3 files changed

+5
-39
lines changed

3 files changed

+5
-39
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5473,15 +5473,3 @@ void TypeChecker::inferDefaultWitnesses(ProtocolDecl *proto) {
54735473
req.getFirstType()->getCanonicalType(), requirementProto, *conformance);
54745474
}
54755475
}
5476-
5477-
Type TypeChecker::getWitnessType(Type type, ProtocolDecl *protocol,
5478-
ProtocolConformanceRef conformance,
5479-
Identifier name,
5480-
Diag<> brokenProtocolDiag) {
5481-
Type ty = conformance.getTypeWitnessByName(type, name);
5482-
if (!ty &&
5483-
!(conformance.isConcrete() && conformance.getConcrete()->isInvalid()))
5484-
diagnose(protocol->getLoc(), brokenProtocolDiag);
5485-
5486-
return (!ty || ty->hasError()) ? Type() : ty;
5487-
}

lib/Sema/TypeCheckStmt.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
763763
return nullptr;
764764
S->setSequenceConformance(conformance);
765765

766-
iteratorTy = TC.getWitnessType(sequenceType, sequenceProto, *conformance,
767-
TC.Context.Id_Iterator,
768-
diag::sequence_protocol_broken);
766+
iteratorTy = conformance->getTypeWitnessByName(sequenceType,
767+
TC.Context.Id_Iterator);
769768
if (!iteratorTy)
770769
return nullptr;
771770

@@ -796,7 +795,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
796795
// be around.
797796
auto nextResultType =
798797
OptionalType::get(conformance->getTypeWitnessByName(
799-
sequenceType, DC->getASTContext().Id_Element))
798+
sequenceType, TC.Context.Id_Element))
800799
->getCanonicalType();
801800
auto *genBinding = PatternBindingDecl::createImplicit(
802801
TC.Context, StaticSpellingKind::None, genPat,
@@ -829,9 +828,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
829828
if (!genConformance)
830829
return nullptr;
831830

832-
Type elementTy = TC.getWitnessType(iteratorTy, iteratorProto,
833-
*genConformance, TC.Context.Id_Element,
834-
diag::iterator_protocol_broken);
831+
Type elementTy = genConformance->getTypeWitnessByName(iteratorTy,
832+
TC.Context.Id_Element);
835833
if (!elementTy)
836834
return nullptr;
837835

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,26 +1536,6 @@ class TypeChecker final : public LazyResolver {
15361536
/// array literals exist.
15371537
bool requireArrayLiteralIntrinsics(SourceLoc loc);
15381538

1539-
/// Retrieve the witness type with the given name.
1540-
///
1541-
/// \param type The type that conforms to the given protocol.
1542-
///
1543-
/// \param protocol The protocol through which we're looking.
1544-
///
1545-
/// \param conformance The protocol conformance.
1546-
///
1547-
/// \param name The name of the associated type.
1548-
///
1549-
/// \param brokenProtocolDiag Diagnostic to emit if the type cannot be
1550-
/// accessed.
1551-
///
1552-
/// \return the witness type, or null if an error occurs or the type
1553-
/// returned would contain an ErrorType.
1554-
Type getWitnessType(Type type, ProtocolDecl *protocol,
1555-
ProtocolConformanceRef conformance,
1556-
Identifier name,
1557-
Diag<> brokenProtocolDiag);
1558-
15591539
/// Build a call to the witness with the given name and arguments.
15601540
///
15611541
/// \param base The base expression, whose witness will be invoked.

0 commit comments

Comments
 (0)