[Mono-bugs] [Bug 76762][Nor] Changed - [GMCS] CS0508 not reported for generic property override causing looped unification

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Dec 17 10:18:07 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 nazgul at omega.pl.

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

--- shadow/76762	2005-12-17 03:12:49.000000000 -0500
+++ shadow/76762.tmp.12077	2005-12-17 10:18:07.000000000 -0500
@@ -57,6 +57,57 @@
 (c) A<T>.B.getT() has return type A<T>.B (from the text)
 
 So, they should unify fine?
 
 IIUC, you disagree with (a').  Also, IIUC, the CSC error message is
 saying (c) doesn't hold.
+
+------- Additional Comments From nazgul at omega.pl  2005-12-17 10:18 -------
+I did a more detailed analysis playing with csc and now I know the
+problem. It is illustrated with following snippet of code:
+
+class A<T>
+{
+   public class B : A<B>
+   {
+       public void getTT()
+       {
+           System.Console.WriteLine(typeof (B));
+           System.Console.WriteLine(this.GetType());
+       }
+   }
+}
+
+class M { 
+	static void Main () { 
+		A<int>.B b = new A<int>.B();
+		b.getTT();
+		System.Console.WriteLine (b.GetType());
+	}
+}
+
+
+The core of the problem is how C# resolves visibility of types. In
+above example B means different things depending on context:
+- in class declaration signature class B : A <B> { }  both B's refere
+to the current type B (that is A<T>.B)
+- inside the class B no longer referes to current type, but to type
+derived from base type (that is A<A<T>.B>.B)
+
+So my original example expands to
+
+abstract class A<T>
+{
+   public abstract T getT();
+
+}
+
+ class A<T>.B : A<A<T>.B>
+ {
+       public override A<A<T>.B>.B getT()
+       {
+           throw new System.Exception("The method or operation is not
+implemented.");
+       }
+ }
+
+Which we can now easily see why is rejected.


More information about the mono-bugs mailing list