Skip to content

Commit 2c35b65

Browse files
committed
[CSDiagnostics] Adjust a couple of diagnostics to not respect different anchor kinds
1 parent 01691d6 commit 2c35b65

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,7 +3809,10 @@ bool MissingMemberFailure::diagnoseForDynamicCallable() const {
38093809
}
38103810

38113811
bool MissingMemberFailure::diagnoseInLiteralCollectionContext() const {
3812-
auto *expr = castToExpr(getAnchor());
3812+
auto *expr = getAsExpr(getAnchor());
3813+
if (!expr)
3814+
return false;
3815+
38133816
auto *parentExpr = findParentExpr(expr);
38143817
auto &solution = getSolution();
38153818

@@ -5918,8 +5921,11 @@ void MissingGenericArgumentsFailure::emitGenericSignatureNote(
59185921
return (type == params.end()) ? Type() : type->second;
59195922
};
59205923

5924+
auto baseType = anchor.dyn_cast<TypeRepr *>();
5925+
if (!baseType)
5926+
return;
5927+
59215928
SmallString<64> paramsAsString;
5922-
auto baseType = anchor.get<TypeRepr *>();
59235929
if (TypeChecker::getDefaultGenericArgumentsString(paramsAsString, GTD,
59245930
getPreferredType)) {
59255931
auto diagnostic = emitDiagnosticAt(

0 commit comments

Comments
 (0)