Skip to content

Commit

Permalink
Merge pull request #7278 from WalterBright/fix17915
Browse files Browse the repository at this point in the history
fix Issue 17915 - [REG 2.073] core.exception.AssertError@ddmd/optimiz…
merged-on-behalf-of: Iain Buclaw <ibuclaw@gdcproject.org>
  • Loading branch information
dlang-bot committed Nov 3, 2017
2 parents 56e4861 + dd2fcfa commit 1fa67d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ddmd/optimize.d
Expand Up @@ -610,6 +610,8 @@ extern (C++) Expression Expression_optimize(Expression e, int result, bool keepL
// See if we can remove an unnecessary cast
ClassDeclaration cdfrom = e.e1.type.isClassHandle();
ClassDeclaration cdto = e.type.isClassHandle();
if (cdto == ClassDeclaration.object && !cdfrom.isInterfaceDeclaration())
goto L1; // can always convert a class to Object
// Need to determine correct offset before optimizing away the cast.
// https://issues.dlang.org/show_bug.cgi?id=16980
cdfrom.size(e.loc);
Expand Down
17 changes: 17 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -7942,6 +7942,22 @@ void test17349()
assert(i == 2);
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=17915

void test17915()
{
static class MyClass
{
S17915!MyClass m_member;
}
}

struct S17915(T)
{
T owner;
}

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

int main()
Expand Down Expand Up @@ -8262,6 +8278,7 @@ int main()
test16466();
test16408();
test17349();
test17915();

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

0 comments on commit 1fa67d0

Please sign in to comment.