From 869d9b561332ac0bf15a1c5db188d99aa8636ddb Mon Sep 17 00:00:00 2001 From: MoonlightSentinel Date: Mon, 27 Jan 2020 18:48:22 +0100 Subject: [PATCH] Fix Issue 20232 - WhiteHole is unusable with @safe interface functions --- std/typecons.d | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/std/typecons.d b/std/typecons.d index 8a6ca4e4112..b3304242dd0 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -4375,6 +4375,17 @@ alias BlackHole(Base) = AutoImplement!(Base, generateEmptyFunction, isAbstractFu BlackHole!Foo o; } +nothrow pure @safe unittest +{ + static interface I + { + void foo() nothrow pure @nogc @safe; + } + + auto cb = new BlackHole!I(); + cb.foo(); +} + /** `WhiteHole!Base` is a subclass of `Base` which automatically implements @@ -4408,10 +4419,25 @@ alias WhiteHole(Base) = AutoImplement!(Base, generateAssertTrap, isAbstractFunct assertThrown!NotImplementedError(c.notYetImplemented()); // throws an Error } +// https://issues.dlang.org/show_bug.cgi?id=20232 +nothrow pure @safe unittest +{ + static interface I + { + void foo() nothrow pure @safe; + } + + if (0) // Just checking attribute interference + { + auto cw = new WhiteHole!I(); + cw.foo(); + } +} + // / ditto class NotImplementedError : Error { - this(string method) + this(string method) nothrow pure @safe { super(method ~ " is not implemented"); }