Author: marek
Date: 2007-12-22 08:17:22 -0500 (Sat, 22 Dec 2007)
New Revision: 91807
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/ecore.cs
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/namespace.cs
Log:
2007-12-22 Marek Safar <[EMAIL PROTECTED]>
* ecore.cs, namespace.cs, expression.cs: Removed broken ResolveGeneric
method.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-12-22 13:12:46 UTC (rev 91806)
+++ trunk/mcs/mcs/ChangeLog 2007-12-22 13:17:22 UTC (rev 91807)
@@ -1,3 +1,8 @@
+2007-12-22 Marek Safar <[EMAIL PROTECTED]>
+
+ * ecore.cs, namespace.cs, expression.cs: Removed broken ResolveGeneric
+ method.
+
2007-12-21 Miguel de Icaza <[EMAIL PROTECTED]>
* report.cs (ErrorMessage): Add support for using colors on
Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs 2007-12-22 13:12:46 UTC (rev 91806)
+++ trunk/mcs/mcs/ecore.cs 2007-12-22 13:17:22 UTC (rev 91807)
@@ -2237,7 +2237,7 @@
if (Arguments != null) {
FullNamedExpression retval =
ec.DeclContainer.LookupNamespaceOrType (SimpleName.RemoveGenericArity (Name),
loc, true);
if (retval != null) {
-
Namespace.Error_TypeArgumentsCannotBeUsed (retval.Type, loc, "type");
+
Namespace.Error_TypeArgumentsCannotBeUsed (retval.Type, loc);
return;
}
}
@@ -2462,7 +2462,6 @@
if (Arguments != null) {
Arguments.Resolve (ec);
me.SetTypeArguments (Arguments);
- return me.ResolveGeneric (ec,
Arguments);
}
if (!me.IsStatic && (me.InstanceExpression !=
null) &&
@@ -3017,72 +3016,6 @@
return this;
}
- // This method is very wrong, it will be deleted completely
- [Obsolete ("This method will be removed soon")]
- public Expression ResolveGeneric (EmitContext ec, TypeArguments
args)
- {
-#if GMCS_SOURCE
- MethodGroupExpr mge = this as MethodGroupExpr;
- if (mge == null)
- return null;
-
- Type [] atypes = args.Arguments;
-
- int first_count = 0;
- MethodInfo first = null;
-
- ArrayList list = new ArrayList ();
- foreach (MethodBase mb in mge.Methods) {
- MethodInfo mi = mb as MethodInfo;
- if ((mi == null) || !mb.IsGenericMethod)
- continue;
-
- Type [] gen_params = mb.GetGenericArguments ();
-
- if (first == null) {
- first = mi;
- first_count = gen_params.Length;
- }
-
- if (gen_params.Length != atypes.Length)
- continue;
-
- mi = mi.MakeGenericMethod (atypes);
- list.Add (mi);
-
-#if MS_COMPATIBLE
- // MS implementation throws
NotSupportedException for GetParameters
- // on unbaked generic method
- Parameters p = TypeManager.GetParameterData
(mi) as Parameters;
- if (p != null) {
- p = p.Clone ();
- p.InflateTypes (gen_params, atypes);
- TypeManager.RegisterMethod (mi, p);
- }
-#endif
- }
-
- if (list.Count > 0) {
- mge.Methods = (MethodBase []) list.ToArray
(typeof (MethodBase));
- return this;
- }
-
- if (first != null) {
- Report.SymbolRelatedToPreviousError (first);
- Report.Error (
- 305, loc, "Using the generic method
`{0}' requires `{1}' type arguments",
- TypeManager.CSharpSignature (first),
first_count.ToString ());
- } else
- Report.Error (
- 308, loc, "The non-generic method `{0}'
" +
- "cannot be used with type arguments",
Name);
-
- return null;
-#else
- throw new NotImplementedException ();
-#endif
- }
-
protected void EmitInstance (EmitContext ec, bool
prepare_for_load)
{
if (IsStatic)
@@ -3689,7 +3622,6 @@
//
if (TypeManager.IsGenericMethod (method)) {
if (type_arguments != null) {
-/*
Type [] g_args =
candidate.GetGenericArguments ();
if (g_args.Length !=
type_arguments.Count)
return int.MaxValue - 20000 +
Math.Abs (type_arguments.Count - g_args.Length);
@@ -3698,7 +3630,6 @@
method = ((MethodInfo)
candidate).MakeGenericMethod (type_arguments.Arguments);
candidate = method;
pd = TypeManager.GetParameterData
(candidate);
-*/
} else {
int score =
TypeManager.InferTypeArguments (ec, arguments, ref candidate);
if (score != 0)
@@ -3709,6 +3640,9 @@
pd = TypeManager.GetParameterData
(candidate);
}
+ } else {
+ if (type_arguments != null)
+ return 8811192;
}
#endif
@@ -3969,23 +3903,11 @@
int j = 0;
for (int i = 0; i < Methods.Length; ++i) {
MethodBase m = Methods [i];
-#if GMCS_SOURCE
- Type [] gen_args = null;
- if (m.IsGenericMethod &&
!m.IsGenericMethodDefinition)
- gen_args =
m.GetGenericArguments ();
-#endif
if (TypeManager.IsOverride (m)) {
if (candidate_overrides == null)
candidate_overrides =
new ArrayList ();
candidate_overrides.Add (m);
m =
TypeManager.TryGetBaseDefinition (m);
-#if GMCS_SOURCE
- if (m != null && gen_args !=
null) {
- if
(!m.IsGenericMethodDefinition)
- throw new
InternalErrorException ("GetBaseDefinition didn't return a
GenericMethodDefinition");
- m = ((MethodInfo)
m).MakeGenericMethod (gen_args);
- }
-#endif
}
if (m != null)
Methods [j++] = m;
@@ -4099,6 +4021,11 @@
g_args.Length.ToString ());
return null;
}
+ } else {
+ if (type_arguments != null) {
+
Namespace.Error_TypeArgumentsCannotBeUsed (best_candidate, loc);
+ return null;
+ }
}
ParameterData pd =
TypeManager.GetParameterData (best_candidate);
@@ -4241,11 +4168,25 @@
throw new InternalErrorException (
"Should not happen. An
'override' method took part in overload resolution: " + best_candidate);
- if (candidate_overrides != null)
+ if (candidate_overrides != null) {
+ Type[] gen_args = null;
+ bool gen_override = false;
+ if (TypeManager.IsGenericMethod
(best_candidate))
+ gen_args =
TypeManager.GetGenericArguments (best_candidate);
+
foreach (MethodBase candidate in
candidate_overrides) {
- if (IsOverride (candidate,
best_candidate))
+ if (IsOverride (candidate,
best_candidate)) {
+ gen_override = true;
best_candidate =
candidate;
+ }
}
+
+ if (gen_override && gen_args != null) {
+#if GMCS_SOURCE
+ best_candidate = ((MethodInfo)
best_candidate).MakeGenericMethod (gen_args);
+#endif
+ }
+ }
}
// We can stop here when probing is on
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2007-12-22 13:12:46 UTC (rev 91806)
+++ trunk/mcs/mcs/expression.cs 2007-12-22 13:17:22 UTC (rev 91807)
@@ -6706,7 +6706,6 @@
if (args != null) {
ex_method_lookup.SetTypeArguments (args);
- return
ex_method_lookup.ResolveGeneric (ec, args);
}
return ex_method_lookup.DoResolve (ec);
@@ -6760,7 +6759,6 @@
if (args != null) {
me.SetTypeArguments (args);
- return me.ResolveGeneric (ec, args);
}
if (original != null && !TypeManager.IsValueType
(expr_type)) {
@@ -7986,7 +7984,6 @@
if (args != null) {
args.Resolve (ec);
me.SetTypeArguments (args);
- return me.ResolveGeneric (ec, args);
}
return me;
Modified: trunk/mcs/mcs/namespace.cs
===================================================================
--- trunk/mcs/mcs/namespace.cs 2007-12-22 13:12:46 UTC (rev 91806)
+++ trunk/mcs/mcs/namespace.cs 2007-12-22 13:17:22 UTC (rev 91807)
@@ -344,7 +344,7 @@
if (name.IndexOf ('`') > 0) {
FullNamedExpression retval = Lookup (ds,
SimpleName.RemoveGenericArity (name), loc);
if (retval != null) {
- Error_TypeArgumentsCannotBeUsed
(retval.Type, loc, "type");
+ Error_TypeArgumentsCannotBeUsed
(retval.Type, loc);
return;
}
} else {
@@ -366,11 +366,22 @@
TypeManager.CSharpName(t),
TypeManager.GetNumberOfTypeArguments(t).ToString());
}
- public static void Error_TypeArgumentsCannotBeUsed(Type t,
Location loc, string symbol)
+ public static void Error_TypeArgumentsCannotBeUsed (Type t,
Location loc)
{
- Report.SymbolRelatedToPreviousError(t);
+ Report.SymbolRelatedToPreviousError (t);
+ Error_TypeArgumentsCannotBeUsed (loc, "type",
TypeManager.CSharpName (t));
+ }
+
+ public static void Error_TypeArgumentsCannotBeUsed (MethodBase
mi, Location loc)
+ {
+ Report.SymbolRelatedToPreviousError (mi);
+ Error_TypeArgumentsCannotBeUsed (loc, "method",
TypeManager.CSharpSignature (mi));
+ }
+
+ static void Error_TypeArgumentsCannotBeUsed (Location loc,
string type, string name)
+ {
Report.Error(308, loc, "The non-generic {0} `{1}'
cannot be used with the type arguments",
- symbol, TypeManager.CSharpName(t));
+ type, name);
}
public override void Emit (EmitContext ec)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches