www.digitalmars.com         C & C++   DMDScript  
Archives

D Programming
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
D.gnu
D

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics


digitalmars.D.bugs - [Issue 3759] New: Implementing two interfaces with same final function is accepted

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3759

           Summary: Implementing two interfaces with same final function
                    is accepted
           Product: D
           Version: 2.040
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ary esperanto.org.ar


--- Comment #0 from Ary Borenszweig <ary esperanto.org.ar> 2010-01-31 10:05:31
PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3759


Mike Parker <aldacron gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldacron gmail.com


--- Comment #1 from Mike Parker <aldacron gmail.com> 2010-01-31 17:14:48 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2010