[Mono-bugs] [Bug 32269][Nor] Changed - Cast from enum variable to System.Enum gives null
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
15 Oct 2002 00:29:04 -0000
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 hwang_rob@yahoo.ca.
http://bugzilla.ximian.com/show_bug.cgi?id=32269
--- shadow/32269 Mon Oct 14 14:05:45 2002
+++ shadow/32269.tmp.8449 Mon Oct 14 20:29:04 2002
@@ -1,14 +1,14 @@
Bug#: 32269
Product: Mono/Runtime
Version: unspecified
-OS:
+OS: unknown
OS Details:
Status: NEW
Resolution:
-Severity:
+Severity: Unknown
Priority: Normal
Component: misc
AssignedTo: mono-bugs@ximian.com
ReportedBy: andy@nobugs.org
QAContact: mono-bugs@ximian.com
TargetMilestone: ---
@@ -45,6 +45,40 @@
Additional Information:
Actually, it's the cast from MyEnum to System.Enum gives null on mono.
However, I've left the code snippet exactly as it was when I tested it on a
windows box at work today, so I'm sure of the behaviour on windows.
+
+------- Additional Comments From hwang_rob@yahoo.ca 2002-10-14 20:29 -------
+For what it's worth (and it might not be worth much), here are my
+observations:
+
+1) This seems related to 31835
+
+2) The fix for 31835 seems to cause the test case this bug report to
+fail to even compile (error CS0029: Cannot convert implicitly from
+`object' to `System.Enum') (but I think mcs is closer to correctness
+with the 31835 fix than without it)
+
+What appears to be happening is that the line
+ System.Enum se = (System.Enum) me;
+
+causes variable me to be boxed (the explicit conversion code first
+tries to do an implicit conversion of "me" to System.Enum, which hits
+the code for for bug 31835 and boxes it). Boxing creates an instance
+of type object. Assignment to variable se (of type System.Enum) from
+type object is not allowed. Hence the error.
+
+Therefore, a possible fix is to augment the fix for 31835 so that,
+when necessary, it does a ClassCast of the BoxedCast instead of just
+the BoxedCast -- it seems to work on the limited tests I've done.
+
+The odd thing is that csc is quite happy to box and store to "se"
+without emitting the classcast instruction, which looks incorrect to
+me, unless you assume that boxing does more than what the C# spec
+says: return "the resulting instance as a value of type object". If
+mcs were to implement this behaviour, I suspect BoxedCast would need
+to be modified...
+
+Hope that this commentary is useful to whoever works on this...
+Hopefully it is even correct :)