@@ -937,19 +937,18 @@ static void maybeDiagnoseBadConformanceRef(DeclContext *dc,
937
937
SourceLoc loc,
938
938
TypeDecl *typeDecl) {
939
939
auto protocol = dyn_cast<ProtocolDecl>(typeDecl->getDeclContext ());
940
- if (!protocol)
941
- return ;
942
940
943
941
// If we weren't given a conformance, go look it up.
944
942
ProtocolConformance *conformance = nullptr ;
945
- if (auto conformanceRef = TypeChecker::conformsToProtocol (
946
- parentTy, protocol, dc,
947
- (ConformanceCheckFlags::InExpression |
948
- ConformanceCheckFlags::SuppressDependencyTracking |
949
- ConformanceCheckFlags::SkipConditionalRequirements))) {
950
- if (conformanceRef->isConcrete ())
951
- conformance = conformanceRef->getConcrete ();
952
- }
943
+ if (protocol)
944
+ if (auto conformanceRef = TypeChecker::conformsToProtocol (
945
+ parentTy, protocol, dc,
946
+ (ConformanceCheckFlags::InExpression |
947
+ ConformanceCheckFlags::SuppressDependencyTracking |
948
+ ConformanceCheckFlags::SkipConditionalRequirements))) {
949
+ if (conformanceRef->isConcrete ())
950
+ conformance = conformanceRef->getConcrete ();
951
+ }
953
952
954
953
// If any errors have occurred, don't bother diagnosing this cross-file
955
954
// issue.
@@ -958,7 +957,7 @@ static void maybeDiagnoseBadConformanceRef(DeclContext *dc,
958
957
return ;
959
958
960
959
auto diagCode =
961
- (conformance && !conformance->getConditionalRequirementsIfAvailable ())
960
+ (!protocol || (conformance && !conformance->getConditionalRequirementsIfAvailable () ))
962
961
? diag::unsupported_recursion_in_associated_type_reference
963
962
: diag::broken_associated_type_witness;
964
963
0 commit comments