Skip to content

Commit ca0f638

Browse files
authored
Merge pull request #36055 from xymus/fix-74446387
[Sema] Protect dereferencing null TypeReprs in associated type diagnostics
2 parents fa7374f + 42aea22 commit ca0f638

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,9 +1881,11 @@ bool AssociatedTypeInference::diagnoseAmbiguousSolutions(
18811881
}
18821882

18831883
// Otherwise, we have a default.
1884-
diags.diagnose(assocType, diag::associated_type_deduction_default,
1885-
type)
1886-
.highlight(assocType->getDefaultDefinitionTypeRepr()->getSourceRange());
1884+
auto defaultDiag =
1885+
diags.diagnose(assocType, diag::associated_type_deduction_default,
1886+
type);
1887+
if (auto defaultTypeRepr = assocType->getDefaultDefinitionTypeRepr())
1888+
defaultDiag.highlight(defaultTypeRepr->getSourceRange());
18871889
};
18881890

18891891
diagnoseWitness(firstMatch, firstType);

0 commit comments

Comments
 (0)