D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3759 - Implementing two interfaces with same final function is accepted
Summary: Implementing two interfaces with same final function is accepted
Status: RESOLVED DUPLICATE of issue 4647
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2010-01-31 10:05 UTC by Ary Borenszweig
Modified: 2012-01-30 18:34 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ary Borenszweig 2010-01-31 10:05:31 UTC
import std.stdio;

interface One {

  final void foo() {
    writefln("One");
  }

}

interface Two {

  final void foo() {
    writefln("Two");
  }

}

class X : One, Two {
}

class Y : Two, One {
}

void main() {
  X x = new X();
  x.foo(); // prints "One"
  Y y = new Y();
  y.foo(); // prints "Two"
}
---

This might lead to bugs. I think this should be a compile-time error. I don't know how to solve this issue if you do want to implement both interfaces.
Comment 1 Mike Parker 2010-01-31 17:14:48 UTC
According to TDPL, the solution *should* be the following:

---
void main() {
  X x = new X();
  x.foo(); // prints "One"
  x.Two.foo(); // should print "Two"
  Y y = new Y();
  y.foo(); // prints "Two"
  y.One.foo(); // should print "One"
}
---

But this gives the following errors:

ifinal.d(28): Error: no property 'Two' for type 'ifinal.X'
Error: no property 'foo' for type 'int'
ifinal.d(28): Error: function expected before (), not __error of type int
ifinal.d(31): Error: no property 'One' for type 'ifinal.Y'
Error: no property 'foo' for type 'int'
ifinal.d(31): Error: function expected before (), not __error of type int
Comment 2 Brad Roberts 2011-02-06 15:39:07 UTC
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Comment 3 yebblies 2012-01-30 18:34:12 UTC

*** This issue has been marked as a duplicate of issue 4647 ***