From a52958ef018e9d2a503be868e0dcf828c78b02bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 23 Feb 2019 15:56:59 +0100 Subject: [PATCH] Work around ReplaceType compile error issue. ReplaceType doesn't work for "class C : D!C {}" --- source/taggedalgebraic/taggedunion.d | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/taggedalgebraic/taggedunion.d b/source/taggedalgebraic/taggedunion.d index 335bab0..40b37ba 100644 --- a/source/taggedalgebraic/taggedunion.d +++ b/source/taggedalgebraic/taggedunion.d @@ -603,7 +603,12 @@ template TypeOf(alias kind) else alias FT = uda[0]; } - alias TypeOf = ReplaceType!(This, U, FT); + // NOTE: ReplaceType has issues with certain types, such as a class + // declaration like this: class C : D!C {} + // For this reason, we test first if it compiles and only then use it. + static if (is(ReplaceType!(This, U, FT))) + alias TypeOf = ReplaceType!(This, U, FT); + else alias TypeOf = FT; } ///