d: Merge dmd, druntime d8e3976a58, phobos 7a6e95688
[official-gcc.git] / gcc / d / dmd / aliasthis.d
blob0e063caa2fcde165181fa89a887b8060ae88b3a5
1 /**
2 * Implements the `alias this` symbol.
4 * Specification: $(LINK2 https://dlang.org/spec/class.html#alias-this, Alias This)
6 * Copyright: Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
7 * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
8 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
9 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/aliasthis.d, _aliasthis.d)
10 * Documentation: https://dlang.org/phobos/dmd_aliasthis.html
11 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/aliasthis.d
14 module dmd.aliasthis;
16 import core.stdc.stdio;
18 import dmd.dsymbol;
19 import dmd.identifier;
20 import dmd.location;
21 import dmd.visitor;
23 /***********************************************************
24 * alias ident this;
26 extern (C++) final class AliasThis : Dsymbol
28 Identifier ident;
29 /// The symbol this `alias this` resolves to
30 Dsymbol sym;
31 /// Whether this `alias this` is deprecated or not
32 bool isDeprecated_;
34 extern (D) this(const ref Loc loc, Identifier ident) @safe
36 super(loc, null); // it's anonymous (no identifier)
37 this.ident = ident;
40 override AliasThis syntaxCopy(Dsymbol s)
42 assert(!s);
43 auto at = new AliasThis(loc, ident);
44 at.comment = comment;
45 return at;
48 override const(char)* kind() const
50 return "alias this";
53 AliasThis isAliasThis()
55 return this;
58 override void accept(Visitor v)
60 v.visit(this);
63 override bool isDeprecated() const
65 return this.isDeprecated_;