mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
By reverting #10718 - it seems superfluous nowadays?
This commit is contained in:
parent
dbe0ddbde6
commit
ed17b3e95d
4 changed files with 96 additions and 8 deletions
77
compiler/test/compilable/imports/test21098_phobos.d
Normal file
77
compiler/test/compilable/imports/test21098_phobos.d
Normal file
|
@ -0,0 +1,77 @@
|
|||
struct Nullable(T)
|
||||
{
|
||||
static struct DontCallDestructorT
|
||||
{
|
||||
T payload;
|
||||
}
|
||||
|
||||
DontCallDestructorT _value;
|
||||
|
||||
string toString() const
|
||||
{
|
||||
Appender!string app;
|
||||
formatValueImpl(app, _value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct Appender(A)
|
||||
{
|
||||
InPlaceAppender!A impl;
|
||||
}
|
||||
|
||||
struct InPlaceAppender(T)
|
||||
{
|
||||
static void toStringImpl(const T[] data)
|
||||
{
|
||||
string app;
|
||||
formatValue(app, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void formatValueImpl(Writer, T)(Writer, const(T)) {}
|
||||
|
||||
void formatValueImpl(Writer, T)(Writer w, T obj)
|
||||
if (is(T == U[], U))
|
||||
{
|
||||
formatValue(w, obj[0]);
|
||||
}
|
||||
|
||||
enum HasToStringResult
|
||||
{
|
||||
none,
|
||||
bla
|
||||
}
|
||||
|
||||
template hasToString(T)
|
||||
{
|
||||
static if (is(typeof(
|
||||
(T val) {
|
||||
val.toString(s);
|
||||
})))
|
||||
enum hasToString = HasToStringResult.bla;
|
||||
else
|
||||
enum hasToString = HasToStringResult.none;
|
||||
}
|
||||
|
||||
void formatValueImpl(Writer, T)(ref Writer w, T val)
|
||||
if (is(T == struct) || is(T == union))
|
||||
{
|
||||
static if (hasToString!T)
|
||||
int dummy;
|
||||
formatElement(w, val.tupleof);
|
||||
}
|
||||
|
||||
void formatElement(Writer, T)(Writer w, T val)
|
||||
{
|
||||
formatValueImpl(w, val);
|
||||
}
|
||||
|
||||
void formatValue(Writer, T)(Writer w, T val)
|
||||
{
|
||||
formatValueImpl(w, val);
|
||||
}
|
12
compiler/test/compilable/imports/test21098b.d
Normal file
12
compiler/test/compilable/imports/test21098b.d
Normal file
|
@ -0,0 +1,12 @@
|
|||
import imports.test21098_phobos : Appender, Nullable;
|
||||
|
||||
struct Type {
|
||||
Nullable!(Type[]) templateArgs;
|
||||
}
|
||||
|
||||
Type[] parseDeclarations() {
|
||||
Appender!(Type[]) members;
|
||||
return null;
|
||||
}
|
||||
|
||||
enum ast = parseDeclarations();
|
4
compiler/test/compilable/test21098.d
Normal file
4
compiler/test/compilable/test21098.d
Normal file
|
@ -0,0 +1,4 @@
|
|||
// https://github.com/dlang/dmd/issues/21098
|
||||
|
||||
// EXTRA_FILES: imports/test21098b.d imports/test21098_phobos.d
|
||||
import imports.test21098b;
|
Loading…
Add table
Add a link
Reference in a new issue