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
#if GMCS_SOURCE
protected Type MutateArrayType (Type array)
{
- int rank = array.GetArrayRank ();
Type element = TypeManager.GetElementType (array);
if (element.IsArray) {
element = MutateArrayType (element);
return array;
}
+ int rank = array.GetArrayRank ();
+ if (rank == 1)
+ return element.MakeArrayType ();
+
return element.MakeArrayType (rank);
}
}
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);
{
AnonymousMethodBody am;
using (ec.Set (EmitContext.Flags.ProbingMode | EmitContext.Flags.InferReturnType)) {
- am = CompatibleMethod (ec, tic, TypeManager.null_type, 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;
}
// anywhere', we depend on special conversion
// rules.
//
- type = TypeManager.anonymous_method_type;
+ type = InternalType.AnonymousMethod;
if ((Parameters != null) && !Parameters.Resolve (ec))
return null;
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;
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 ();
//
// 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)));
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,