@@ -302,10 +302,8 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
302302
303303 case ExprKind::Call: {
304304 auto callExpr = cast<CallExpr>(expr);
305- auto functionKind = callExpr->getFn ()->getKind ();
306305
307- if (functionKind == ExprKind::DeclRef) {
308- auto declRefExpr = cast<DeclRefExpr>(callExpr->getFn ());
306+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(callExpr->getFn ())) {
309307 auto identifier =
310308 declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
311309
@@ -314,17 +312,15 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
314312 return std::make_shared<FunctionCallValue>(identifier, parameters);
315313 }
316314
317- if (functionKind == ExprKind::ConstructorRefCall ) {
315+ if (auto constructorRefCall = dyn_cast<ConstructorRefCallExpr>(callExpr-> getFn ()) ) {
318316 std::vector<FunctionParameter> parameters =
319317 extractFunctionArguments (callExpr->getArgs (), declContext);
320318 return std::make_shared<InitCallValue>(callExpr->getType (), parameters);
321319 }
322320
323- if (functionKind == ExprKind::DotSyntaxCall) {
324- auto dotSyntaxCallExpr = cast<DotSyntaxCallExpr>(callExpr->getFn ());
321+ if (auto dotSyntaxCallExpr = dyn_cast<DotSyntaxCallExpr>(callExpr->getFn ())) {
325322 auto fn = dotSyntaxCallExpr->getFn ();
326- if (fn->getKind () == ExprKind::DeclRef) {
327- auto declRefExpr = cast<DeclRefExpr>(fn);
323+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(fn)) {
328324 auto baseIdentifierName =
329325 declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
330326
@@ -355,10 +351,8 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
355351 }
356352 }
357353
358- if (functionKind == ExprKind::FunctionConversion) {
359- auto functionConversionExpr = cast<FunctionConversionExpr>(callExpr->getFn ());
360- if (functionConversionExpr->getSubExpr ()->getKind () == ExprKind::DeclRef) {
361- auto declRefExpr = cast<DeclRefExpr>(functionConversionExpr->getSubExpr ());
354+ if (auto functionConversionExpr = dyn_cast<FunctionConversionExpr>(callExpr->getFn ())) {
355+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(functionConversionExpr->getSubExpr ())) {
362356 auto identifier =
363357 declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
364358
@@ -374,8 +368,7 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
374368 case ExprKind::DotSyntaxCall: {
375369 auto dotSyntaxCallExpr = cast<DotSyntaxCallExpr>(expr);
376370 auto fn = dotSyntaxCallExpr->getFn ();
377- if (fn->getKind () == ExprKind::DeclRef) {
378- auto declRefExpr = cast<DeclRefExpr>(fn);
371+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(fn)) {
379372 auto caseName =
380373 declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
381374 return std::make_shared<EnumValue>(caseName, std::nullopt );
0 commit comments