2009-06-23 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / anonymous.cs
index 6b09a7fbe8f18fc21d32f497c75d605aaaa76e31..b11557f31afc3bc858bd50a9cb67b2e431a49da0 100644 (file)
@@ -508,7 +508,7 @@ namespace Mono.CSharp {
                                Type t = MutateGenericType (method.DeclaringType);
                                if (t != method.DeclaringType) {
                                        method = (MethodInfo) TypeManager.DropGenericMethodArguments (method);
-                                       if (method.Module == CodeGen.Module.Builder)
+                                       if (method.Module == Module.Builder)
                                                method = TypeBuilder.GetMethod (t, method);
                                        else
                                                method = (MethodInfo) MethodInfo.GetMethodFromHandle (method.MethodHandle, t.TypeHandle);
@@ -534,7 +534,7 @@ namespace Mono.CSharp {
                                Type t = MutateGenericType (ctor.DeclaringType);
                                if (t != ctor.DeclaringType) {
                                        ctor = (ConstructorInfo) TypeManager.DropGenericMethodArguments (ctor);
-                                       if (ctor.Module == CodeGen.Module.Builder)
+                                       if (ctor.Module == Module.Builder)
                                                return TypeBuilder.GetConstructor (t, ctor);
                                                
                                        return (ConstructorInfo) ConstructorInfo.GetMethodFromHandle (ctor.MethodHandle, t.TypeHandle);
@@ -585,7 +585,7 @@ namespace Mono.CSharp {
                        for (int i = 0; i < t_args.Length; ++i)
                                t_args [i] = MutateType (t_args [i]);
 
-                       return type.GetGenericTypeDefinition ().MakeGenericType (t_args);
+                       return TypeManager.DropGenericTypeArguments (type).MakeGenericType (t_args);
                }
 #endif
 
@@ -876,7 +876,6 @@ namespace Mono.CSharp {
                        if (TypeManager.IsDelegateType (delegate_type))
                                return delegate_type;
 
-#if GMCS_SOURCE
                        if (TypeManager.DropGenericTypeArguments (delegate_type) == TypeManager.expression_type) {
                                delegate_type = TypeManager.GetTypeArguments (delegate_type) [0];
                                if (TypeManager.IsDelegateType (delegate_type))
@@ -886,7 +885,6 @@ namespace Mono.CSharp {
                                        GetSignatureForError (), TypeManager.CSharpName (delegate_type));
                                return null;
                        }
-#endif
 
                        Report.Error (1660, loc, "Cannot convert `{0}' to non-delegate type `{1}'",
                                      GetSignatureForError (), TypeManager.CSharpName (delegate_type));
@@ -971,16 +969,12 @@ namespace Mono.CSharp {
                                return false;
 
                        if (!TypeManager.IsDelegateType (delegate_type)) {
-#if GMCS_SOURCE
                                if (TypeManager.DropGenericTypeArguments (delegate_type) != TypeManager.expression_type)
                                        return false;
 
-                               delegate_type = delegate_type.GetGenericArguments () [0];
+                               delegate_type = TypeManager.GetTypeArguments (delegate_type) [0];
                                if (!TypeManager.IsDelegateType (delegate_type))
                                        return false;
-#else
-                               return false;
-#endif
                        }
                        
                        AParametersCollection d_params = TypeManager.GetDelegateParameters (delegate_type);
@@ -1064,6 +1058,8 @@ namespace Mono.CSharp {
                                        compatibles.Add (type, am == null ? EmptyExpression.Null : am);
 
                                return am;
+                       } catch (CompletionResult){
+                               throw;
                        } catch (Exception e) {
                                throw new InternalErrorException (e, loc);
                        }
@@ -1537,7 +1533,6 @@ namespace Mono.CSharp {
                        }
 
                        MethodInfo delegate_method = method.MethodBuilder;
-#if GMCS_SOURCE
                        if (storey != null && storey.MemberName.IsGeneric) {
                                Type t = storey.Instance.Type;
                                
@@ -1551,9 +1546,13 @@ namespace Mono.CSharp {
                                        t = storey.GetGenericStorey ().MutateType (t);
                                }
 
+#if GMCS_SOURCE
                                delegate_method = TypeBuilder.GetMethod (t, delegate_method);
-                       }
+#else
+                               throw new NotSupportedException ();
 #endif
+                       }
+
                        ig.Emit (OpCodes.Ldftn, delegate_method);
 
                        ConstructorInfo constructor_method = Delegate.GetConstructor (ec.ContainerType, type);
@@ -1636,8 +1635,8 @@ namespace Mono.CSharp {
 
                public static AnonymousTypeClass Create (TypeContainer parent, ArrayList parameters, Location loc)
                {
-                       if (RootContext.Version <= LanguageVersion.ISO_2)
-                               Report.FeatureIsNotAvailable (loc, "anonymous types");
+                       if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)
+                               Report.FeatureIsNotSupported (loc, "anonymous types");
 
                        string name = ClassNamePrefix + types_counter++;