Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue 3836 - [TDPL] obligatory override attribute #462

Merged
merged 1 commit into from

3 participants

Daniel Murphy Andrei Alexandrescu Hara Kenji
Daniel Murphy
Collaborator

Move requiring the override attribute to the next stage, from warning to deprecated.

http://d.puremagic.com/issues/show_bug.cgi?id=3836

Daniel Murphy yebblies referenced this pull request
Merged

Deprecations #697

Daniel Murphy yebblies Fix Issue 3836 - [TDPL] obligatory override attribute
Move requiring the override attribute to the next stage, from warning to deprecated.
d6d3ed2
Andrei Alexandrescu
Owner

This is a must and we need to merge ASAP. Required override is proven and has been adopted by modern OOP languages. Even the older ones such as C++ and Java have adopted notation for it.

I won't actually commit this as I'm not familiar with assessing the quality of implementation, but someone on the core team please do the honors. Thanks!

Hara Kenji
Collaborator

LGTM so this is a simple change to an error from a warning.

Hara Kenji 9rnsr merged commit 2625839 into from
Hara Kenji
Collaborator

Merged.

Daniel Murphy
Collaborator

After 11 months! @andralex @9rnsr Thanks for getting things moving.

Brad Roberts braddr referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Daniel Murphy yebblies deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 21, 2012
  1. Daniel Murphy

    Fix Issue 3836 - [TDPL] obligatory override attribute

    yebblies authored
    Move requiring the override attribute to the next stage, from warning to deprecated.
This page is out of date. Refresh to see the latest.
4 src/func.c
View
@@ -484,8 +484,8 @@ void FuncDeclaration::semantic(Scope *sc)
doesoverride = TRUE;
#if DMDV2
- if (!isOverride())
- warning(loc, "overrides base class function %s, but is not marked with 'override'", fdv->toPrettyChars());
+ if (!isOverride() && !global.params.useDeprecated)
+ ::error(loc, "overriding base class function without using override attribute is deprecated (%s overrides %s)", toPrettyChars(), fdv->toPrettyChars());
#endif
FuncDeclaration *fdc = ((Dsymbol *)cd->vtbl.data[vi])->isFuncDeclaration();
9 test/compilable/deprecate2.d
View
@@ -16,3 +16,12 @@ float distance(point2 a, point2 b)
d[0] = b[0] - a[0]; // if I comment out this line it won't crash
return 0.0f;
}
+
+class A3836
+{
+ void fun() {}
+}
+class B3836 : A3836
+{
+ void fun() {}
+}
8 test/compilable/interpret3.d
View
@@ -3327,11 +3327,11 @@ class SomeClass : TheBase, SomeInterface
int fab;
int a = 17;
int b = 23;
- int foo() { return gab + a; }
- float bar(char c) { return 2.6; }
+ override int foo() { return gab + a; }
+ override float bar(char c) { return 2.6; }
int something() { return 0; }
- int daz() { return 0; }
- int baz() { return 0; }
+ override int daz() { return 0; }
+ override int baz() { return 0; }
}
class Unrelated : TheBase {
2  test/runnable/testcontracts.d
View
@@ -365,7 +365,7 @@ class P7699
}
class D7699 : P7699
{
- void f(int n) in { } body { }
+ override void f(int n) in { } body { }
}
/*******************************************/
2  test/runnable/traits.d
View
@@ -696,7 +696,7 @@ class EE
class FF : EE
{
- final int YYY() { return 4; }
+ final override int YYY() { return 4; }
}
static assert(__traits(isVirtualMethod, FF.YYY));
16 test/runnable/xtest46.d
View
@@ -3056,11 +3056,11 @@ void test3559()
static class B : A
{
- int foo(float a) { return 2; }
+ override int foo(float a) { return 2; }
alias A.foo foo;
alias A.bar bar;
- int bar(float a) { return 2; }
+ override int bar(float a) { return 2; }
}
{
@@ -3427,7 +3427,7 @@ void test5554()
interface I { MB foo(); }
class B : A
{
- MC foo() { return null; }
+ override MC foo() { return null; }
}
class C : B, I
{
@@ -4734,11 +4734,11 @@ class Base3282
}
class Derived3282 : Base3282
{
- string f()
+ override string f()
{
return "Derived.f()";
}
- string f() const
+ override string f() const
{
return "Derived.f() const";
}
@@ -4764,7 +4764,7 @@ class C7534
class D7534 : C7534
{
override int foo(){ return 2; }
- int foo() const { return 3; }
+ override int foo() const { return 3; }
// Error: D.foo multiple overrides of same function
}
void test7534()
@@ -4798,8 +4798,8 @@ class V7534
}
class W7534 : V7534
{
- Y7534 foo(){ return new Y7534(1); }
- Y7534 foo() const { return new Y7534(2); }
+ override Y7534 foo(){ return new Y7534(1); }
+ override Y7534 foo() const { return new Y7534(2); }
}
void test7534cov()
Something went wrong with that request. Please try again.