Author: marek
Date: 2005-08-24 11:11:52 -0400 (Wed, 24 Aug 2005)
New Revision: 48782
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/attribute.cs
trunk/mcs/mcs/class.cs
trunk/mcs/mcs/cs-parser.jay
trunk/mcs/mcs/cs-tokenizer.cs
trunk/mcs/mcs/ecore.cs
trunk/mcs/mcs/enum.cs
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/statement.cs
trunk/mcs/mcs/typemanager.cs
Log:
2005-08-24 Marek Safar <[EMAIL PROTECTED]>
* attribute.cs (GetMethodObsoleteAttribute): Disabled obsolete
properties
detection until I fix it.
* cs-tokenizer.cs: Changed error message.
* cs-parser.jay: Fixed 2 error locations.
* ecore.cs (Error_TypeDoesNotContainDefinition): Share error message.
(PropertyExpr.Error_PropertyNotFound): First attempt to detect non C#
properties.
* enum.cs (GetSignatureForError): Fixed.
* expression.cs (Invocation.IsSpecialMethodInvocation): Improved special
method detection.
* class.cs,
* typemanager.cs (RegisterProperty): Removed.
* statement.cs (CheckInvariantMeaningInBlock): Changed error message.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/ChangeLog 2005-08-24 15:11:52 UTC (rev 48782)
@@ -1,3 +1,26 @@
+2005-08-24 Marek Safar <[EMAIL PROTECTED]>
+
+ * attribute.cs (GetMethodObsoleteAttribute): Disabled obsolete
properties
+ detection until I fix it.
+
+ * cs-tokenizer.cs: Changed error message.
+
+ * cs-parser.jay: Fixed 2 error locations.
+
+ * ecore.cs (Error_TypeDoesNotContainDefinition): Share error message.
+ (PropertyExpr.Error_PropertyNotFound): First attempt to detect non C#
+ properties.
+
+ * enum.cs (GetSignatureForError): Fixed.
+
+ * expression.cs (Invocation.IsSpecialMethodInvocation): Improved special
+ method detection.
+
+ * class.cs,
+ * typemanager.cs (RegisterProperty): Removed.
+
+ * statement.cs (CheckInvariantMeaningInBlock): Changed error message.
+
2005-08-24 Raja R Harinath <[EMAIL PROTECTED]>
Fix #75874.
Modified: trunk/mcs/mcs/attribute.cs
===================================================================
--- trunk/mcs/mcs/attribute.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/attribute.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -1671,9 +1671,14 @@
if (mb.DeclaringType is TypeBuilder)
return null;
- PropertyInfo pi = PropertyExpr.AccessorTable [mb] as
PropertyInfo;
- if (pi != null)
- return GetMemberObsoleteAttribute (pi);
+ if (mb.IsSpecialName) {
+ PropertyInfo pi = PropertyExpr.AccessorTable
[mb] as PropertyInfo;
+ if (pi != null) {
+ // FIXME: This is buggy as properties
from this assembly are included as well
+ return null;
+ //return GetMemberObsoleteAttribute
(pi);
+ }
+ }
return GetMemberObsoleteAttribute (mb);
}
Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/class.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -6442,7 +6442,6 @@
if (!Set.IsDummy)
PropertyBuilder.SetSetMethod (SetBuilder);
- TypeManager.RegisterProperty (PropertyBuilder,
GetBuilder, SetBuilder);
return true;
}
}
Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/cs-parser.jay 2005-08-24 15:11:52 UTC (rev 48782)
@@ -1630,7 +1630,7 @@
MemberName name = new MemberName (lt.Value, lt.Location);
if ($3 == TypeManager.system_void_expr) {
- Report.Error (547, lt.Location, "`{0}': property or
indexer cannot have void type", $4);
+ Report.Error (547, lt.Location, "`{0}': property or
indexer cannot have void type", lt.Value);
break;
}
@@ -1702,7 +1702,8 @@
$$ = null;
}
| opt_attributes opt_new EVENT type IDENTIFIER ASSIGN {
- Report.Error (68, (Location) $3, "`{0}.{1}': event in interface
cannot have initializer", current_container.Name, $5);
+ LocatedToken lt = (LocatedToken) $5;
+ Report.Error (68, lt.Location, "`{0}.{1}': event in interface
cannot have initializer", current_container.Name, lt.Value);
$$ = null;
}
| opt_attributes opt_new EVENT type IDENTIFIER OPEN_BRACE
Modified: trunk/mcs/mcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/mcs/cs-tokenizer.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/cs-tokenizer.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -2274,7 +2274,7 @@
// in csc, it is 'XML comment is not placed on
// a valid language element'. But that does not
// make sense.
- Report.Warning (1587, 2, Location, "XML comment
is placed on an invalid language element.");
+ Report.Warning (1587, 2, Location, "XML comment
is not placed on a valid language element");
}
}
Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/ecore.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -283,6 +283,12 @@
Convert.Error_CannotImplicitConversion (loc, Type, t);
}
+ protected static void Error_TypeDoesNotContainDefinition
(Location loc, Type type, string name)
+ {
+ Report.Error (117, loc, "`{0}' does not contain a
definition for `{1}'",
+ TypeManager.CSharpName (type), name);
+ }
+
ResolveFlags ExprClassToResolveFlags ()
{
switch (eclass) {
@@ -520,6 +526,8 @@
/// <summary>
/// Returns a fully formed expression after a MemberLookup
/// </summary>
+ ///
+ // TODO: This can be heavily cached
public static Expression ExprClassFromMemberInfo (EmitContext
ec, MemberInfo mi, Location loc)
{
if (mi is EventInfo)
@@ -723,9 +731,7 @@
Report.Error (103, loc, "The name `{0}'
does not exist in the context of `{1}'",
name, class_name);
else
- Report.Error (
- 117, loc, "`" +
TypeManager.CSharpName (queried_type) + "' does not contain a " +
- "definition for `" + name +
"'");
+ Error_TypeDoesNotContainDefinition
(loc, queried_type, name);
return;
}
@@ -3178,6 +3184,26 @@
return true;
}
+
+ void Error_PropertyNotFound (MethodInfo mi, bool getter)
+ {
+ // TODO: correctly we should compare arguments but it
will lead to bigger changes
+ if (mi is MethodBuilder) {
+ Error_TypeDoesNotContainDefinition (loc,
PropertyInfo.DeclaringType, Name);
+ return;
+ }
+
+ StringBuilder sig = new StringBuilder
(TypeManager.CSharpName (mi.DeclaringType));
+ sig.Append ('.');
+ ParameterData iparams = TypeManager.GetParameterData
(mi);
+ sig.Append (getter ? "get_" : "set_");
+ sig.Append (Name);
+ sig.Append (iparams.GetSignatureForError ());
+
+ Report.SymbolRelatedToPreviousError (mi);
+ Report.Error (1546, loc, "Property `{0}' is not
supported by the C# language. Try to call the accessor method `{1}' directly",
+ Name, sig.ToString ());
+ }
override public Expression DoResolve (EmitContext ec)
{
@@ -3186,10 +3212,7 @@
if (getter != null){
if (TypeManager.GetArgumentTypes
(getter).Length != 0){
- Report.Error (
- 117, loc, "`{0}' does not
contain a " +
- "definition for `{1}'.",
getter.DeclaringType,
- Name);
+ Error_PropertyNotFound (getter, true);
return null;
}
}
@@ -3264,10 +3287,7 @@
}
if (TypeManager.GetArgumentTypes (setter).Length != 1){
- Report.Error (
- 117, loc, "`{0}' does not contain a " +
- "definition for `{1}'.",
getter.DeclaringType,
- Name);
+ Error_PropertyNotFound (setter, false);
return null;
}
Modified: trunk/mcs/mcs/enum.cs
===================================================================
--- trunk/mcs/mcs/enum.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/enum.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -155,7 +155,7 @@
public override string GetSignatureForError()
{
- return String.Concat (parent_enum.GetSignatureForError
(), '.', base.GetSignatureForError ());
+ return String.Concat (parent_enum.GetSignatureForError
(), '.', Name);
}
public override string[] ValidAttributeTargets {
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/expression.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -2913,7 +2913,8 @@
private void WarnUselessComparison (Type type)
{
- Report.Warning (652, 2, loc, "Comparison to integral
constant is useless; the constant is outside the range of type '{0}'", type);
+ Report.Warning (652, 2, loc, "Comparison to integral
constant is useless; the constant is outside the range of type `{0}'",
+ TypeManager.CSharpName (type));
}
/// <remarks>
@@ -5428,12 +5429,8 @@
return null;
}
- if ((method.Attributes & MethodAttributes.SpecialName)
!= 0) {
- if (TypeManager.LookupDeclSpace
(method.DeclaringType) != null || TypeManager.IsSpecialMethod (method)) {
- Report.Error (571, loc, "`{0}': cannot
explicitly call operator or accessor",
- TypeManager.CSharpSignature
(method, true));
- return null;
- }
+ if ((method.Attributes & MethodAttributes.SpecialName)
!= 0 && IsSpecialMethodInvocation (method)) {
+ return null;
}
if (mg.InstanceExpression != null)
@@ -5443,6 +5440,32 @@
return this;
}
+ bool IsSpecialMethodInvocation (MethodBase method)
+ {
+ IMethodData md = TypeManager.GetMethod (method);
+ if (md != null) {
+ if (!(md is AbstractPropertyEventMethod) &&
!(md is Operator))
+ return false;
+ } else {
+ if (!TypeManager.IsSpecialMethod (method))
+ return false;
+
+ int args = TypeManager.GetParameterData
(method).Count;
+ if (method.Name.StartsWith ("get_") && args > 0)
+ return false;
+ else if (method.Name.StartsWith ("set_") &&
args > 2)
+ return false;
+
+ // TODO: check operators and events as well ?
+ }
+
+ Report.SymbolRelatedToPreviousError (method);
+ Report.Error (571, loc, "`{0}': cannot explicitly call
operator or accessor",
+ TypeManager.CSharpSignature (method, true));
+
+ return true;
+ }
+
// <summary>
// Emits the list of arguments as an array
// </summary>
@@ -6039,11 +6062,13 @@
}
if (type.IsAbstract && type.IsSealed) {
+ Report.SymbolRelatedToPreviousError (type);
Report.Error (712, loc, "Cannot create an
instance of the static class `{0}'", TypeManager.CSharpName (type));
return null;
}
if (type.IsInterface || type.IsAbstract){
+ Report.SymbolRelatedToPreviousError (type);
Report.Error (144, loc, "Cannot create an
instance of the abstract class or interface `{0}'", TypeManager.CSharpName
(type));
return null;
}
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/statement.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -1512,7 +1512,7 @@
// treat it as if the variable declaration was in error.
//
Report.SymbolRelatedToPreviousError (loc, name);
- Error_AlreadyDeclared (kvi.Location, name, "child");
+ Error_AlreadyDeclared (kvi.Location, name, "parent or
current");
return false;
}
Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs 2005-08-24 15:05:47 UTC (rev 48781)
+++ trunk/mcs/mcs/typemanager.cs 2005-08-24 15:11:52 UTC (rev 48782)
@@ -290,7 +290,6 @@
fieldbuilders_to_fields = null;
events = null;
priv_fields_events = null;
- properties = null;
type_hash = null;
TypeHandle.CleanUp ();
@@ -1808,27 +1807,9 @@
return (MemberInfo) priv_fields_events [ei];
}
- static Hashtable properties;
-
- static public bool RegisterProperty (PropertyBuilder pb, MethodBase
get, MethodBase set)
- {
- if (properties == null)
- properties = new Hashtable ();
-
- if (properties.Contains (pb))
- return false;
-
- properties.Add (pb, new Pair (get, set));
-
- return true;
- }
-
static public bool RegisterIndexer (PropertyBuilder pb, MethodBase get,
MethodBase set, Type[] args)
{
- if (!RegisterProperty (pb, get,set))
- return false;
-
indexer_arguments.Add (pb, args);
return true;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches