Merge pull request #4727 from Cauterite/patch-1

fix Issue 16383 - 'Algebraic visit does not match const'
This commit is contained in:
Steven Schveighoffer 2016-08-19 08:49:29 -04:00 committed by GitHub
commit 0538d0ce15

View file

@ -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