dmd.aliasthis
Implements the alias this symbol.
Specification: Alias This
License
Source: aliasthis.d
Documentation: https://dlang.org/phobos/dmd_aliasthis.html
-
Declaration
classAliasThis: dmd.dsymbol.Dsymbol;alias ident this;
-
Declaration
Dsymbolsym;The symbol this
alias thisresolves to -
Declaration
boolisDeprecated_;Whether this
alias thisis deprecated or not
-
-
Declaration
ExpressionresolveAliasThis(Scope*sc, Expressione, boolgag= false, boolfindOnly= false);Find the
alias thissymbol ofe's type.Parameters
Scope*sccontext
Expressioneexpression forming the
thisboolgagdo not print errors, return
nullinsteadboolfindOnlydon't do further processing like resolving properties, i.
e. just return plain dotExp() result.Return Value
Expression that is
e.aliasthis -
Declaration
boolcheckDeprecatedAliasThis(AliasThisat, const ref Locloc, Scope*sc);Check if an
alias thisis deprecatedDiscussion
Usually one would use
expression.checkDeprecated(scope, aliasthis)to check ifexpressionuses a deprecatedaliasthis, but this callstoPrettyCharswhich lead to the following message: "Deprecation: alias thisfullyqualified.aggregate.__anonymousis deprecated"Parameters
AliasThisatThe
AliasThisobject to checkLoclocLocof the expression triggering the access toatScope*scScopeof the expression (deprecations do not trigger in deprecated scopes)Return Value
Whether the alias this was reported as deprecated.
-
Declaration
boolisRecursiveAliasThis(ref Typeatt, Typet);Check and set '
att' if 't' is a recursive 'alias this' typeDiscussion
The goal is to prevent endless loops when there is a cycle in the alias this chain. Since there is no multiple
alias this, the chain either ends in a leaf, or it loops back on itself as some point.Example: S0 -> (S1 -> S2 -> S3 -> S1)
S0is not a recursive alias this, so this returnsfalse, and a rewrite toS1can be tried.S1is a recursive alias this type, but sinceis initialized toattnull, this still returnsfalse, butatt1is set toS1. A rewrite toS2andS3can be tried, but when we want to try a rewrite toS1again, we notice, so we're back at the start of the loop, and this returnsatt==ttrue.Parameters
Typeatttype reference used to detect recursion. Should be initialized to
null.Typettype of 'alias this' rewrite to attempt
Return Value
falseif the rewrite is safe,trueif it would loop back around