@@ -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 ;
@@ -5093,7 +5097,7 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
5093
5097
return declRef->getDecl ();
5094
5098
5095
5099
if (auto *apply = dyn_cast<ApplyExpr>(E)) {
5096
- auto *decl = apply->getCalledValue ();
5100
+ auto *decl = apply->getCalledValue (/* skipFunctionConversions= */ true );
5097
5101
if (isa_and_nonnull<AbstractFunctionDecl>(decl))
5098
5102
return decl;
5099
5103
}
@@ -5232,9 +5236,10 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
5232
5236
5233
5237
void diagnoseIfUnintendedInterpolation (CallExpr *segment,
5234
5238
UnintendedInterpolationKind kind) {
5235
- if (interpolationWouldBeUnintended (segment->getCalledValue (), kind))
5239
+ if (interpolationWouldBeUnintended (
5240
+ segment->getCalledValue (/* skipFunctionConversions=*/ true ), kind))
5236
5241
if (auto firstArg =
5237
- getFirstArgIfUnintendedInterpolation (segment->getArgs (), kind))
5242
+ getFirstArgIfUnintendedInterpolation (segment->getArgs (), kind))
5238
5243
diagnoseUnintendedInterpolation (firstArg, kind);
5239
5244
}
5240
5245
@@ -5445,7 +5450,7 @@ static void maybeDiagnoseCallToKeyValueObserveMethod(const Expr *E,
5445
5450
KVOObserveCallWalker (ASTContext &ctx) : C(ctx) {}
5446
5451
5447
5452
void maybeDiagnoseCallExpr (CallExpr *expr) {
5448
- auto fn = expr->getCalledValue ();
5453
+ auto fn = expr->getCalledValue (/* skipFunctionConversions= */ true );
5449
5454
if (!fn)
5450
5455
return ;
5451
5456
SmallVector<KeyPathExpr *, 1 > keyPathArgs;
@@ -5583,9 +5588,10 @@ static void diagnoseComparisonWithNaN(const Expr *E, const DeclContext *DC) {
5583
5588
// Dig out the function declaration.
5584
5589
if (auto Fn = BE->getFn ()) {
5585
5590
if (auto DSCE = dyn_cast<DotSyntaxCallExpr>(Fn)) {
5586
- comparisonDecl = DSCE->getCalledValue ();
5591
+ comparisonDecl =
5592
+ DSCE->getCalledValue (/* skipFunctionConversions=*/ true );
5587
5593
} else {
5588
- comparisonDecl = BE->getCalledValue ();
5594
+ comparisonDecl = BE->getCalledValue (/* skipFunctionConversions= */ true );
5589
5595
}
5590
5596
}
5591
5597
0 commit comments