From 206a4bf91e5a9ffb5061a2e3a4fc1d9b0c20204c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chaloupka?= Date: Sat, 2 Mar 2019 11:47:47 +0100 Subject: [PATCH] Fix #1941 - reall fix for the workaround --- data/vibe/data/serialization.d | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/data/vibe/data/serialization.d b/data/vibe/data/serialization.d index bee7075a02..4e91f89eee 100644 --- a/data/vibe/data/serialization.d +++ b/data/vibe/data/serialization.d @@ -1199,11 +1199,15 @@ private template isBuiltinTuple(T, string member) } // heuristically determines @safe'ty of the serializer by testing readValue and writeValue for type int -private enum isSafeSerializer(S) = __traits(compiles, (S s) @safe { +private template isSafeSerializer(S) +{ alias T = Traits!(int, DefaultPolicy); - s.writeValue!T(42); - s.readValue!(T, int)(); -}); + static if (__traits(hasMember, S, "writeValue")) + enum isSafeSerializer = __traits(compiles, (S s) @safe { s.writeValue!T(42); }); + else static if (__traits(hasMember, S, "readValue")) + enum isSafeSerializer = __traits(compiles, (S s) @safe { s.readValue!(T, int)(); }); + else static assert(0, "Serializer without writeValue or readValue is invalid"); +} private template hasAttribute(T, alias decl) { enum hasAttribute = findFirstUDA!(T, decl).found; }