Skip to content

Commit

Permalink
Merge pull request #1768 from AndrejMitrovic/Fix9755
Browse files Browse the repository at this point in the history
Issue 9755 - Json template protection attribute output is wrong.
  • Loading branch information
WalterBright committed Mar 20, 2013
2 parents 9a5a9e3 + 214b0fd commit d9b6839
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/template.c
Expand Up @@ -422,6 +422,7 @@ TemplateDeclaration::TemplateDeclaration(Loc loc, Identifier *id,
this->literal = 0;
this->ismixin = ismixin;
this->previous = NULL;
this->protection = PROTundefined;

// Compute in advance for Ddoc's use
if (members)
Expand Down Expand Up @@ -2478,6 +2479,11 @@ char *TemplateDeclaration::toChars()
return (char *)buf.extractData();
}

enum PROT TemplateDeclaration::prot()
{
return protection;
}

/* ======================== Type ============================================ */

/****
Expand Down
1 change: 1 addition & 0 deletions src/template.h
Expand Up @@ -88,6 +88,7 @@ struct TemplateDeclaration : ScopeDsymbol
void emitComment(Scope *sc);
void toJson(JsonOut *json);
virtual void jsonProperties(JsonOut *json);
enum PROT prot();
// void toDocBuffer(OutBuffer *buf);

MATCH matchWithInstance(TemplateInstance *ti, Objects *atypes, Expressions *fargs, int flag);
Expand Down
67 changes: 67 additions & 0 deletions test/compilable/extra-files/json.out
Expand Up @@ -376,6 +376,73 @@
]
}
]
},
{
"kind" : "template",
"protection" : "private",
"line" : 89,
"name" : "S1_9755",
"parameters" : [
{
"name" : "T",
"kind" : "type"
}
],
"members" : [
{
"name" : "S1_9755",
"kind" : "struct",
"line" : 89,
"members" : []
}
]
},
{
"kind" : "template",
"protection" : "package",
"line" : 90,
"name" : "S2_9755",
"parameters" : [
{
"name" : "T",
"kind" : "type"
}
],
"members" : [
{
"name" : "S2_9755",
"kind" : "struct",
"line" : 90,
"members" : []
}
]
},
{
"name" : "C_9755",
"kind" : "class",
"line" : 93,
"members" : [
{
"kind" : "template",
"protection" : "protected",
"line" : 94,
"name" : "CI_9755",
"parameters" : [
{
"name" : "T",
"kind" : "type"
}
],
"members" : [
{
"name" : "CI_9755",
"kind" : "class",
"line" : 94,
"members" : []
}
]
}
]
}
]
}
Expand Down
9 changes: 9 additions & 0 deletions test/compilable/json.d
Expand Up @@ -84,3 +84,12 @@ struct S
/** Issue 9480 - Template name should be stripped of parameters */
this(T)(T t) { }
}

/** Issue 9755 - Protection not emitted properly for Templates. */
private struct S1_9755(T) { }
package struct S2_9755(T) { }

class C_9755
{
protected static class CI_9755(T) { }
}

0 comments on commit d9b6839

Please sign in to comment.