Skip to content

Commit

Permalink
Fix #4790: Make sure TypeInfo_Class.base is always a `TypeInfo_Clas…
Browse files Browse the repository at this point in the history
…s` ref (#4796)

I.e., ignore all modifiers of the base class.
  • Loading branch information
kinke authored Dec 7, 2024
1 parent 1df61f1 commit f241166
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ir/irclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "dmd/target.h"
#include "gen/abi/abi.h"
#include "gen/arrays.h"
#include "gen/classes.h"
#include "gen/funcgenstate.h"
#include "gen/functions.h"
#include "gen/irstate.h"
Expand Down Expand Up @@ -389,7 +390,8 @@ LLConstant *IrClass::getClassInfoInit() {
// TypeInfo_Class base
assert(!isInterface || !cd->baseClass);
if (cd->baseClass) {
b.push_typeinfo(cd->baseClass->type);
DtoResolveClass(cd->baseClass);
b.push(getIrAggr(cd->baseClass)->getClassInfoSymbol());
} else {
b.push_null(cinfoType);
}
Expand Down
12 changes: 12 additions & 0 deletions tests/codegen/gh4790.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %ldc -run %s

shared class A {
}

shared class B : A {
}

void main() {
shared A a1 = cast(shared A) A.classinfo.create();
shared A a2 = cast(shared A) B.classinfo.create();
}

0 comments on commit f241166

Please sign in to comment.