Destructors can be called on shared objects

This commit is contained in:
Atila Neves 2017-05-07 14:45:56 +02:00
parent 10c69f43d3
commit afb902a233
3 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View file

@ -13,6 +13,7 @@ src/dmd.exe
-.DS_Store
-trace.def
-trace.log
*.lst
# Visual Studio files
*.exe

View file

@ -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);
}

View file

@ -0,0 +1,21 @@
struct MaybeShared
{
this(this T)()
{
}
~this()
{
}
}
void main() {
{
auto aboutToDie = MaybeShared();
}
{
auto aboutToDie = shared MaybeShared();
}
}