ソースを参照

2005-04-29 Martin Baulig <[email protected]>

	* generic.cs (TypeManager.HasConstructorConstraint): Removed.

	* expression.cs (New.DoResolve): Fix the CS0304 check.


svn path=/trunk/mcs/; revision=43769
Martin Baulig 21 年 前
コミット
601ddadcc3
3 ファイル変更9 行追加10 行削除
  1. 6 0
      mcs/gmcs/ChangeLog
  2. 3 1
      mcs/gmcs/expression.cs
  3. 0 9
      mcs/gmcs/generic.cs

+ 6 - 0
mcs/gmcs/ChangeLog

@@ -1,3 +1,9 @@
+2005-04-29  Martin Baulig  <[email protected]>
+
+	* generic.cs (TypeManager.HasConstructorConstraint): Removed.
+
+	* expression.cs (New.DoResolve): Fix the CS0304 check.
+
 2005-04-29  Martin Baulig  <[email protected]>
 
 	* typemanager.cs (TypeManager.GetFullName): Updated to the new

+ 3 - 1
mcs/gmcs/expression.cs

@@ -5975,7 +5975,9 @@ namespace Mono.CSharp {
 			}
 
 			if (type.IsGenericParameter) {
-				if (!TypeManager.HasConstructorConstraint (type)) {
+				GenericConstraints gc = TypeManager.GetTypeParameterConstraints (type);
+
+				if ((gc == null) || (!gc.HasConstructorConstraint && !gc.IsValueType)) {
 					Error (304, String.Format (
 						       "Cannot create an instance of the " +
 						       "variable type '{0}' because it " +

+ 0 - 9
mcs/gmcs/generic.cs

@@ -1631,15 +1631,6 @@ namespace Mono.CSharp {
 			return (TypeParameter) builder_to_type_param [t];
 		}
 
-		public static bool HasConstructorConstraint (Type t)
-		{
-			GenericConstraints gc = GetTypeParameterConstraints (t);
-			if (gc == null)
-				return false;
-
-			return (gc.Attributes & GenericParameterAttributes.DefaultConstructorConstraint) != 0;
-		}
-
 		public static GenericConstraints GetTypeParameterConstraints (Type t)
 		{
 			if (!t.IsGenericParameter)