//
public bool IsReferenceType {
get {
- return (spec & SpecialConstraint.Class) != 0 || HasTypeConstraint;
+ if ((spec & SpecialConstraint.Class) != 0 || HasTypeConstraint)
+ return true;
+
+ if (targs != null) {
+ foreach (var ta in targs) {
+ if (TypeManager.IsReferenceType (ta))
+ return true;
+ }
+ }
+
+ return false;
}
}
--- /dev/null
+public class Z { }
+
+public class A<X, Y>
+ where Y : Z
+ where X : Y
+{
+ public X Foo (Y y)
+ {
+ return y as X;
+ }
+}
+
+public class Foo
+{
+ public static int Main ()
+ {
+ var a = new A<Z, Z> ();
+ if (a.Foo (new Z ()) == null)
+ return 1;
+
+ return 0;
+ }
+}