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=81380 --- shadow/81380 2007-04-15 10:59:34.000000000 -0400 +++ shadow/81380.tmp.25356 2007-04-15 10:59:34.000000000 -0400 @@ -0,0 +1,71 @@ +Bug#: 81380 +Product: Mono: Compilers +Version: 1.2 +OS: All +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Warning CS0183 incorrectly given for reference types + +Description of Problem: + +Re: Warning CS0183: The given expression is always of the provided (`IFoo') type + +This warning is not valid for reference types since the boolean expression may evaluate to true or +false at runtime (null would give false). CS0183 should only be generated for value types because +that's the only situation where the evaluation of the "is" test will not vary. + +Steps to reproduce the problem: + +// test.cs +using System; +interface IFoo { +} +class Bar { +} +class Program { + public static void Main() { + IFoo foo = null; + if (foo is IFoo) + Console.WriteLine("got an IFoo"); // never prints + Bar bar = null; + if (bar is Bar) + Console.WriteLine("got a bar"); // never prints + } +} +// end of test.cs + +Actual Results: + +$ gmcs test.cs +test.cs(15,11): warning CS0183: The given expression is always of the provided (`IFoo') type +test.cs(18,11): warning CS0183: The given expression is always of the provided (`Bar') type +Compilation succeeded - 2 warning(s) +$ mono test.exe +(no output) + +Expected Results: + +$ gmcs test.cs +$ mono test.exe +(no output) + +How often does this happen? + +Always. + +Additional Information: + +"if (x is Foo)" can evaluate to false if "x" is null. Or it might evaluate to true. +This is true even when the compile-time type of "x" is "Foo". + +See also: http://msdn2.microsoft.com/en-us/library/sb7782xb(vs.80).aspx _______________________________________________ mono-bugs maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-bugs
