@@ -445,49 +445,46 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
445445 return new IntegerExp(e.loc, false , Type.tbool);
446446 }
447447
448- /**
449- Gets the function type from a given AST node
450- if the node is a function of some sort.
451-
452- Params:
453- o = an AST node to check for a `TypeFunction`
454- fdp = optional pointer to a function declararion, to be set
455- if `o` is a function declarartion.
456-
457- Returns:
458- a type node if `o` is a declaration of
459- a delegate, function, function-pointer
460- or a variable of the former. Otherwise, `null`.
461- */
462- static TypeFunction toTypeFunction (RootObject o, FuncDeclaration* fdp = null )
448+ /* *******
449+ * Gets the function type from a given AST node
450+ * if the node is a function of some sort.
451+ * Params:
452+ * o = an AST node to check for a `TypeFunction`
453+ * fdp = if `o` is a FuncDeclaration then fdp is set to that, otherwise `null`
454+ * Returns:
455+ * a type node if `o` is a declaration of
456+ * a delegate, function, function-pointer or a variable of the former.
457+ * Otherwise, `null`.
458+ */
459+ static TypeFunction toTypeFunction (RootObject o, out FuncDeclaration fdp)
463460 {
464- auto s = getDsymbolWithoutExpCtx(o);
465- auto t = isType(o);
466- TypeFunction tf = null ;
467-
468- if (s)
461+ Type t;
462+ if (auto s = getDsymbolWithoutExpCtx(o))
469463 {
470- auto fd = s.isFuncDeclaration();
471- if (fd)
464+ if (auto fd = s.isFuncDeclaration())
472465 {
473466 t = fd.type;
474- if (fdp)
475- * fdp = fd;
467+ fdp = fd;
476468 }
477469 else if (auto vd = s.isVarDeclaration())
478470 t = vd.type;
471+ else
472+ t = isType(o);
479473 }
474+ else
475+ t = isType(o);
476+
480477 if (t)
481478 {
482479 if (t.ty == Type.Kind.function_)
483- tf = cast (TypeFunction)t;
480+ return cast (TypeFunction)t;
484481 else if (t.ty == Type.Kind.delegate_)
485- tf = cast (TypeFunction)t.nextOf();
482+ return cast (TypeFunction)t.nextOf();
486483 else if (t.ty == Type.Kind.pointer && t.nextOf().ty == Type.Kind.function_)
487- tf = cast (TypeFunction)t.nextOf();
484+ return cast (TypeFunction)t.nextOf();
488485 }
489486
490- return tf ;
487+ return null ;
491488 }
492489
493490 IntegerExp isX (T)(bool function (T) fp)
@@ -1036,7 +1033,8 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
10361033 if (dim != 1 )
10371034 return dimError (1 );
10381035
1039- TypeFunction tf = toTypeFunction((* e.args)[0 ]);
1036+ FuncDeclaration fd;
1037+ TypeFunction tf = toTypeFunction((* e.args)[0 ], fd);
10401038
10411039 if (! tf)
10421040 {
@@ -1070,7 +1068,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
10701068 auto o = (* e.args)[0 ];
10711069
10721070 FuncDeclaration fd;
1073- TypeFunction tf = toTypeFunction(o, & fd);
1071+ TypeFunction tf = toTypeFunction(o, fd);
10741072
10751073 if (tf)
10761074 {
@@ -1113,7 +1111,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
11131111 auto o1 = (* e.args)[1 ];
11141112
11151113 FuncDeclaration fd;
1116- TypeFunction tf = toTypeFunction(o, & fd);
1114+ TypeFunction tf = toTypeFunction(o, fd);
11171115
11181116 Parameters* fparams;
11191117 if (tf)
@@ -1203,7 +1201,8 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
12031201 LINK link;
12041202 auto o = (* e.args)[0 ];
12051203
1206- TypeFunction tf = toTypeFunction(o);
1204+ FuncDeclaration fd;
1205+ TypeFunction tf = toTypeFunction(o, fd);
12071206
12081207 if (tf)
12091208 link = tf.linkage;
0 commit comments