+2009-07-27 Marek Safar <marek.safar@gmail.com>
+
+ * typemanager.cs, argument.cs, convert.cs, assign.cs, expression.cs,
+ ecore.cs: Add TypeManager.IsDynamicType.
+
2009-07-27 Marek Safar <marek.safar@gmail.com>
A fix for bug #415375
dynamic = false;
foreach (Argument a in args) {
a.Resolve (ec);
- dynamic |= a.Type == InternalType.Dynamic;
+ dynamic |= TypeManager.IsDynamicType (a.Type);
}
}
}
if (!TypeManager.IsEqual (target_type, source_type)) {
- if (source_type == InternalType.Dynamic) {
+ if (TypeManager.IsDynamicType (source_type)) {
Arguments args = new Arguments (1);
args.Add (new Argument (source));
return new DynamicConversion (target_type, false, args, loc).Resolve (ec);
// notice that it is possible to write "ValueType v = 1", the ValueType here
// is an abstract class, and not really a value type, so we apply the same rules.
//
- if (target_type == TypeManager.object_type || target_type == InternalType.Dynamic) {
+ if (target_type == TypeManager.object_type || TypeManager.IsDynamicType (target_type)) {
//
// A pointer type cannot be converted to object
//
//
// From any value-type to the type object.
//
- if (target_type == TypeManager.object_type || target_type == InternalType.Dynamic) {
+ if (target_type == TypeManager.object_type || TypeManager.IsDynamicType (target_type)) {
//
// A pointer type cannot be converted to object
//
if (e.Type == TypeManager.bool_type)
return e;
- if (e.Type == InternalType.Dynamic) {
+ if (TypeManager.IsDynamicType (e.Type)) {
Arguments args = new Arguments (1);
args.Add (new Argument (e));
return new DynamicUnaryConversion ("IsTrue", args, loc);
//
protected Expression ConvertExpressionToArrayIndex (EmitContext ec, Expression source)
{
- if (source.type == InternalType.Dynamic) {
+ if (TypeManager.IsDynamicType (source.type)) {
Arguments args = new Arguments (1);
args.Add (new Argument (source));
return new DynamicConversion (TypeManager.int32_type, false, args, loc).Resolve (ec);
if (Expr == null)
return null;
- if (Expr.Type == InternalType.Dynamic) {
+ if (TypeManager.IsDynamicType (Expr.Type)) {
Arguments args = new Arguments (1);
args.Add (new Argument (Expr));
return new DynamicUnaryConversion (GetOperatorExpressionTypeName (), args, loc).DoResolve (ec);
CheckUselessComparison (rc, left.Type);
}
- if (left.Type == InternalType.Dynamic || right.Type == InternalType.Dynamic) {
+ if (TypeManager.IsDynamicType (left.Type) || TypeManager.IsDynamicType (right.Type)) {
Arguments args = new Arguments (2);
args.Add (new Argument (left));
args.Add (new Argument (right));
Type expr_type = expr_resolved.Type;
mg = expr_resolved as MethodGroupExpr;
- if (expr_type == InternalType.Dynamic || dynamic_arg) {
+ if (dynamic_arg || TypeManager.IsDynamicType (expr_type)) {
if (mg != null && mg.IsBase) {
Report.Error (1971, loc,
"The base call to method `{0}' cannot be dynamically dispatched. Consider casting the dynamic arguments or eliminating the base access",
}
Type expr_type = expr_resolved.Type;
- if (expr_type == InternalType.Dynamic) {
+ if (TypeManager.IsDynamicType (expr_type)) {
Arguments args = new Arguments (2);
args.Add (new Argument (expr_resolved.Resolve (ec)));
if (right_side != null)
{
bool dynamic;
arguments.Resolve (ec, out dynamic);
- if (dynamic || indexer_type == InternalType.Dynamic) {
+ if (dynamic || TypeManager.IsDynamicType (indexer_type)) {
int additional = right_side == null ? 1 : 2;
Arguments args = new Arguments (arguments.Count + additional);
if (is_base_indexer) {
t = DropGenericTypeArguments (t);
return IsSubclassOf (t, TypeManager.delegate_type);
}
+
+ //
+ // Is a type of dynamic type
+ //
+ public static bool IsDynamicType (Type t)
+ {
+ if (t == InternalType.Dynamic)
+ return true;
+
+ if (t != object_type)
+ return false;
+
+ if (t.Module == RootContext.ToplevelTypes.Builder)
+ return false;
+
+ throw new NotImplementedException ("imported dynamic type");
+ }
public static bool IsEnumType (Type t)
{
public static Type TypeToReflectionType (Type type)
{
// TODO: Very lame and painful, GetReference () is enough for mcs-cecil
- return type == InternalType.Dynamic ? object_type : type;
+ return IsDynamicType (type) ? object_type : type;
}
/// <summary>