@@ -257,7 +257,8 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
257
257
// Void to _ then warn, because that is redundant.
258
258
if (auto DAE = dyn_cast<DiscardAssignmentExpr>(destExpr)) {
259
259
if (auto CE = dyn_cast<CallExpr>(AE->getSrc ())) {
260
- if (isa_and_nonnull<FuncDecl>(CE->getCalledValue ()) &&
260
+ if (getAsDecl<FuncDecl>(
261
+ CE->getCalledValue (/* skipFunctionConversions=*/ true )) &&
261
262
CE->getType ()->isVoid ()) {
262
263
Ctx.Diags
263
264
.diagnose (DAE->getLoc (),
@@ -311,7 +312,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
311
312
// FIXME: Duplicate labels on enum payloads should be diagnosed
312
313
// when declared, not when called.
313
314
if (auto *CE = dyn_cast_or_null<CallExpr>(E)) {
314
- auto calledValue = CE->getCalledValue ();
315
+ auto calledValue = CE->getCalledValue (/* skipFunctionConversions= */ true );
315
316
if (calledValue && isa<EnumElementDecl>(calledValue)) {
316
317
auto *args = CE->getArgs ();
317
318
SmallVector<Identifier, 4 > scratch;
@@ -1464,6 +1465,9 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
1464
1465
if (auto dotSyntax = dyn_cast<DotSyntaxCallExpr>(fnExpr))
1465
1466
fnExpr = dotSyntax->getSemanticFn ();
1466
1467
1468
+ if (auto *FCE = dyn_cast<FunctionConversionExpr>(fnExpr))
1469
+ fnExpr = FCE->getSubExpr ();
1470
+
1467
1471
auto DRE = dyn_cast<DeclRefExpr>(fnExpr);
1468
1472
if (!DRE || !DRE->getDecl ()->isOperator ())
1469
1473
return ;
@@ -5089,7 +5093,7 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
5089
5093
return declRef->getDecl ();
5090
5094
5091
5095
if (auto *apply = dyn_cast<ApplyExpr>(E)) {
5092
- auto *decl = apply->getCalledValue ();
5096
+ auto *decl = apply->getCalledValue (/* skipFunctionConversions= */ true );
5093
5097
if (isa_and_nonnull<AbstractFunctionDecl>(decl))
5094
5098
return decl;
5095
5099
}
@@ -5228,9 +5232,10 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
5228
5232
5229
5233
void diagnoseIfUnintendedInterpolation (CallExpr *segment,
5230
5234
UnintendedInterpolationKind kind) {
5231
- if (interpolationWouldBeUnintended (segment->getCalledValue (), kind))
5235
+ if (interpolationWouldBeUnintended (
5236
+ segment->getCalledValue (/* skipFunctionConversions=*/ true ), kind))
5232
5237
if (auto firstArg =
5233
- getFirstArgIfUnintendedInterpolation (segment->getArgs (), kind))
5238
+ getFirstArgIfUnintendedInterpolation (segment->getArgs (), kind))
5234
5239
diagnoseUnintendedInterpolation (firstArg, kind);
5235
5240
}
5236
5241
@@ -5441,7 +5446,7 @@ static void maybeDiagnoseCallToKeyValueObserveMethod(const Expr *E,
5441
5446
KVOObserveCallWalker (ASTContext &ctx) : C(ctx) {}
5442
5447
5443
5448
void maybeDiagnoseCallExpr (CallExpr *expr) {
5444
- auto fn = expr->getCalledValue ();
5449
+ auto fn = expr->getCalledValue (/* skipFunctionConversions= */ true );
5445
5450
if (!fn)
5446
5451
return ;
5447
5452
SmallVector<KeyPathExpr *, 1 > keyPathArgs;
@@ -5579,9 +5584,10 @@ static void diagnoseComparisonWithNaN(const Expr *E, const DeclContext *DC) {
5579
5584
// Dig out the function declaration.
5580
5585
if (auto Fn = BE->getFn ()) {
5581
5586
if (auto DSCE = dyn_cast<DotSyntaxCallExpr>(Fn)) {
5582
- comparisonDecl = DSCE->getCalledValue ();
5587
+ comparisonDecl =
5588
+ DSCE->getCalledValue (/* skipFunctionConversions=*/ true );
5583
5589
} else {
5584
- comparisonDecl = BE->getCalledValue ();
5590
+ comparisonDecl = BE->getCalledValue (/* skipFunctionConversions= */ true );
5585
5591
}
5586
5592
}
5587
5593
0 commit comments