mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-04 03:23:14 +01:00
Move check for access of context for nested class from backend into frontend.
This commit is contained in:
@@ -842,12 +842,6 @@ DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp)
|
||||
Logger::println("Resolving nested context");
|
||||
LOG_SCOPE;
|
||||
|
||||
if (gIR->func()->decl->isStatic())
|
||||
{
|
||||
newexp->error("function %s is static and cannot access nested class %s", gIR->func()->decl->toPrettyChars(), tc->sym->toPrettyChars());
|
||||
fatal();
|
||||
}
|
||||
|
||||
// get context
|
||||
LLValue* nest = DtoNestedContext(loc, tc->sym);
|
||||
|
||||
|
||||
@@ -390,11 +390,15 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym)
|
||||
LOG_SCOPE;
|
||||
|
||||
IrFunction* irfunc = gIR->func();
|
||||
|
||||
|
||||
// if this func has its own vars that are accessed by nested funcs
|
||||
// use its own context
|
||||
if (irfunc->nestedVar)
|
||||
return irfunc->nestedVar;
|
||||
// otherwise, it may have gotten a context from the caller
|
||||
else if (irfunc->nestArg)
|
||||
return irfunc->nestArg;
|
||||
// or just have a this argument
|
||||
else if (irfunc->thisArg)
|
||||
{
|
||||
ClassDeclaration* cd = irfunc->decl->isMember2()->isClassDeclaration();
|
||||
|
||||
Reference in New Issue
Block a user