mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-31 03:53:14 +01:00
Removed error on naked, not fully complete, but I'll be doing more work on it during this Christmas, and some things do work.
Fixed taking delegate of final class method. see mini/delegate3.d.
This commit is contained in:
@@ -1260,6 +1260,7 @@ LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl)
|
||||
{
|
||||
// sanity checks
|
||||
assert(fdecl->isVirtual());
|
||||
assert(!fdecl->isFinal());
|
||||
assert(fdecl->vtblIndex > 0); // 0 is always ClassInfo/Interface*
|
||||
assert(inst->getType()->toBasetype()->ty == Tclass);
|
||||
|
||||
|
||||
@@ -628,13 +628,6 @@ void DtoDefineFunc(FuncDeclaration* fd)
|
||||
Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
// error on naked
|
||||
if (fd->naked)
|
||||
{
|
||||
fd->error("naked is not supported");
|
||||
fatal();
|
||||
}
|
||||
|
||||
// debug info
|
||||
if (global.params.symdebug) {
|
||||
Module* mo = fd->getModule();
|
||||
|
||||
@@ -1970,7 +1970,7 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
Logger::println("func: '%s'", func->toPrettyChars());
|
||||
|
||||
LLValue* castfptr;
|
||||
if (func->isVirtual())
|
||||
if (func->isVirtual() && !func->isFinal())
|
||||
castfptr = DtoVirtualFunctionPointer(u, func);
|
||||
else if (func->isAbstract())
|
||||
assert(0 && "TODO delegate to abstract method");
|
||||
|
||||
18
tests/mini/delegate3.d
Normal file
18
tests/mini/delegate3.d
Normal file
@@ -0,0 +1,18 @@
|
||||
module bar;
|
||||
|
||||
class S
|
||||
{
|
||||
int i;
|
||||
final int foo()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
auto s = new S;
|
||||
s.i = 42;
|
||||
auto dg = &s.foo;
|
||||
assert(dg() == 42);
|
||||
}
|
||||
Reference in New Issue
Block a user