mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Destructors can be called on shared objects
This commit is contained in:
parent
10c69f43d3
commit
afb902a233
3 changed files with 27 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,6 +13,7 @@ src/dmd.exe
|
|||
-.DS_Store
|
||||
-trace.def
|
||||
-trace.log
|
||||
*.lst
|
||||
|
||||
# Visual Studio files
|
||||
*.exe
|
||||
|
|
|
@ -2192,6 +2192,11 @@ extern (C++) class VarDeclaration : Declaration
|
|||
*/
|
||||
e.type = e.type.mutableOf();
|
||||
|
||||
// Enable calling destructors on shared objects.
|
||||
// The destructor is always a single, non-overloaded function,
|
||||
// and must serve both shared and non-shared objects.
|
||||
e.type = e.type.unSharedOf;
|
||||
|
||||
e = new DotVarExp(loc, e, sd.dtor, false);
|
||||
e = new CallExp(loc, e);
|
||||
}
|
||||
|
|
21
test/compilable/shared_destructor.d
Normal file
21
test/compilable/shared_destructor.d
Normal file
|
@ -0,0 +1,21 @@
|
|||
struct MaybeShared
|
||||
{
|
||||
this(this T)()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~this()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
{
|
||||
auto aboutToDie = MaybeShared();
|
||||
}
|
||||
{
|
||||
auto aboutToDie = shared MaybeShared();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue