2007-07-03 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Tue, 3 Jul 2007 09:01:55 +0000 (09:01 -0000)
committerMarek Safar <marek.safar@gmail.com>
Tue, 3 Jul 2007 09:01:55 +0000 (09:01 -0000)
* class.cs (Indexer): Check return type as soon as possible.

* cs-parser.jay: Initialize implicit_value_parameter_type for interface
members too.

* ecore.cs (VarExpr.DoResolveLValue): Set eclass value.

* expression.cs (Invocation.Error_InvalidArguments): Show type only.

* parameter.cs (Parameter): Use expression type when it is available.

* support.cs (ReflectionParameters.ParameterDesc): Show an extension
method modifier for the first parameter only.

svn path=/trunk/mcs/; revision=81230

mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/cs-parser.jay
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/parameter.cs
mcs/mcs/support.cs

index 7b3cadcf33349e975352463cdcac08e0ad8e2880..bfaaed7b0279ffe58c9c386462ac2ce73b0a3d3e 100644 (file)
@@ -1,3 +1,19 @@
+2007-07-03  Marek Safar  <marek.safar@gmail.com>
+
+       * class.cs (Indexer): Check return type as soon as possible.
+       
+       * cs-parser.jay: Initialize implicit_value_parameter_type for interface
+       members too.
+       
+       * ecore.cs (VarExpr.DoResolveLValue): Set eclass value.
+       
+       * expression.cs (Invocation.Error_InvalidArguments): Show type only.
+       
+       * parameter.cs (Parameter): Use expression type when it is available.
+       
+       * support.cs (ReflectionParameters.ParameterDesc): Show an extension
+       method modifier for the first parameter only.
+
 2007-06-24  Marek Safar  <marek.safar@gmail.com>
 
        A fix for bug #81938
