Skip to content

Commit abc6db1

Browse files
committed
Provide AST Context Getters To Protocol Inference
1 parent dd46c88 commit abc6db1

File tree

6 files changed

+212
-214
lines changed

6 files changed

+212
-214
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,9 +2613,8 @@ bool ContextualFailure::tryProtocolConformanceFixIt(
26132613
// Let's build a list of protocols that the context does not conform to.
26142614
SmallVector<std::string, 8> missingProtoTypeStrings;
26152615
for (auto protocol : layout.getProtocols()) {
2616-
if (TypeChecker::conformsToProtocol(FromType, protocol->getDecl(), getDC(),
2617-
ConformanceCheckFlags::InExpression)
2618-
.isInvalid()) {
2616+
if (!TypeChecker::conformsToProtocol(FromType, protocol->getDecl(), getDC(),
2617+
ConformanceCheckFlags::InExpression)) {
26192618
missingProtoTypeStrings.push_back(protocol->getString());
26202619
}
26212620
}

lib/Sema/CSRanking.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static bool isNominallySuperclassOf(Type type1, Type type2) {
201201
/// Determine the relationship between the self types of the given declaration
202202
/// contexts..
203203
static std::pair<SelfTypeRelationship, ProtocolConformanceRef>
204-
computeSelfTypeRelationship(TypeChecker &tc, DeclContext *dc, ValueDecl *decl1,
204+
computeSelfTypeRelationship(DeclContext *dc, ValueDecl *decl1,
205205
ValueDecl *decl2) {
206206
// If both declarations are operators, even through they
207207
// might have Self such types are unrelated.
@@ -533,8 +533,7 @@ static bool isDeclAsSpecializedAs(TypeChecker &tc, DeclContext *dc,
533533
// Determine the relationship between the 'self' types and add the
534534
// appropriate constraints. The constraints themselves never fail, but
535535
// they help deduce type variables that were opened.
536-
auto selfTypeRelationship =
537-
computeSelfTypeRelationship(tc, dc, decl1, decl2);
536+
auto selfTypeRelationship = computeSelfTypeRelationship(dc, decl1, decl2);
538537
auto relationshipKind = selfTypeRelationship.first;
539538
auto conformance = selfTypeRelationship.second;
540539
(void)conformance;

0 commit comments

Comments
 (0)