From 9f349dff74fcfc5154e2f77b5254bf87dbdb3240 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 19 Jan 2013 20:13:27 -0800 Subject: [PATCH] fix Issue 3404 - JSON output should retain original alias names --- src/json.c | 3 +++ test/compilable/extra-files/json.out | 15 +++++++++++++++ test/compilable/json.d | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/src/json.c b/src/json.c index fc4ca016a6b0..f1c7254309be 100644 --- a/src/json.c +++ b/src/json.c @@ -267,6 +267,9 @@ void Declaration::toJsonBuffer(OutBuffer *buf) if (type) JsonProperty(buf, Ptype, type->toChars()); + if (originalType && type != originalType) + JsonProperty(buf, "originalType", originalType->toChars()); + if (comment) JsonProperty(buf, Pcomment, (const char *)comment); diff --git a/test/compilable/extra-files/json.out b/test/compilable/extra-files/json.out index 3753ab98156d..a79477409bb3 100644 --- a/test/compilable/extra-files/json.out +++ b/test/compilable/extra-files/json.out @@ -13,6 +13,21 @@ "kind" : "enum", "protection" : "public", "line" : 7} +, +{ +"name" : "myInt", +"kind" : "alias", +"protection" : "public", +"type" : "int", +"line" : 10} +, +{ +"name" : "x", +"kind" : "variable", +"protection" : "public", +"type" : "int", +"originalType" : "myInt", +"line" : 11} ] } ] diff --git a/test/compilable/json.d b/test/compilable/json.d index 8d502f2e91ff..cb30afa761d3 100644 --- a/test/compilable/json.d +++ b/test/compilable/json.d @@ -5,3 +5,7 @@ struct X; enum Y; + +// 3404 +alias int myInt; +myInt x;