Bug 324248 (MONO81571) - [GMCS] implicite conversion to boolean from generic using == does not work
Summary: [GMCS] implicite conversion to boolean from generic using == does not work
Status: RESOLVED FIXED
Alias: MONO81571
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-09 00:37 UTC by Jerome Haltom
Modified: 2008-03-04 09:47 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:38:00 UTC


---- Reported by wasabi@larvalstage.net 2007-05-08 17:37:01 MST ----

I have been assured the following code compiles correctly on MS.Net.
However, I don't have a box at the time to verify it. It doesn't compile
on Mono 1.2.3... and it appears it should.



using System;

namespace MonoBug {
        class MainClass {
                public static void Main(string[] args) {
                        Console.WriteLine("Hello World!");

                        GenericType<bool> g = new GenericType<bool>(true);
                        if (g)
                                Console.WriteLine("true");
                        if (g == true)
                                Console.WriteLine("true");
                }
        }

        public class GenericType<T> {

                private T value;

                public GenericType(T value) {
                        this.value = value;
                }

                public static implicit operator T(GenericType<T> o) {
                        return o.value;
                }
        }
}


Unknown operating system unknown. Setting to default OS "Other".

Comment 2 Sebastien Pouliot 2007-11-06 22:15:29 UTC
Just to confirm (for Windows) and to show the error that gmcs reports...

C:\temp>csc 324248.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.


C:\temp>324248
Hello World!
true
true


gmcs 324248.cs
324248.cs(11,29): error CS0019: Operator `==' cannot be applied to operands of type `MonoBug.GenericType<bool>' and `bool'
Compilation failed: 1 error(s), 0 warnings
Comment 3 Marek Safar 2008-03-04 09:47:53 UTC
Fixed in SVN.