Skip to content

Commit

Permalink
merge D2 pull #974
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jun 12, 2012
1 parent f85d1d0 commit bfdf389
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
18 changes: 8 additions & 10 deletions src/class.c
Expand Up @@ -445,22 +445,20 @@ void ClassDeclaration::semantic(Scope *sc)
// If no base class, and this is not an Object, use Object as base class
if (!baseClass && ident != Id::Object)
{
// BUG: what if Object is redefined in an inner scope?
Type *tbase = new TypeIdentifier(0, Id::Object);
BaseClass *b;
TypeClass *tc;
Type *bt;

if (!object)
{
error("missing or corrupt object.d");
fatal();
}
bt = tbase->semantic(loc, sc)->toBasetype();
b = new BaseClass(bt, PROTpublic);

Type *t = object->type;
t = t->semantic(loc, sc)->toBasetype();
assert(t->ty == Tclass);
TypeClass *tc = (TypeClass *)t;

BaseClass *b = new BaseClass(tc, PROTpublic);
baseclasses->shift(b);
assert(b->type->ty == Tclass);
tc = (TypeClass *)(b->type);

baseClass = tc->sym;
assert(!baseClass->isInterfaceDeclaration());
b->base = baseClass;
Expand Down
11 changes: 9 additions & 2 deletions src/statement.c
Expand Up @@ -3648,9 +3648,16 @@ Statement *SynchronizedStatement::semantic(Scope *sc)
{ /* Cast the interface to an object, as the object has the monitor,
* not the interface.
*/
Type *t = new TypeIdentifier(0, Id::Object);
if (!ClassDeclaration::object)
{
error("missing or corrupt object.d");
fatal();
}

Type *t = ClassDeclaration::object->type;
t = t->semantic(0, sc)->toBasetype();
assert(t->ty == Tclass);

t = t->semantic(0, sc);
exp = new CastExp(loc, exp, t);
exp = exp->semantic(sc);
}
Expand Down

0 comments on commit bfdf389

Please sign in to comment.