# HG changeset patch # User Tomas Lindquist Olsen # Date 1228828050 -3600 # Node ID 331a176c1f4fd6f46a78040eb23593951210b5e8 # Parent 14c3319ac1bb3d9bc68195d98d65770a97d0476f 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. diff -r 14c3319ac1bb -r 331a176c1f4f gen/classes.cpp --- a/gen/classes.cpp Tue Dec 09 03:01:19 2008 +0100 +++ b/gen/classes.cpp Tue Dec 09 14:07:30 2008 +0100 @@ -1260,6 +1260,7 @@ { // sanity checks assert(fdecl->isVirtual()); + assert(!fdecl->isFinal()); assert(fdecl->vtblIndex > 0); // 0 is always ClassInfo/Interface* assert(inst->getType()->toBasetype()->ty == Tclass); diff -r 14c3319ac1bb -r 331a176c1f4f gen/functions.cpp --- a/gen/functions.cpp Tue Dec 09 03:01:19 2008 +0100 +++ b/gen/functions.cpp Tue Dec 09 14:07:30 2008 +0100 @@ -628,13 +628,6 @@ 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(); diff -r 14c3319ac1bb -r 331a176c1f4f gen/toir.cpp --- a/gen/toir.cpp Tue Dec 09 03:01:19 2008 +0100 +++ b/gen/toir.cpp Tue Dec 09 14:07:30 2008 +0100 @@ -1970,7 +1970,7 @@ 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"); diff -r 14c3319ac1bb -r 331a176c1f4f tests/mini/delegate3.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/delegate3.d Tue Dec 09 14:07:30 2008 +0100 @@ -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); +}