[Mono-bugs] [Bug 68265][Blo] Changed - [GMCS]: Casting to a generic instance
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 13 Oct 2004 19:12:30 -0400 (EDT)
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 luca.barbieri@gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=68265
--- shadow/68265 2004-10-13 19:02:11.000000000 -0400
+++ shadow/68265.tmp.16232 2004-10-13 19:12:30.000000000 -0400
@@ -147,6 +147,123 @@
Very funny summary ;-)
------- Additional Comments From luca.barbieri@gmail.com 2004-10-13 19:02 -------
Are you sure that the problem is gmcs? The IL code it generates seems
correct.
+
+------- Additional Comments From luca.barbieri@gmail.com 2004-10-13 19:12 -------
+This code also FAILS:
+class MainClass
+{
+ class Base
+ {
+ }
+
+ class Gen<T> : Base
+ {
+ }
+
+ class Der : Gen<int>
+ {
+ }
+
+ static int Main(string[] args)
+ {
+ Base b = (Base)(object)new Der();
+ return 0;
+ }
+}
+
+And this too FAILS:
+class MainClass
+{
+ class Base
+ {
+ }
+
+ class Gen<T> : Base
+ {
+ }
+
+ class Der<T> : Gen<T>
+ {
+ }
+
+ static int Main(string[] args)
+ {
+ Gen<int> b = (Gen<int>)(object)new Der<int>();
+ return 0;
+ }
+}
+
+
+
+
+But this WORKS:
+class MainClass
+{
+ class Base
+ {
+ }
+
+ class Gen<T> : Base
+ {
+ }
+
+ class Der<T> : Gen<T>
+ {
+ }
+
+ static int Main(string[] args)
+ {
+ Base b = (Base)(object)new Der<int>();
+ return 0;
+ }
+}
+
+
+This also WORKS:
+class MainClass
+{
+ class Base
+ {
+ }
+
+ class Gen<T> : Base
+ {
+ }
+
+ class Der<T> : Gen<int>
+ {
+ }
+
+ static int Main(string[] args)
+ {
+ Base b = (Base)(object)new Der<int>();
+ return 0;
+ }
+}
+
+
+But very surprisingly this FAILS:
+class MainClass
+{
+ class Base
+ {
+ }
+
+ class Gen<T> : Base
+ {
+ }
+
+ class Der : Gen<int>
+ {
+ }
+
+ static int Main(string[] args)
+ {
+ Base b = (Base)(object)new Der();
+ return 0;
+ }
+}
+