Skip to content

Commit

Permalink
Merge pull request #1828 from 9rnsr/fix9858
Browse files Browse the repository at this point in the history
[REG2.063a] Issue 9858 - const alias this fails when opAssign is present
  • Loading branch information
AndrejMitrovic committed Apr 4, 2013
2 parents 8a2a368 + c6ebfc2 commit afd7c3d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/mtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ Type *Type::unSharedOf()
t->wto = NULL;
t->swto = NULL;
t->vtinfo = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
t = t->merge();

t->fixTo(this);
Expand Down Expand Up @@ -884,6 +886,8 @@ Type *Type::makeConst()
t->swto = NULL;
t->vtinfo = NULL;
t->ctype = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
//printf("-Type::makeConst() %p, %s\n", t, toChars());
return t;
}
Expand All @@ -908,6 +912,8 @@ Type *Type::makeInvariant()
t->swto = NULL;
t->vtinfo = NULL;
t->ctype = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
return t;
}

Expand All @@ -931,6 +937,8 @@ Type *Type::makeShared()
t->swto = NULL;
t->vtinfo = NULL;
t->ctype = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
return t;
}

Expand All @@ -954,6 +962,8 @@ Type *Type::makeSharedConst()
t->swto = NULL;
t->vtinfo = NULL;
t->ctype = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
return t;
}

Expand All @@ -977,6 +987,8 @@ Type *Type::makeWild()
t->swto = NULL;
t->vtinfo = NULL;
t->ctype = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
return t;
}

Expand All @@ -1000,6 +1012,8 @@ Type *Type::makeSharedWild()
t->swto = NULL;
t->vtinfo = NULL;
t->ctype = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
return t;
}

Expand All @@ -1021,6 +1035,8 @@ Type *Type::makeMutable()
t->swto = NULL;
t->vtinfo = NULL;
t->ctype = NULL;
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
return t;
}

Expand Down
19 changes: 19 additions & 0 deletions test/runnable/aliasthis.d
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,24 @@ struct S9177
}
pragma(msg, is(S9177 : int));

/***************************************************/
// 9858

struct S9858()
{
@property int get() const
{
return 42;
}
alias get this;
void opAssign(int) {}
}
void test9858()
{
const S9858!() s;
int i = s;
}

/***************************************************/

int main()
Expand Down Expand Up @@ -1161,6 +1179,7 @@ int main()
test7992();
test8169();
test9174();
test9858();

printf("Success\n");
return 0;
Expand Down

0 comments on commit afd7c3d

Please sign in to comment.