Skip to content

Commit

Permalink
Merge pull request #6351 from LemonBoy/b16278
Browse files Browse the repository at this point in the history
Fix issue #16278 - Do not emit TypeInfo for speculative instantiations.
  • Loading branch information
MartinNowak committed Jan 18, 2017
2 parents 3c0b769 + bdf0df9 commit d7101f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/dtemplate.d
Expand Up @@ -8342,8 +8342,7 @@ void unSpeculative(Scope* sc, RootObject o)
if (!s)
return;

Declaration d = s.isDeclaration();
if (d)
if (Declaration d = s.isDeclaration())
{
if (VarDeclaration vd = d.isVarDeclaration())
o = vd.type;
Expand Down
10 changes: 10 additions & 0 deletions src/typinf.d
Expand Up @@ -13,6 +13,7 @@ module ddmd.typinf;
import ddmd.declaration;
import ddmd.dmodule;
import ddmd.dscope;
import ddmd.dclass;
import ddmd.dstruct;
import ddmd.errors;
import ddmd.globals;
Expand Down Expand Up @@ -192,8 +193,17 @@ extern (C++) bool isSpeculativeType(Type t)

override void visit(TypeClass t)
{
ClassDeclaration sd = t.sym;
if (auto ti = sd.isInstantiated())
{
if (!ti.needsCodegen() && !ti.minst)
{
result |= true;
}
}
}


override void visit(TypeTuple t)
{
if (t.arguments)
Expand Down
6 changes: 6 additions & 0 deletions test/runnable/b16278.d
@@ -0,0 +1,6 @@
// REQUIRED_ARGS: -main
class A()
{
static struct S { A a; }
}
enum e = is(A!());

0 comments on commit d7101f3

Please sign in to comment.