diff --git a/std/variant.d b/std/variant.d index 1235895e8..b160a264a 100644 --- a/std/variant.d +++ b/std/variant.d @@ -2209,7 +2209,7 @@ private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant result.exceptionFuncIdx = dgidx; } } - else static if (is(Unqual!(Params[0]) == T)) + else static if (is(Params[0] == T) || is(Unqual!(Params[0]) == T)) { if (added) assert(false, "duplicate overload specified for type '" ~ T.stringof ~ "'"); @@ -2293,6 +2293,18 @@ unittest assert(depth(fb) == 3); } +unittest +{ + // https://issues.dlang.org/show_bug.cgi?id=16383 + class Foo {this() immutable {}} + alias V = Algebraic!(immutable Foo); + + auto x = V(new immutable Foo).visit!( + (immutable(Foo) _) => 3 + ); + assert(x == 3); +} + unittest { // http://d.puremagic.com/issues/show_bug.cgi?id=5310