Skip to content

Remove TypeChecker::getWitnessType() #26138

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 1 commit into from
Jul 15, 2019
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
12 changes: 0 additions & 12 deletions lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5473,15 +5473,3 @@ void TypeChecker::inferDefaultWitnesses(ProtocolDecl *proto) {
req.getFirstType()->getCanonicalType(), requirementProto, *conformance);
}
}

Type TypeChecker::getWitnessType(Type type, ProtocolDecl *protocol,
ProtocolConformanceRef conformance,
Identifier name,
Diag<> brokenProtocolDiag) {
Type ty = conformance.getTypeWitnessByName(type, name);
if (!ty &&
!(conformance.isConcrete() && conformance.getConcrete()->isInvalid()))
diagnose(protocol->getLoc(), brokenProtocolDiag);

return (!ty || ty->hasError()) ? Type() : ty;
}
12 changes: 5 additions & 7 deletions lib/Sema/TypeCheckStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
return nullptr;
S->setSequenceConformance(conformance);

iteratorTy = TC.getWitnessType(sequenceType, sequenceProto, *conformance,
TC.Context.Id_Iterator,
diag::sequence_protocol_broken);
iteratorTy = conformance->getTypeWitnessByName(sequenceType,
TC.Context.Id_Iterator);
if (!iteratorTy)
return nullptr;

Expand Down Expand Up @@ -796,7 +795,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
// be around.
auto nextResultType =
OptionalType::get(conformance->getTypeWitnessByName(
sequenceType, DC->getASTContext().Id_Element))
sequenceType, TC.Context.Id_Element))
->getCanonicalType();
auto *genBinding = PatternBindingDecl::createImplicit(
TC.Context, StaticSpellingKind::None, genPat,
Expand Down Expand Up @@ -829,9 +828,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
if (!genConformance)
return nullptr;

Type elementTy = TC.getWitnessType(iteratorTy, iteratorProto,
*genConformance, TC.Context.Id_Element,
diag::iterator_protocol_broken);
Type elementTy = genConformance->getTypeWitnessByName(iteratorTy,
TC.Context.Id_Element);
if (!elementTy)
return nullptr;

Expand Down
20 changes: 0 additions & 20 deletions lib/Sema/TypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -1536,26 +1536,6 @@ class TypeChecker final : public LazyResolver {
/// array literals exist.
bool requireArrayLiteralIntrinsics(SourceLoc loc);

/// Retrieve the witness type with the given name.
///
/// \param type The type that conforms to the given protocol.
///
/// \param protocol The protocol through which we're looking.
///
/// \param conformance The protocol conformance.
///
/// \param name The name of the associated type.
///
/// \param brokenProtocolDiag Diagnostic to emit if the type cannot be
/// accessed.
///
/// \return the witness type, or null if an error occurs or the type
/// returned would contain an ErrorType.
Type getWitnessType(Type type, ProtocolDecl *protocol,
ProtocolConformanceRef conformance,
Identifier name,
Diag<> brokenProtocolDiag);

/// Build a call to the witness with the given name and arguments.
///
/// \param base The base expression, whose witness will be invoked.
Expand Down