From 4f6eeaf1bc62bd879643cc58c95c8271d2138021 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 27 Feb 2017 00:36:29 +0100 Subject: [PATCH] documents the limitation of attributes on overridden functions --- spec/function.dd | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/function.dd b/spec/function.dd index 3ac33849a6..b3cb214571 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -921,6 +921,31 @@ void main() } ------ + $(P It's not allowed to mark an overridden method with the attributes + $(LINK2 attribute.html#disable, $(D @disable)) or + $(LINK2 attribute.html#deprecated, $(D deprecated)). + To stop the compilation or to output the deprecation message, the compiler + must be able to determine the target of the call, which can't be guaranteed + when it is virtual. + ) + +------ +class B +{ + void foo() {} +} + +class D : B +{ + @disable override void foo() {} +} + +void main() +{ + B b = new D; + b.foo(); // would compiles and then the most derived would be called even if disabled. +} +------ $(H4 $(LNAME2 inline-functions, Inline Functions))