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=79525 --- shadow/79525 2006-09-29 08:39:09.000000000 -0400 +++ shadow/79525.tmp.7674 2006-09-29 08:39:09.000000000 -0400 @@ -0,0 +1,84 @@ +Bug#: 79525 +Product: Mono: Compilers +Version: 1.1 +OS: All +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Major +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: cast to generic valuetypes fails at runtime + +Please fill in this template when reporting a bug, unless you know what you +are doing. +Description of Problem: + +Mono refuses to run cast code generated from gmcs. + +Steps to reproduce the problem: +1. Compile this program with : "gmcs program.cs" + +interface Interface1<T>{ +} + +class Generic1<T>{ + + class Nested:Interface1<T>{ + public void salute() + { + System.Console.WriteLine("Hello world"); + } + } + + public Interface1<T> getAnInstance() + { + return new Nested(); + } + + public void test( Interface1<T> gi) + { + Nested n = (Nested) gi; + n.salute(); + } + +} + +class App { + public static void Main() + { + Generic1<int> g1 = new Generic1<int>(); + Interface1<int> gi = g1.getAnInstance(); + g1.test(gi); + } +} + +2. Execute with mono program.exe + + +Actual Results: + +System.InvalidProgram... +Illegal IL code ....stloc.0 + +Expected Results: + +"Hello world" + +How often does this happen? + +Always + +Additional Information: + +The compiler generates a castclass instead of an unboxing cast in the test +method, and in fact, it's not a compiler problem, but a bug deep in the +mono internals that makes Type.IsClass to return true for a generic value +type during the type construction. Type.IsClass works right, however, if +the test is done inside the target program. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
