/// The @parent argument is set to the parent object or null
/// if this is `System.Object'.
/// </summary>
- Type [] GetClassBases (bool is_class, out Type parent, out bool error)
+ Type [] GetClassBases (bool is_class, out TypeExpr parent, out bool error)
{
ArrayList bases = Bases;
int count;
if (is_class)
parent = null;
else
- parent = TypeManager.value_type;
+ parent = new TypeExpr (TypeManager.value_type, Location);
if (bases == null){
if (is_class){
if (RootContext.StdLib)
- parent = TypeManager.object_type;
+ parent = new TypeExpr (TypeManager.object_type, Location);
else if (Name != "System.Object")
- parent = TypeManager.object_type;
+ parent = new TypeExpr (TypeManager.object_type, Location);
} else {
//
// If we are compiling our runtime,
// parent is `System.Object'.
//
if (!RootContext.StdLib && Name == "System.ValueType")
- parent = TypeManager.object_type;
+ parent = new TypeExpr (TypeManager.object_type, Location);
}
return null;
return null;
}
+ if (name is ConstructedType){
+ parent = (TypeExpr) name;
+ return null;
+ }
+
Type first = name.Type;
+ Type ptype;
if (first.IsClass){
- parent = first;
+ parent = (TypeExpr) name;
+ ptype = first;
start = 1;
} else {
- parent = TypeManager.object_type;
+ ptype = TypeManager.object_type;
+ parent = new TypeExpr (ptype, Location);
start = 0;
}
if (first.IsSealed){
if (first.IsValueType)
detail = " (a class can not inherit from a struct/enum)";
- Report.Error (509, "class `"+ Name +
- "': Cannot inherit from sealed class `"+
- first + "'" + detail);
+ Report.Error (509, Location,"class `{0}': Cannot inherit from " +
+ "sealed class `{1}'{2}", Name, first, detail);
+ error = true;
+ return null;
+ }
+
+ if (ptype == TypeManager.enum_type ||
+ (ptype == TypeManager.value_type && RootContext.StdLib) ||
+ ptype == TypeManager.delegate_type ||
+ ptype == TypeManager.array_type){
+ Report.Error (644, Location,
+ "`{0}' cannot inherit from special class `{1}'",
+ Name, TypeManager.CSharpName (ptype));
error = true;
return null;
}
- if (!AsAccessible (parent, ModFlags))
+ if (IsGeneric && (ptype == TypeManager.attribute_type ||
+ ptype.IsSubclassOf (TypeManager.attribute_type))){
+ Report.Error (-214, Location,
+ "Generic type can not derive from Attribute");
+ error = true;
+ return null;
+ }
+
+ if (!AsAccessible (ptype, ModFlags))
Report.Error (60, Location,
- "Inconsistent accessibility: base class `" +
- TypeManager.CSharpName (parent) + "' is less " +
- "accessible than class `" +
- Name + "'");
+ "Inconsistent accessibility: base class `{0}' " +
+ "is less accessible than class `{1}'",
+ TypeManager.CSharpName (ptype), Name);
} else {
start = 0;
//
public override TypeBuilder DefineType ()
{
- Type parent;
+ TypeExpr parent;
bool is_class;
if (TypeBuilder != null)
if (error)
return null;
- if (is_class && parent != null){
- if (parent == TypeManager.enum_type ||
- (parent == TypeManager.value_type && RootContext.StdLib) ||
- parent == TypeManager.delegate_type ||
- parent == TypeManager.array_type){
- Report.Error (
- 644, Location, "`" + Name + "' cannot inherit from " +
- "special class `" + TypeManager.CSharpName (parent) + "'");
- error = true;
- return null;
- }
- }
-
- if (IsGeneric && (parent == TypeManager.attribute_type ||
- parent.IsSubclassOf (TypeManager.attribute_type))){
- Report.Error (-214, Location, "Generic type can not derive from Attribute");
- return null;
- }
-
if (IsGeneric) {
foreach (TypeParameter type_param in TypeParameters)
if (!type_param.Resolve (this)) {
error = true;
return null;
}
-
+
ModuleBuilder builder = CodeGen.ModuleBuilder;
TypeBuilder = builder.DefineType (
- Name, type_attributes, parent, ifaces);
+ Name, type_attributes, parent.Type, ifaces);
} else {
TypeBuilder builder = Parent.DefineType ();
return null;
TypeBuilder = builder.DefineNestedType (
- Basename, type_attributes, parent, ifaces);
+ Basename, type_attributes, parent.Type, ifaces);
}
if (IsGeneric) {
type_param.Define (TypeBuilder);
}
+ ConstructedType constructed = parent as ConstructedType;
+ if (constructed != null) {
+ Type ptype = constructed.ResolveType (ec);
+ if (ptype == null)
+ return null;
+
+ TypeBuilder.SetParent (ptype);
+ }
+
//
// Structs with no fields need to have at least one byte.
// The right thing would be to set the PackingSize in a DefineType
TypeManager.AddUserType (Name, TypeBuilder, this, ifaces);
- if ((parent != null) &&
- (parent == TypeManager.attribute_type ||
- parent.IsSubclassOf (TypeManager.attribute_type))) {
+ if ((parent != null) && (parent.Type != null) &&
+ (parent.Type == TypeManager.attribute_type ||
+ parent.Type.IsSubclassOf (TypeManager.attribute_type))) {
RootContext.RegisterAttribute (this);
TypeManager.RegisterAttrType (TypeBuilder, this);
} else