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 [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=80518 --- shadow/80518 2007-01-14 10:25:49.000000000 -0500 +++ shadow/80518.tmp.19947 2007-01-14 10:25:49.000000000 -0500 @@ -0,0 +1,130 @@ +Bug#: 80518 +Product: Mono: Compilers +Version: 1.2 +OS: +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: GMCS doesn't use constraints from base classes + +Description of Problem: + + +Steps to reproduce the problem: + +First problem: + +try to compile: +// BEGIN OF CODE +using System; + +namespace test +{ + public class BaseClass + { + public BaseClass() + { + } + public string Hello { get { return "Hello"; } } + } + + public abstract class Printer + { + public abstract void Print<T>(T obj) where T: BaseClass; + } + + public class PrinterImpl : Printer + { + public override void Print<T>(T obj) + { + Console.WriteLine(obj.Hello); + } + } + + public class Starter + { + public static void Main( string[] args ) + { + BaseClass bc = new BaseClass(); + Printer p = new PrinterImpl(); + p.Print<BaseClass>(bc); + } + } +} +// END OF CODE + +It will lead to exception: +test.cs(22,28): error CS0117: `T' does not contain a definition for `Hello' +Compilation failed: 1 error(s), 0 warnings + +Second problem: + +try to compile: +// BEGIN OF CODE +using System; + +namespace test +{ + public class BaseClass + { + public BaseClass() + { + } + public string Hello { get { return "Hello"; } } + } + + public abstract class Printer + { + public abstract void Print<T>(object x) where T: BaseClass; + } + + public class PrinterImpl: Printer + { + public override void Print<T>(object x) + { + Console.WriteLine((x as T).Hello); + } + } + + public class Starter + { + public static void Main( string[] args ) + { + BaseClass bc = new BaseClass(); + Printer p = new PrinterImpl(); + p.Print<BaseClass>(bc); + } + } +} +// END OF CODE +It raises the following exception: +test2.cs(22,27): error CS0413: The as operator requires that the `T' type +parameter be constrained by a class +Compilation failed: 1 error(s), 0 warnings + +Actual Results: +It doesn't compile under mono 1.2.2.1. + +Expected Results: +It should compile. At least it compiles under csc 2.0. + +How often does this happen? +always + +Additional Information: + +I found two occurances of this problem. More may exists. +I try to figure out the problem and think that it is in the way generic.cs +works with GenericConstraints (gc) and Constraints(constraints) in +TypeParameter class. + +(sorry for bad English) _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
