+2007-01-16 Sergey P. Kondratyev <se@unicom.tomica.ru>
+
+ * generic.cs (TypeParameter.FindMembers): Use the generic
+ constraints, not the constraints to check for methods (first fix
+ of 80518).
+
2006-12-30 Marek Safar <marek.safar@gmail.com>
* cs-parser.jay: Better syntax errors handling.
public MemberList FindMembers (MemberTypes mt, BindingFlags bf,
MemberFilter filter, object criteria)
{
- if (constraints == null)
+ if (gc == null)
return MemberList.Empty;
ArrayList members = new ArrayList ();
+2007-01-16 Sergey P. Kondratyev <se@unicom.tomica.ru>
+
+ * 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 <grendello@gmail.com>
* doc-bootstrap.cs: Fix a compilation problem in the bootstrap phase.
//
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)
--- /dev/null
+//
+// 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);
+ }
+ }
+}
--- /dev/null
+//
+// 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);
+ }
+ }
+}