[Mono-bugs] [Bug 77127][Nor] New - Interface re-implementations lost in inheritance

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Dec 29 20:52:22 EST 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by rodolfo.campero at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=77127

--- shadow/77127	2005-12-29 20:52:22.000000000 -0500
+++ shadow/77127.tmp.26448	2005-12-29 20:52:22.000000000 -0500
@@ -0,0 +1,124 @@
+Bug#: 77127
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: Debian Linux 2.6.12-1-k7
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: JIT
+AssignedTo: lupus at ximian.com                            
+ReportedBy: rodolfo.campero at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Interface re-implementations lost in inheritance
+
+Description of Problem:
+
+Interface re-implementations seems to get lost in the class inheritance chain.
+This might be related to bug #75903 -
+http://bugzilla.ximian.com/show_bug.cgi?id=75903
+
+Detail:
+
+You may find easier to just read the code... but I'll try to explain the
+situation anyway.
+
+Consider two interfaces IX and IY, where IY derives from IX.
+
+Given three classes: C derived from B, B derived from A, and A, each
+implementing its corresponding interface IA, IB and IC respectively.
+IA defines a property "Prop" whose type is IX, and IB redefines it to
+change its type to IY.
+
+When the interface property IA.Prop is implemented in a class A, then
+reimplemented in a class B, and finally accessed through a third class C,
+the implementation from class A is called instead of the one from class B.
+
+Steps to reproduce the problem:
+1. Compile the following program:
+
+using System;
+
+public interface IX {}
+public interface IY : IX {}
+
+public class X : IX {
+        public override string ToString() {
+                return "X";
+        }
+}
+
+public class Y : IY {
+        public override string ToString() {
+                return "Y";
+        }
+}
+
+public interface IA {
+        IX Prop { get; }
+}
+
+public interface IB : IA {
+        new IY Prop { get; }
+}
+
+public interface IC : IB {
+}
+
+public class A : IA {
+
+        IX IA.Prop {
+                get { return new X(); }
+        }
+}
+
+public class B : A, IA, IB {
+        IX IA.Prop {
+                get { return new Y(); }
+        }
+
+        IY IB.Prop {
+                get { return new Y(); }
+        }
+}
+
+public class C : B, IC {
+}
+
+class MainClass {
+        static void Main(string[] args) {
+                IC c = new C();
+                IX w = ((IA)c).Prop;
+                Console.WriteLine( w.ToString() );
+        }
+}
+
+2. Run the program.
+
+Actual Results:
+X
+
+Expected Results:
+Y
+
+How often does this happen? 
+Always.
+
+Additional Information:
+* If we create a B object instead of a C object, that is, replacing
+    IC c = new C();
+by
+    IB c = new B();
+the code produces "Y", the expected result.
+
+* Running mono from svn, revision 54908.
+$ mono --version
+Mono JIT compiler version 1.1.11, (C) 2002-2005 Novell, Inc and
+Contributors. www.mono-project.com
+        TLS:           normal
+        GC:            Included Boehm (with typed GC)
+        SIGSEGV      : normal


More information about the mono-bugs mailing list