+2010-06-24 Marek Safar <marek.safar@gmail.com>
+
+ A fix for bug #616809
+ * generic.cs, expression.cs, ecore.cs: Added a new type expression
+ for open generic type to pass unbound type arguments to typeof
+ expression.
+
2010-06-24 Marek Safar <marek.safar@gmail.com>
* statement.cs: Foreach collection implementation refactoring to
FullNamedExpression fne = ec.LookupNamespaceOrType (Name, Arity, loc, /*ignore_cs0104=*/ false);
if (fne != null) {
- if (HasTypeArguments && fne.Type != null && TypeManager.IsGenericType (fne.Type)) {
- GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
- return ct.ResolveAsTypeStep (ec, false);
+ if (fne.Type != null && Arity > 0) {
+ if (HasTypeArguments) {
+ GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
+ return ct.ResolveAsTypeStep (ec, false);
+ }
+
+ return new GenericOpenTypeExpr (fne.Type, loc);
}
//
return fne;
}
- if (!HasTypeArguments && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3) {
+ if (Arity == 0 && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3) {
if (!PredefinedAttributes.Get.Dynamic.IsDefined) {
ec.Compiler.Report.Error (1980, Location,
"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?",
typearg = texpr.Type;
- //
- // Get generic type definition for unbounded type arguments
- //
- var tne = QueriedType as ATypeNameExpression;
- if (tne != null && typearg.IsGeneric && !tne.HasTypeArguments)
- typearg = typearg.GetDefinition ();
-
if (typearg == TypeManager.void_type && !(QueriedType is TypeExpression)) {
ec.Report.Error (673, loc, "System.Void cannot be used from C#. Use typeof (void) to get the void type object");
} else if (typearg.IsPointer && !ec.IsUnsafe){
}
}
+ //
+ // Generic type with unbound type arguments, used for typeof (G<,,>)
+ //
+ class GenericOpenTypeExpr : TypeExpr
+ {
+ public GenericOpenTypeExpr (TypeSpec type, /*UnboundTypeArguments args,*/ Location loc)
+ {
+ this.type = type.GetDefinition ();
+ this.loc = loc;
+ }
+
+ protected override TypeExpr DoResolveAsTypeStep (IMemberContext ec)
+ {
+ return this;
+ }
+ }
+
static class ConstraintChecker
{
/// <summary>