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