Add support for DMD 2.094 -preview=in switch

This will allow users to use -preview=in as soon as it's released.
This commit is contained in:
Geod24 2020-08-31 11:17:55 +09:00 committed by Mathias LANG
parent 258342163f
commit 9a685523f9
3 changed files with 27 additions and 6 deletions

View file

@ -717,7 +717,20 @@ struct DirectoryWatcher { // TODO: avoid all those heap allocations!
LocalManualEvent changeEvent;
shared(NativeEventDriver) driver;
void onChange(WatcherID, in ref FileChange change)
// Support for `-preview=in`
static if (!is(typeof(mixin(q{(in ref int a) => a}))))
{
void onChange(WatcherID id, in FileChange change) nothrow {
this.onChangeImpl(id, change);
}
} else {
mixin(q{
void onChange(WatcherID id, in ref FileChange change) nothrow {
this.onChangeImpl(id, change);
}});
}
void onChangeImpl(WatcherID, const scope ref FileChange change)
nothrow {
DirectoryChangeType ct;
final switch (change.kind) {

View file

@ -127,8 +127,15 @@ struct Task {
return app.data;
}
bool opEquals(in ref Task other) const @safe nothrow { return m_fiber is other.m_fiber && m_taskCounter == other.m_taskCounter; }
bool opEquals(in Task other) const @safe nothrow { return m_fiber is other.m_fiber && m_taskCounter == other.m_taskCounter; }
// Remove me when `-preview=in` becomes the default
static if (is(typeof(mixin(q{(in ref int a) => a}))))
mixin(q{
bool opEquals(in ref Task other) const @safe nothrow {
return m_fiber is other.m_fiber && m_taskCounter == other.m_taskCounter;
}});
bool opEquals(in Task other) const @safe nothrow {
return m_fiber is other.m_fiber && m_taskCounter == other.m_taskCounter;
}
}