X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fanonymous.cs;h=fed1f93bccd7a6b455189f083b9c4e8ae58c5a6b;hb=a651e64e7518044338d18ea58952d2ed7ca6f5bd;hp=3ffdd87384c287e8db8360c74959ccdb86660ed0;hpb=1fd7e91289180a2d090df8f866dac73a6ff0b5f6;p=mono.git diff --git a/mcs/mcs/anonymous.cs b/mcs/mcs/anonymous.cs index 3ffdd87384c..fed1f93bccd 100644 --- a/mcs/mcs/anonymous.cs +++ b/mcs/mcs/anonymous.cs @@ -550,8 +550,11 @@ namespace Mono.CSharp { if (TypeManager.IsGenericType (field.DeclaringType)) { Type t = MutateGenericType (field.DeclaringType); if (t != field.DeclaringType) { - // TODO: It should throw on imported types - return TypeBuilder.GetField (t, field); + field = TypeManager.DropGenericTypeArguments (field.DeclaringType).GetField (field.Name, TypeManager.AllMembers); + if (field.Module == Module.Builder) + return TypeBuilder.GetField (t, field); + + return FieldInfo.GetFieldFromHandle (field.FieldHandle, t.TypeHandle); } } #endif @@ -561,7 +564,6 @@ namespace Mono.CSharp { #if GMCS_SOURCE protected Type MutateArrayType (Type array) { - int rank = array.GetArrayRank (); Type element = TypeManager.GetElementType (array); if (element.IsArray) { element = MutateArrayType (element); @@ -573,6 +575,10 @@ namespace Mono.CSharp { return array; } + int rank = array.GetArrayRank (); + if (rank == 1) + return element.MakeArrayType (); + return element.MakeArrayType (rank); } @@ -708,7 +714,10 @@ namespace Mono.CSharp { } if (inner_access == null) { - inner_access = new FieldExpr (field.FieldBuilder, field.Location); + inner_access = field.Parent.MemberName.IsGeneric ? + new FieldExpr (field.FieldBuilder, field.Parent.CurrentType, field.Location) : + new FieldExpr (field.FieldBuilder, field.Location); + inner_access.InstanceExpression = storey.GetStoreyInstanceExpression (ec); inner_access.Resolve (ec); cached_inner_access.Add (ec.CurrentAnonymousMethod, inner_access); @@ -999,16 +1008,12 @@ namespace Mono.CSharp { { AnonymousMethodBody am; using (ec.Set (EmitContext.Flags.ProbingMode | EmitContext.Flags.InferReturnType)) { - am = CompatibleMethod (ec, tic, GetType (), delegate_type); + am = CompatibleMethod (ec, tic, InternalType.Arglist, delegate_type); } if (am == null) return null; - // Stop referencing gmcs NullLiteral type - if (am.ReturnType == TypeManager.null_type) - am.ReturnType = null; - return am.ReturnType; } @@ -1129,7 +1134,7 @@ namespace Mono.CSharp { // anywhere', we depend on special conversion // rules. // - type = TypeManager.anonymous_method_type; + type = InternalType.AnonymousMethod; if ((Parameters != null) && !Parameters.Resolve (ec)) return null; @@ -1302,8 +1307,10 @@ namespace Mono.CSharp { IDisposable aec_dispose = null; EmitContext.Flags flags = 0; - if (ec.InferReturnType) + if (ec.InferReturnType) { flags |= EmitContext.Flags.InferReturnType; + aec.ReturnTypeInference = new TypeInferenceContext (); + } if (ec.IsInProbingMode) flags |= EmitContext.Flags.ProbingMode; @@ -1321,8 +1328,10 @@ namespace Mono.CSharp { bool unreachable; bool res = aec.ResolveTopBlock (ec, Block, Block.Parameters, null, out unreachable); - if (ec.InferReturnType) - ReturnType = aec.ReturnType; + if (ec.InferReturnType) { + aec.ReturnTypeInference.FixAllTypes (); + ReturnType = aec.ReturnTypeInference.InferredTypeArguments [0]; + } if (aec_dispose != null) { aec_dispose.Dispose (); @@ -1806,9 +1815,10 @@ namespace Mono.CSharp { // // Equals (object obj) override - // + // + LocalVariableReference other_variable_assign = new LocalVariableReference (equals_block, "other", loc); equals_block.AddStatement (new StatementExpression ( - new SimpleAssign (other_variable, + new SimpleAssign (other_variable_assign, new As (equals_block.GetParameterReference ("obj", loc), current_type, loc), loc))); @@ -1849,8 +1859,9 @@ namespace Mono.CSharp { hashcode_block.AddVariable (TypeManager.system_int32_expr, "hash", loc); LocalVariableReference hash_variable = new LocalVariableReference (hashcode_block, "hash", loc); + LocalVariableReference hash_variable_assign = new LocalVariableReference (hashcode_block, "hash", loc); hashcode_block.AddStatement (new StatementExpression ( - new SimpleAssign (hash_variable, rs_hashcode))); + new SimpleAssign (hash_variable_assign, rs_hashcode))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable,