Author: miguel
Date: 2007-01-16 11:14:05 -0500 (Tue, 16 Jan 2007)
New Revision: 71148

Added:
   trunk/mcs/tests/gtest-303.cs
   trunk/mcs/tests/gtest-304.cs
Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/generic.cs
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/expression.cs
Log:
2007-01-16  Sergey P. Kondratyev <[EMAIL PROTECTED]>

        * expression.cs (As.DoResolve): Use GenericConstraints instead of
        Constraints, solves the problem where the compiler incorrectly
        reported that a type parameter was not constrained to a class (Bug
        80518)

2007-01-16  Sergey P. Kondratyev <[EMAIL PROTECTED]>

        * generic.cs (TypeParameter.FindMembers): Use the generic
        constraints, not the constraints to check for methods (first fix
        of 80518).



Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2007-01-16 16:08:58 UTC (rev 71147)
+++ trunk/mcs/gmcs/ChangeLog    2007-01-16 16:14:05 UTC (rev 71148)
@@ -1,3 +1,9 @@
+2007-01-16  Sergey P. Kondratyev <[EMAIL PROTECTED]>
+
+       * generic.cs (TypeParameter.FindMembers): Use the generic
+       constraints, not the constraints to check for methods (first fix
+       of 80518).
+
 2006-12-30  Marek Safar  <[EMAIL PROTECTED]>
 
        * cs-parser.jay: Better syntax errors handling.

Modified: trunk/mcs/gmcs/generic.cs
===================================================================
--- trunk/mcs/gmcs/generic.cs   2007-01-16 16:08:58 UTC (rev 71147)
+++ trunk/mcs/gmcs/generic.cs   2007-01-16 16:14:05 UTC (rev 71148)
@@ -901,7 +901,7 @@
                public MemberList FindMembers (MemberTypes mt, BindingFlags bf,
                                               MemberFilter filter, object 
criteria)
                {
-                       if (constraints == null)
+                       if (gc == null)
                                return MemberList.Empty;
 
                        ArrayList members = new ArrayList ();

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-01-16 16:08:58 UTC (rev 71147)
+++ trunk/mcs/mcs/ChangeLog     2007-01-16 16:14:05 UTC (rev 71148)
@@ -1,3 +1,10 @@
+2007-01-16  Sergey P. Kondratyev <[EMAIL PROTECTED]>
+
+       * expression.cs (As.DoResolve): Use GenericConstraints instead of
+       Constraints, solves the problem where the compiler incorrectly
+       reported that a type parameter was not constrained to a class (Bug
+       80518)
+
 2007-01-14  Marek Habersack  <[EMAIL PROTECTED]>
 
        * doc-bootstrap.cs: Fix a compilation problem in the bootstrap phase.

Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2007-01-16 16:08:58 UTC (rev 71147)
+++ trunk/mcs/mcs/expression.cs 2007-01-16 16:14:05 UTC (rev 71148)
@@ -1262,7 +1262,7 @@
                        //
                        TypeParameterExpr tpe = probe_type_expr as 
TypeParameterExpr;
                        if (tpe != null){
-                               Constraints constraints = 
tpe.TypeParameter.Constraints;
+                               GenericConstraints constraints = 
tpe.TypeParameter.GenericConstraints;
                                bool error = false;
                                
                                if (constraints == null)

Added: trunk/mcs/tests/gtest-303.cs
===================================================================
--- trunk/mcs/tests/gtest-303.cs        2007-01-16 16:08:58 UTC (rev 71147)
+++ trunk/mcs/tests/gtest-303.cs        2007-01-16 16:14:05 UTC (rev 71148)
@@ -0,0 +1,39 @@
+//
+// Test case from bug 80518
+//
+
+using System;
+
+namespace test
+{
+    public class BaseClass
+    {
+       public BaseClass()
+       {
+       }
+       public string Hello { get { return "Hello"; } }
+    }
+
+    public abstract class Printer
+    {
+       public abstract void Print<T>(T obj) where T: BaseClass;
+    } 
+    
+    public class PrinterImpl : Printer
+    {
+       public override void Print<T>(T obj) 
+       {
+           Console.WriteLine(obj.Hello);
+       }
+    }
+
+    public class Starter
+    {
+       public static void Main( string[] args )
+       {
+           BaseClass bc = new BaseClass();
+           Printer p = new PrinterImpl();
+           p.Print<BaseClass>(bc);
+       }       
+    }
+}


Property changes on: trunk/mcs/tests/gtest-303.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mcs/tests/gtest-304.cs
===================================================================
--- trunk/mcs/tests/gtest-304.cs        2007-01-16 16:08:58 UTC (rev 71147)
+++ trunk/mcs/tests/gtest-304.cs        2007-01-16 16:14:05 UTC (rev 71148)
@@ -0,0 +1,38 @@
+//
+// Second test from bug 80518
+//
+using System;
+
+namespace test
+{
+    public class BaseClass
+    {
+       public BaseClass()
+       {
+       }
+       public string Hello { get { return "Hello"; } }
+    }
+
+    public abstract class Printer
+    {
+       public abstract void Print<T>(object x) where T: BaseClass;
+    } 
+    
+    public class PrinterImpl: Printer
+    {
+       public override void Print<T>(object x)
+       {
+           Console.WriteLine((x as T).Hello);
+       }
+    }
+
+    public class Starter
+    {
+       public static void Main( string[] args )
+       {
+           BaseClass bc = new BaseClass();
+           Printer p = new PrinterImpl();
+           p.Print<BaseClass>(bc);
+       }       
+    }
+}


Property changes on: trunk/mcs/tests/gtest-304.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to