var mclass = try_get_mclass_by_name(nclassdef, mmodule, name)
if mclass == null then
+ if nclassdef isa AStdClassdef and nclassdef.n_kwredef != null then
+ error(nclassdef, "Redef error: No imported class {name} to refine.")
+ return
+ end
mclass = new MClass(mmodule, name, arity, mkind, mvisibility)
#print "new class {mclass}"
else if nclassdef isa AStdClassdef and nmodule.mclass2nclassdef.has_key(mclass) then
error(nfd, "Error: A formal parameter type `{ptname}' already exists")
return
end
+ for c in ptname do if c >= 'a' and c<= 'z' then
+ warning(nfd, "Warning: lowercase in the formal parameter type {ptname}")
+ break
+ end
names.add(ptname)
+ nfd.mtype = mclass.mclass_type.arguments[i].as(MParameterType)
end
# Revolve bound for formal parameter names
error(nfd, "Error: Formal parameter type `{names[i]}' bounded with a formal parameter type")
else
bounds.add(bound)
+ nfd.bound = bound
end
else if mclass.mclassdefs.is_empty then
# No bound, then implicitely bound by nullable Object
- bounds.add(objectclass.mclass_type.as_nullable)
+ var bound = objectclass.mclass_type.as_nullable
+ bounds.add(bound)
+ nfd.bound = bound
else
# Inherit the bound
- bounds.add(mclass.intro.bound_mtype.arguments[i])
+ var bound = mclass.intro.bound_mtype.arguments[i]
+ bounds.add(bound)
+ nfd.bound = bound
end
end
end
do
var mmodule = nmodule.mmodule.as(not null)
var objectclass = try_get_mclass_by_name(nmodule, mmodule, "Object")
+ var pointerclass = try_get_mclass_by_name(nmodule, mmodule, "Pointer")
var mclass = nclassdef.mclass.as(not null)
var mclassdef = nclassdef.mclassdef.as(not null)
#print "new super : {mclass} < {mtype}"
end
end
- if specobject and mclass.name != "Object" and objectclass != null and mclassdef.is_intro then
- supertypes.add objectclass.mclass_type
+ if specobject and mclassdef.is_intro then
+ if mclass.kind == extern_kind then
+ if mclass.name == "Pointer" then
+ supertypes.add objectclass.mclass_type
+ else
+ supertypes.add pointerclass.mclass_type
+ end
+ else if mclass.name != "Object" and objectclass != null then
+ supertypes.add objectclass.mclass_type
+ end
end
mclassdef.set_supertypes(supertypes)
redef fun mkind do return extern_kind
end
+redef class AFormaldef
+ # The associated parameter type
+ var mtype: nullable MParameterType = null
+
+ # The associated bound
+ var bound: nullable MType = null
+end
+
redef class AType
# The mtype associated to the node
var mtype: nullable MType = null