mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 13:40:11 +03:00
remove some dyncast calls (#15488)
This commit is contained in:
parent
a4e9bf514a
commit
04f46ff87d
7 changed files with 15 additions and 15 deletions
|
@ -626,7 +626,7 @@ extern (C++) final class TupleDeclaration : Declaration
|
|||
for (size_t i = 0; i < objects.length; i++)
|
||||
{
|
||||
RootObject o = (*objects)[i];
|
||||
if (o.dyncast() != DYNCAST.type)
|
||||
if (!o.isType())
|
||||
{
|
||||
//printf("\tnot[%d], %p, %d\n", i, o, o.dyncast());
|
||||
return null;
|
||||
|
|
|
@ -7706,7 +7706,7 @@ private void removeHookTraceImpl(ref CallExp ce, ref FuncDeclaration fd)
|
|||
// Get the Hook from the second template parameter
|
||||
TemplateInstance templateInstance = fd.parent.isTemplateInstance;
|
||||
RootObject hook = (*templateInstance.tiargs)[1];
|
||||
assert(hook.dyncast() == DYNCAST.dsymbol, "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
|
||||
assert(hook.isDsymbol(), "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
|
||||
fd = (cast(Dsymbol)hook).isFuncDeclaration;
|
||||
|
||||
// Remove the first three trace parameters
|
||||
|
|
|
@ -353,9 +353,9 @@ extern (C++) class Dsymbol : ASTNode
|
|||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o.dyncast() != DYNCAST.dsymbol)
|
||||
const s = o.isDsymbol();
|
||||
if (!s)
|
||||
return false;
|
||||
auto s = cast(Dsymbol)o;
|
||||
// Overload sets don't have an ident
|
||||
// Function-local declarations may have identical names
|
||||
// if they are declared in different scopes
|
||||
|
|
|
@ -4708,9 +4708,9 @@ void errorSupplementalInferredAttr(FuncDeclaration fd, int maxDepth, bool deprec
|
|||
s.arg0 ? s.arg0.toChars() : "", s.arg1 ? s.arg1.toChars() : "", s.arg2 ? s.arg2.toChars() : "");
|
||||
}
|
||||
}
|
||||
else if (s.arg0.dyncast() == DYNCAST.dsymbol)
|
||||
else if (auto sa = s.arg0.isDsymbol())
|
||||
{
|
||||
if (FuncDeclaration fd2 = (cast(Dsymbol) s.arg0).isFuncDeclaration())
|
||||
if (FuncDeclaration fd2 = sa.isFuncDeclaration())
|
||||
{
|
||||
if (maxDepth > 0)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ import dmd.aggregate;
|
|||
import dmd.astenums;
|
||||
import dmd.declaration;
|
||||
import dmd.dscope;
|
||||
import dmd.dtemplate : isDsymbol;
|
||||
import dmd.errors;
|
||||
import dmd.expression;
|
||||
import dmd.func;
|
||||
|
@ -263,6 +264,7 @@ private FuncDeclaration stripHookTraceImpl(FuncDeclaration fd)
|
|||
// Get the Hook from the second template parameter
|
||||
auto templateInstance = fd.parent.isTemplateInstance;
|
||||
RootObject hook = (*templateInstance.tiargs)[1];
|
||||
assert(hook.dyncast() == DYNCAST.dsymbol, "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
|
||||
return (cast(Dsymbol)hook).isFuncDeclaration;
|
||||
Dsymbol s = hook.isDsymbol();
|
||||
assert(s, "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
|
||||
return s.isFuncDeclaration;
|
||||
}
|
||||
|
|
|
@ -530,13 +530,11 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
|
|||
}
|
||||
|
||||
RootObject o = (*tup.objects)[cast(size_t)d];
|
||||
if (o.dyncast() != DYNCAST.type)
|
||||
{
|
||||
if (auto tt = o.isType())
|
||||
return tt.addMod(mtype.mod);
|
||||
.error(loc, "`%s` is not a type", mtype.toChars());
|
||||
return error();
|
||||
}
|
||||
return (cast(Type)o).addMod(mtype.mod);
|
||||
}
|
||||
|
||||
if (t && t.ty == Terror)
|
||||
return error();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue