From f963694522905dd78ac9243d851e052537508735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 20 Mar 2018 17:28:21 +0100 Subject: [PATCH] Work around linker error for "dub test" in dependent projects. --- source/taggedalgebraic.d | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/source/taggedalgebraic.d b/source/taggedalgebraic.d index d30cc0e..e862e3d 100644 --- a/source/taggedalgebraic.d +++ b/source/taggedalgebraic.d @@ -464,29 +464,26 @@ unittest { static assert( is(typeof(ta.testI()))); } -version (unittest) { - // test recursive definition using a wrapper dummy struct - // (needed to avoid "no size yet for forward reference" errors) - template ID(What) { alias ID = What; } - private struct _test_Wrapper { - TaggedAlgebraic!_test_U u; +// test recursive definition using a wrapper dummy struct +// (needed to avoid "no size yet for forward reference" errors) +unittest { + static struct TA { + union U { + TA[] children; + int value; + } + TaggedAlgebraic!U u; alias u this; - this(ARGS...)(ARGS args) { u = TaggedAlgebraic!_test_U(args); } - } - private union _test_U { - _test_Wrapper[] children; - int value; - } - unittest { - alias TA = _test_Wrapper; - auto ta = TA(null); - ta ~= TA(0); - ta ~= TA(1); - ta ~= TA([TA(2)]); - assert(ta[0] == 0); - assert(ta[1] == 1); - assert(ta[2][0] == 2); + this(ARGS...)(ARGS args) { u = TaggedAlgebraic!U(args); } } + + auto ta = TA(null); + ta ~= TA(0); + ta ~= TA(1); + ta ~= TA([TA(2)]); + assert(ta[0] == 0); + assert(ta[1] == 1); + assert(ta[2][0] == 2); } unittest { // postblit/destructor test