diff --git a/src/dtemplate.d b/src/dtemplate.d index 144bf4ce66f4..31f6af1a1fda 100644 --- a/src/dtemplate.d +++ b/src/dtemplate.d @@ -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; diff --git a/src/typinf.d b/src/typinf.d index d08bc5cf26b8..4810ad8261a1 100644 --- a/src/typinf.d +++ b/src/typinf.d @@ -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; @@ -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) diff --git a/test/runnable/b16278.d b/test/runnable/b16278.d new file mode 100644 index 000000000000..a0a422daf6b6 --- /dev/null +++ b/test/runnable/b16278.d @@ -0,0 +1,6 @@ +// REQUIRED_ARGS: -main +class A() +{ + static struct S { A a; } +} +enum e = is(A!());