index d666cbb32beccf5221ff2516564713092d6cafa2..25dcf72ce063ce4ea6dba2255abeb2a207a9edc7 100644 (file)
@@ -7682,6 +7682,9 @@ namespace Mono.CSharp {
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
                                is_iface, name, attrs, define_set_first)
                {
+                       if (type == TypeManager.system_void_expr)
+                               Report.Error (620, name.Location, "An indexer return type cannot be `void'");
+                       
                        this.parameters = parameters;
 
                        if (get_block == null)
@@ -7749,11 +7752,6 @@ namespace Mono.CSharp {
                        if (!DefineParameters (parameters))
                                return false;
 
-                       if (MemberType == TypeManager.void_type) {
-                               Report.Error (620, Location, "Indexers cannot have void type");
-                               return false;
-                       }
-
                        if (OptAttributes != null) {
                                Attribute indexer_attr = OptAttributes.Search (TypeManager.indexer_name_type);
                                if (indexer_attr != null) {
index aa513d73aa9f5edfdbcec31fba98da0a7b7a3425..4b6c0a3addc07454da2d0c0f42036fa2c50debc1 100644 (file)
@@ -1742,11 +1742,15 @@ interface_property_declaration
          opt_new
          type IDENTIFIER 
          OPEN_BRACE 
-         { lexer.PropertyParsing = true; }
+         {
+               lexer.PropertyParsing = true;
+               implicit_value_parameter_type = (Expression)$3;
+         }
          accessor_declarations 
          {
                has_get = has_set = false; 
                lexer.PropertyParsing = false;
+               implicit_value_parameter_type = null;
          }
          CLOSE_BRACE
          {
@@ -1820,11 +1824,13 @@ interface_event_declaration
          }
        | opt_attributes opt_new EVENT type IDENTIFIER OPEN_BRACE
          {
+               implicit_value_parameter_type = (Expression) $4;
                lexer.EventParsing = true;
          }
          event_accessor_declarations
          {
                lexer.EventParsing = false;
+               implicit_value_parameter_type = null;
          }
          CLOSE_BRACE {
                Report.Error (69, (Location) $3, "Event in interface cannot have add or remove accessors");
@@ -1835,12 +1841,16 @@ interface_event_declaration
 interface_indexer_declaration 
        : opt_attributes opt_new type THIS 
          OPEN_BRACKET formal_parameter_list CLOSE_BRACKET
-         OPEN_BRACE 
-         { lexer.PropertyParsing = true; }
+         OPEN_BRACE
+         {
+               lexer.PropertyParsing = true;
+               implicit_value_parameter_type = (Expression)$3;
+         }
          accessor_declarations 
          { 
                has_get = has_set = false;
                lexer.PropertyParsing = false;
+               implicit_value_parameter_type = null;
          }
          CLOSE_BRACE
          {
index 23cb1acdd6753aac48c7106df14d4669a85f0b8a..23c7e9fe837404d8d81334ae54dc685d4a5d2cef 100644 (file)
@@ -5040,7 +5040,8 @@ namespace Mono.CSharp {
                                              TypeManager.CSharpName (type));
                                return null;
                        }
-                       
+
+                       eclass = ExprClass.Variable;
                        return this;
                }
 
index 9c4b1ceff15e9578c6c84f541d0fbf0aba26902f..b011b114d858d7e74fdeb9039b86ab11c002d2b0 100644 (file)
@@ -4341,14 +4341,14 @@ namespace Mono.CSharp {
                                                index, Parameter.GetModifierSignature (mod));
                        } else {
                                string p1 = Argument.FullDesc (a);
-                               string p2 = expected_par.ParameterDesc (idx);
+                               string p2 = TypeManager.CSharpName (expected_par.ParameterType (idx));
 
                                if (p1 == p2) {
                                        Report.ExtraInformation (loc, "(equally named types possibly from different assemblies in previous ");
                                        Report.SymbolRelatedToPreviousError (a.Expr.Type);
                                        Report.SymbolRelatedToPreviousError (expected_par.ParameterType (idx));
                                }
-                               Report.Error (1503, loc, "Argument {0}: Cannot convert from `{1}' to `{2}'", index, p1, p2);
+                               Report.Error (1503, loc, "Argument {0}: Cannot convert type `{1}' to `{2}'", index, p1, p2);
                        }
                }
                
index 7598d1fd38868e9e60ef5d115e1b56bf73491abf..6c50851b114f925c714e28fb8bac53d4914a69f9 100644 (file)
@@ -241,12 +241,12 @@ namespace Mono.CSharp {
 #endif
                
                public Parameter (Expression type, string name, Modifier mod, Attributes attrs, Location loc)
-                       : base (attrs)
+                       : this (type.Type, name, mod, attrs, loc)
                {
-                       Name = name;
-                       modFlags = mod;
+                       if (type == TypeManager.system_void_expr)
+                               Report.Error (1536, loc, "Invalid parameter type `void'");
+                       
                        TypeName = type;
-                       Location = loc;
                }
 
                public Parameter (Type type, string name, Modifier mod, Attributes attrs, Location loc)
@@ -332,11 +332,12 @@ namespace Mono.CSharp {
                // </summary>
                public virtual bool Resolve (IResolveContext ec)
                {
+                       // HACK: to resolve attributes correctly
+                       this.resolve_context = ec;
+
                        if (parameter_type != null)
                                return true;
 
-                       this.resolve_context = ec;
-
                        TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
                        if (texpr == null)
                                return false;
@@ -358,11 +359,6 @@ namespace Mono.CSharp {
                                return false;
                        }
 
-                       if (parameter_type == TypeManager.void_type){
-                               Report.Error (1536, Location, "Invalid parameter type 'void'");
-                               return false;
-                       }
-
                        if ((modFlags & Parameter.Modifier.ISBYREF) != 0){
                                if (parameter_type == TypeManager.typed_reference_type ||
                                    parameter_type == TypeManager.arg_iterator_type){
@@ -588,8 +584,7 @@ namespace Mono.CSharp {
 
                public Parameter Clone ()
                {
-                       Parameter p = new Parameter (TypeName, Name, ModFlags, attributes, Location);
-                       p.parameter_type = parameter_type;
+                       Parameter p = new Parameter (parameter_type, Name, ModFlags, attributes, Location);
                        p.IsTypeParameter = IsTypeParameter;
 
                        return p;
index 3f072b6c53e8e4f653320c3a96293f9c89fcf9a5..78b4870c10ae40b74a7ef5ebe10be7734c094593 100644 (file)
@@ -209,7 +209,7 @@ namespace Mono.CSharp {
                        if (params_idx == pos)
                                sb.Append ("params ");
 
-                       if (ExtensionMethodType != null)
+                       if (pos == 0 && ExtensionMethodType != null)
                                sb.Append ("this ");
 
                        sb.Append (TypeManager.CSharpName (partype).Replace ("&", ""));