@@ -257,7 +257,8 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
257257 // Void to _ then warn, because that is redundant.
258258 if (auto DAE = dyn_cast<DiscardAssignmentExpr>(destExpr)) {
259259 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 )) &&
261262 CE->getType ()->isVoid ()) {
262263 Ctx.Diags
263264 .diagnose (DAE->getLoc (),
@@ -311,7 +312,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
311312 // FIXME: Duplicate labels on enum payloads should be diagnosed
312313 // when declared, not when called.
313314 if (auto *CE = dyn_cast_or_null<CallExpr>(E)) {
314- auto calledValue = CE->getCalledValue ();
315+ auto calledValue = CE->getCalledValue (/* skipFunctionConversions= */ true );
315316 if (calledValue && isa<EnumElementDecl>(calledValue)) {
316317 auto *args = CE->getArgs ();
317318 SmallVector<Identifier, 4 > scratch;
@@ -1464,6 +1465,9 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
14641465 if (auto dotSyntax = dyn_cast<DotSyntaxCallExpr>(fnExpr))
14651466 fnExpr = dotSyntax->getSemanticFn ();
14661467
1468+ if (auto *FCE = dyn_cast<FunctionConversionExpr>(fnExpr))
1469+ fnExpr = FCE->getSubExpr ();
1470+
14671471 auto DRE = dyn_cast<DeclRefExpr>(fnExpr);
14681472 if (!DRE || !DRE->getDecl ()->isOperator ())
14691473 return ;
@@ -5089,7 +5093,7 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
50895093 return declRef->getDecl ();
50905094
50915095 if (auto *apply = dyn_cast<ApplyExpr>(E)) {
5092- auto *decl = apply->getCalledValue ();
5096+ auto *decl = apply->getCalledValue (/* skipFunctionConversions= */ true );
50935097 if (isa_and_nonnull<AbstractFunctionDecl>(decl))
50945098 return decl;
50955099 }
@@ -5228,9 +5232,10 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
52285232
52295233 void diagnoseIfUnintendedInterpolation (CallExpr *segment,
52305234 UnintendedInterpolationKind kind) {
5231- if (interpolationWouldBeUnintended (segment->getCalledValue (), kind))
5235+ if (interpolationWouldBeUnintended (
5236+ segment->getCalledValue (/* skipFunctionConversions=*/ true ), kind))
52325237 if (auto firstArg =
5233- getFirstArgIfUnintendedInterpolation (segment->getArgs (), kind))
5238+ getFirstArgIfUnintendedInterpolation (segment->getArgs (), kind))
52345239 diagnoseUnintendedInterpolation (firstArg, kind);
52355240 }
52365241
@@ -5441,7 +5446,7 @@ static void maybeDiagnoseCallToKeyValueObserveMethod(const Expr *E,
54415446 KVOObserveCallWalker (ASTContext &ctx) : C(ctx) {}
54425447
54435448 void maybeDiagnoseCallExpr (CallExpr *expr) {
5444- auto fn = expr->getCalledValue ();
5449+ auto fn = expr->getCalledValue (/* skipFunctionConversions= */ true );
54455450 if (!fn)
54465451 return ;
54475452 SmallVector<KeyPathExpr *, 1 > keyPathArgs;
@@ -5579,9 +5584,10 @@ static void diagnoseComparisonWithNaN(const Expr *E, const DeclContext *DC) {
55795584 // Dig out the function declaration.
55805585 if (auto Fn = BE->getFn ()) {
55815586 if (auto DSCE = dyn_cast<DotSyntaxCallExpr>(Fn)) {
5582- comparisonDecl = DSCE->getCalledValue ();
5587+ comparisonDecl =
5588+ DSCE->getCalledValue (/* skipFunctionConversions=*/ true );
55835589 } else {
5584- comparisonDecl = BE->getCalledValue ();
5590+ comparisonDecl = BE->getCalledValue (/* skipFunctionConversions= */ true );
55855591 }
55865592 }
55875593
0 commit comments