The `-w` option takes the name of a warning (displayed at the end of message, between parentheses) to activate it; and "no-{name}" to disable it. It has precedence over -q and -W.
To show only missing-doc warnings in standard
~~~sh
$ nitg -q -w missing-doc standard
~~~
To show all warnings and advices, except missing-doc
~~~sh
$ nitg -W -w no-missing-doc standard
~~~
To show standard warnings except useless-type-test, but not advice except missing-doc
~~~sh
$ nitg -w missing-doc -w no-useless-type-test standard
~~~
Pull-Request: #790
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
# A simple wall clock with 60 minutes and 12 hours.
class Clock
# total number of minutes from 0 to 719
- var total_minutes: Int
+ var total_minutes: Int is noinit
# Note: only the read acces is public, the write access is private.
# number of minutes in the current hour (from 0 to 59)
redef fun to_s do return "{hours}:{minutes}"
- fun reset(hours, minutes: Int) do self.total_minutes = hours*60 + minutes
-
- init(hours, minutes: Int) do self.reset(hours, minutes)
+ fun reset(hours, minutes: Int) is autoinit do self.total_minutes = hours*60 + minutes
redef fun ==(o)
do
end
# MapRead are abstract associative collections: `key` -> `item`.
-interface MapRead[K: Object, E]
+interface MapRead[K: Object, V]
# Get the item at `key`
#
# var x = new HashMap[String, Int]
#
# If the key is not in the map, `provide_default_value` is called (that aborts by default)
# See `get_or_null` and `get_or_default` for safe variations.
- fun [](key: K): E is abstract
+ fun [](key: K): V is abstract
# Get the item at `key` or null if `key` is not in the map.
#
# assert x.get_or_null("four") == 4
# assert x.get_or_null("five") == null
#
- # Note: use `has_key` and `[]` if you need the distinction bewteen a key associated with null, and no key.
- fun get_or_null(key: K): nullable E
+ # Note: use `has_key` and `[]` if you need the distinction between a key associated with null, and no key.
+ fun get_or_null(key: K): nullable V
do
if has_key(key) then return self[key]
return null
# assert x.get_or_default("four", 40) == 4
# assert x.get_or_default("five", 50) == 50
#
- fun get_or_default(key: K, default: E): E
+ fun get_or_default(key: K, default: V): V
do
if has_key(key) then return self[key]
return default
end
- # Depreciated alias for `keys.has`
+ # Alias for `keys.has`
fun has_key(key: K): Bool do return self.keys.has(key)
# Get a new iterator on the map.
- fun iterator: MapIterator[K, E] is abstract
+ fun iterator: MapIterator[K, V] is abstract
# Return the point of view of self on the values only.
# Note that `self` and `values` are views on the same data;
# x["four"] = 4
# assert x.values.has(4) == true
# assert x.values.has(5) == false
- fun values: Collection[E] is abstract
+ fun values: Collection[V] is abstract
# Return the point of view of self on the keys only.
# Note that `self` and `keys` are views on the same data;
#
# Note: the value is returned *as is*, implementations may want to store the value in the map before returning it
# @toimplement
- protected fun provide_default_value(key: K): E do abort
+ protected fun provide_default_value(key: K): V do abort
end
# Maps are associative collections: `key` -> `item`.
# assert map.values.has(1) == true
# assert map.values.has(3) == false
#
-interface Map[K: Object, E]
- super MapRead[K, E]
+interface Map[K: Object, V]
+ super MapRead[K, V]
# Set the `value` at `key`.
#
# x["four"] = 4
# assert x["four"] == 4
#
- # If the key was associated with a value, this old value is discarted
+ # If the key was associated with a value, this old value is discarded
# and replaced with the new one.
#
# x["four"] = 40
# assert x["four"] == 40
# assert x.values.has(4) == false
#
- fun []=(key: K, value: E) is abstract
+ fun []=(key: K, value: V) is abstract
# Add each (key,value) of `map` into `self`.
# If a same key exists in `map` and `self`, then the value in self is discarded.
# assert x["four"] == 40
# assert x["five"] == 5
# assert x["nine"] == 90
- fun recover_with(map: Map[K, E])
+ fun recover_with(map: MapRead[K, V])
do
var i = map.iterator
while i.is_ok do
# ENSURE `is_empty`
fun clear is abstract
- redef fun values: RemovableCollection[E] is abstract
+ redef fun values: RemovableCollection[V] is abstract
redef fun keys: RemovableCollection[K] is abstract
end
# Iterators for Map.
-interface MapIterator[K: Object, E]
+interface MapIterator[K: Object, V]
# The current item.
# Require `is_ok`.
- fun item: E is abstract
+ fun item: V is abstract
# The key of the current item.
# Require `is_ok`.
# Associative arrays that internally uses couples to represent each (key, value) pairs.
# This is an helper class that some specific implementation of Map may implements.
-interface CoupleMap[K: Object, E]
- super Map[K, E]
+interface CoupleMap[K: Object, V]
+ super Map[K, V]
# Return the couple of the corresponding key
# Return null if the key is no associated element
- protected fun couple_at(key: K): nullable Couple[K, E] is abstract
+ protected fun couple_at(key: K): nullable Couple[K, V] is abstract
# Return a new iteralot on all couples
# Used to provide `iterator` and others
- protected fun couple_iterator: Iterator[Couple[K,E]] is abstract
+ protected fun couple_iterator: Iterator[Couple[K,V]] is abstract
- redef fun iterator do return new CoupleMapIterator[K,E](couple_iterator)
+ redef fun iterator do return new CoupleMapIterator[K,V](couple_iterator)
redef fun [](key)
do
# Iterator on CoupleMap
#
# Actually it is a wrapper around an iterator of the internal array of the map.
-private class CoupleMapIterator[K: Object, E]
- super MapIterator[K, E]
+private class CoupleMapIterator[K: Object, V]
+ super MapIterator[K, V]
redef fun item do return _iter.item.second
#redef fun item=(e) do _iter.item.second = e
_iter.next
end
- private var iter: Iterator[Couple[K,E]]
+ private var iter: Iterator[Couple[K,V]]
- init(i: Iterator[Couple[K,E]]) do _iter = i
+ init(i: Iterator[Couple[K,V]]) do _iter = i
end
# Some tools ###################################################################
# See the License for the specific language governing permissions and
# limitations under the License.
-# Check missing signed-off-by in commits
+# Check missing "This file is part of NIT…" comment in committed scripts.
if test "$#" -lt 2; then
echo "Usage: checklicense from to"
git diff --name-status $from..$to -- "*.nit" "*.sh" | sed -n 's/^A\s*//p' > checklicense_new_files.out
test -s checklicense_new_files.out || exit 0
-grep -L 'his file is part of NIT' `cat checklicense_new_files.out` 2>/dev/null | tee checklicense_missing.out
+grep -L '\(^\|\b\)# [Tt]his file is part of NIT ' `cat checklicense_new_files.out` 2>/dev/null | tee checklicense_missing.out
test \! -s checklicense_missing.out
var outname = outfile(mainmodule)
- var orig_dir=".." # FIXME only works if `compile_dir` is a subdirectory of cwd
+ var orig_dir = compile_dir.relpath(".")
var outpath = orig_dir.join_path(outname).simplify_path
var makename = makefile_name(mainmodule)
var makepath = "{compile_dir}/{makename}"
if not initializers.is_empty then
var recv = arguments.first
- assert initializers.length == arguments.length - 1 else debug("expected {initializers.length}, got {arguments.length - 1}")
var i = 1
for p in initializers do
if p isa MMethod then
- self.send(p, [recv, arguments[i]])
+ var args = [recv]
+ for x in p.intro.msignature.mparameters do
+ args.add arguments[i]
+ i += 1
+ end
+ self.send(p, args)
else if p isa MAttribute then
self.write_attribute(p, recv, arguments[i])
+ i += 1
else abort
- i += 1
end
+ assert i == arguments.length
return self.send(callsite.mproperty, [recv])
end
redef fun calloc_array(ret_type, arguments)
do
var mclass = self.get_class("ArrayCapable")
- var ft = mclass.mclass_type.arguments.first.as(MParameterType)
+ var ft = mclass.mparameters.first
var res = self.native_array_instance(ft, arguments[1])
self.ret(res)
end
var tpl = new Template
if arity > 0 then
tpl.add "["
- tpl.add intro.parameter_names.join(", ")
+ var parameter_names = new Array[String]
+ for p in mparameters do
+ parameter_names.add(p.name)
+ end
+ tpl.add parameter_names.join(", ")
tpl.add "]"
end
return tpl
fun tpl_signature: Template do
var tpl = new Template
- if not parameter_names.is_empty then
+ var mparameters = mclass.mparameters
+ if not mparameters.is_empty then
tpl.add "["
- for i in [0..parameter_names.length[ do
- tpl.add "{parameter_names[i]}: "
+ for i in [0..mparameters.length[ do
+ tpl.add "{mparameters[i].name}: "
tpl.add bound_mtype.arguments[i].tpl_signature
- if i < parameter_names.length - 1 then tpl.add ", "
+ if i < mparameters.length - 1 then tpl.add ", "
end
tpl.add "]"
end
redef class MParameterType
redef fun tpl_link do
- var name = mclass.intro.parameter_names[rank]
return new TplLink.with_title("{mclass.nitdoc_url}#FT_{name}", name, "formal type")
end
redef fun tpl_signature do return tpl_link
noinit
readonly
writable
+autoinit
cached
nosuper
old_style_init
redef fun infobox(v)
do
var res = new HInfoBox(v, to_s)
- var name = mclass.intro.parameter_names[rank]
res.new_field("parameter type").append("{name} from class ").add mclass.intro.linkto
return res
end
redef fun linkto
do
- var name = mclass.intro.parameter_names[rank]
return (new HTMLTag("span")).text(name)
end
end
do
var initializers = callsite.mpropdef.initializers
if not initializers.is_empty then
- assert initializers.length == arguments.length - 1 else debug("expected {initializers.length} got {arguments.length - 1}")
var recv = arguments.first
var i = 1
for p in initializers do
if p isa MMethod then
- self.send(p, [recv, arguments[i]])
+ var args = [recv]
+ for x in p.intro.msignature.mparameters do
+ args.add arguments[i]
+ i += 1
+ end
+ self.send(p, args)
else if p isa MAttribute then
assert recv isa MutableInstance
recv.attributes[p] = arguments[i]
+ i += 1
else abort
- i += 1
end
+ assert i == arguments.length
+
return send(callsite.mproperty, [recv])
end
return send(callsite.mproperty, arguments)
var cla = self.model.get_mclasses_by_name(name)
if cla == null then
if name == "Bool" then
- var c = new MClass(self, name, 0, enum_kind, public_visibility)
- var cladef = new MClassDef(self, c.mclass_type, new Location(null, 0,0,0,0), new Array[String])
+ var c = new MClass(self, name, null, enum_kind, public_visibility)
+ var cladef = new MClassDef(self, c.mclass_type, new Location(null, 0,0,0,0))
return c
end
print("Fatal Error: no primitive class {name}")
# 0 if the class is not generic
var arity: Int
+ # Each generic formal parameters in order.
+ # is empty if the class is not generic
+ var mparameters = new Array[MParameterType]
+
# The kind of the class (interface, abstract class, etc.)
# In Nit, the kind of a class cannot evolve in refinements
var kind: MClassKind
# In Nit, the visibility of a class cannot evolve in refinements
var visibility: MVisibility
- init(intro_mmodule: MModule, name: String, arity: Int, kind: MClassKind, visibility: MVisibility)
+ init(intro_mmodule: MModule, name: String, parameter_names: nullable Array[String], kind: MClassKind, visibility: MVisibility)
do
self.intro_mmodule = intro_mmodule
self.name = name
- self.arity = arity
+ if parameter_names == null then
+ self.arity = 0
+ else
+ self.arity = parameter_names.length
+ end
self.kind = kind
self.visibility = visibility
intro_mmodule.intro_mclasses.add(self)
# Create the formal parameter types
if arity > 0 then
+ assert parameter_names != null
var mparametertypes = new Array[MParameterType]
for i in [0..arity[ do
- var mparametertype = new MParameterType(self, i)
+ var mparametertype = new MParameterType(self, i, parameter_names[i])
mparametertypes.add(mparametertype)
end
+ self.mparameters = mparametertypes
var mclass_type = new MGenericType(self, mparametertypes)
self.mclass_type = mclass_type
self.get_mtype_cache.add(mclass_type)
# ENSURE: `bound_mtype.mclass == self.mclass`
var bound_mtype: MClassType
- # Name of each formal generic parameter (in order of declaration)
- var parameter_names: Array[String]
-
# The origin of the definition
var location: Location
# Example: "mymodule#MyClass"
redef var to_s: String
- init(mmodule: MModule, bound_mtype: MClassType, location: Location, parameter_names: Array[String])
+ init(mmodule: MModule, bound_mtype: MClassType, location: Location)
do
- assert bound_mtype.mclass.arity == parameter_names.length
self.bound_mtype = bound_mtype
self.mmodule = mmodule
self.mclass = bound_mtype.mclass
self.location = location
mmodule.mclassdefs.add(self)
mclass.mclassdefs.add(self)
- self.parameter_names = parameter_names
self.to_s = "{mmodule}#{mclass}"
end
# FIXME: is `position` a better name?
var rank: Int
- # Internal name of the parameter type
- # Names of parameter types changes in each class definition
- # Therefore, this method return an internal name.
- # Example: return "G#1" for the second parameter of the class G
- # FIXME: add a way to get the real name in a classdef
- redef fun to_s do return "{mclass}#{rank}"
+ redef var name
+
+ redef fun to_s do return name
# Resolve the bound for a given resolved_receiver
# The result may be a other virtual type (or a parameter type)
return mtype.collect_mclassdefs(mmodule).has(mclass.intro)
end
- init(mclass: MClass, rank: Int)
+ init(mclass: MClass, rank: Int, name: String)
do
self.mclass = mclass
self.rank = rank
+ self.name = name
end
end
# Get the list of all parameter types in 'self'.
fun parameter_types: Map[String, MType] do
var res = new HashMap[String, MType]
- for i in [0..intro.parameter_names.length[ do
- res[intro.parameter_names[i]] = intro.bound_mtype.arguments[i]
+ for p in mparameters do
+ res[p.name] = p
end
return res
end
var nvisibility: nullable AVisibility
var mvisibility: nullable MVisibility
var arity = 0
+ var names = new Array[String]
if nclassdef isa AStdClassdef then
name = nclassdef.n_id.text
nkind = nclassdef.n_classkind
error(nvisibility, "Error: intrude is not a legal visibility for classes.")
return
end
+ # Collect formal parameter names
+ for i in [0..arity[ do
+ var nfd = nclassdef.n_formaldefs[i]
+ var ptname = nfd.n_id.text
+ if names.has(ptname) then
+ error(nfd, "Error: A formal parameter type `{ptname}' already exists")
+ return
+ end
+ for c in ptname.chars do if c >= 'a' and c<= 'z' then
+ warning(nfd, "formal-type-name", "Warning: lowercase in the formal parameter type {ptname}")
+ break
+ end
+ names.add(ptname)
+ end
+
else if nclassdef isa ATopClassdef then
name = "Object"
nkind = null
error(nclassdef, "Redef error: No imported class {name} to refine.")
return
end
- mclass = new MClass(mmodule, name, arity, mkind, mvisibility)
+ mclass = new MClass(mmodule, name, names, mkind, mvisibility)
#print "new class {mclass}"
else if nclassdef isa AStdClassdef and nmodule.mclass2nclassdef.has_key(mclass) then
error(nclassdef, "Error: A class {name} is already defined at line {nmodule.mclass2nclassdef[mclass].location.line_start}.")
else if nclassdef isa AStdClassdef and nclassdef.n_kwredef == null then
error(nclassdef, "Redef error: {name} is an imported class. Add the redef keyword to refine it.")
return
- else if mclass.arity != arity then
+ else if arity != 0 and mclass.arity != arity then
error(nclassdef, "Redef error: Formal parameter arity missmatch; got {arity}, expected {mclass.arity}.")
return
else if nkind != null and mkind != concrete_kind and mclass.kind != mkind then
return
end
- var names = new Array[String]
var bounds = new Array[MType]
if nclassdef isa AStdClassdef and mclass.arity > 0 then
- # Collect formal parameter names
+ # Revolve bound for formal parameters
for i in [0..mclass.arity[ do
- var nfd = nclassdef.n_formaldefs[i]
- var ptname = nfd.n_id.text
- if names.has(ptname) then
- error(nfd, "Error: A formal parameter type `{ptname}' already exists")
- return
- end
- for c in ptname.chars do if c >= 'a' and c<= 'z' then
- warning(nfd, "formal-type-name", "Warning: lowercase in the formal parameter type {ptname}")
- break
+ if nclassdef.n_formaldefs.is_empty then
+ # Inherit the bound
+ var bound = mclass.intro.bound_mtype.arguments[i]
+ bounds.add(bound)
+ continue
end
- names.add(ptname)
- nfd.mtype = mclass.mclass_type.arguments[i].as(MParameterType)
- end
- # Revolve bound for formal parameter names
- for i in [0..mclass.arity[ do
var nfd = nclassdef.n_formaldefs[i]
+ var pname = mclass.mparameters[i].name
+ if nfd.n_id.text != pname then
+ error(nfd.n_id, "Error: Formal parameter type #{i} `{nfd.n_id.text}` must be named `{pname}' as in the original definition in module `{mclass.intro.mmodule}`.")
+ end
var nfdt = nfd.n_type
if nfdt != null then
var bound = resolve_mtype_unchecked(mmodule, null, nfdt, false)
if bound == null then return # Forward error
if bound.need_anchor then
# No F-bounds!
- error(nfd, "Error: Formal parameter type `{names[i]}' bounded with a formal parameter type")
+ error(nfd, "Error: Formal parameter type `{pname}' bounded with a formal parameter type")
else
bounds.add(bound)
nfd.bound = bound
end
var bound_mtype = mclass.get_mtype(bounds)
- var mclassdef = new MClassDef(mmodule, bound_mtype, nclassdef.location, names)
+ var mclassdef = new MClassDef(mmodule, bound_mtype, nclassdef.location)
nclassdef.mclassdef = mclassdef
self.mclassdef2nclassdef[mclassdef] = nclassdef
end
# Check parameter type
- if mclassdef != null and mclassdef.parameter_names.has(name) then
- if not ntype.n_types.is_empty then
- error(ntype, "Type error: formal type {name} cannot have formal parameters.")
- end
- for i in [0..mclassdef.parameter_names.length[ do
- if mclassdef.parameter_names[i] == name then
- res = mclassdef.mclass.mclass_type.arguments[i]
- if ntype.n_kwnullable != null then res = res.as_nullable
- ntype.mtype = res
- return res
+ if mclassdef != null then
+ for p in mclassdef.mclass.mparameters do
+ if p.name != name then continue
+
+ if not ntype.n_types.is_empty then
+ error(ntype, "Type error: formal type {name} cannot have formal parameters.")
end
+
+ res = p
+ if ntype.n_kwnullable != null then res = res.as_nullable
+ ntype.mtype = res
+ return res
end
- abort
end
# Check class
# Collect undefined attributes
var mparameters = new Array[MParameter]
var initializers = new Array[MProperty]
- var anode: nullable ANode = null
for npropdef in nclassdef.n_propdefs do
+ if npropdef isa AMethPropdef then
+ if npropdef.mpropdef == null then return # Skip broken attribute
+ var at = npropdef.get_single_annotation("autoinit", self)
+ if at == null then continue # Skip non tagged init
+
+ var sig = npropdef.mpropdef.msignature
+ if sig == null then continue # Skip broken method
+
+ if not npropdef.mpropdef.is_intro then
+ self.error(at, "Error: `autoinit` cannot be set on redefinitions")
+ continue
+ end
+
+ for param in sig.mparameters do
+ var ret_type = param.mtype
+ var mparameter = new MParameter(param.name, ret_type, false)
+ mparameters.add(mparameter)
+ end
+ initializers.add(npropdef.mpropdef.mproperty)
+ end
if npropdef isa AAttrPropdef then
if npropdef.mpropdef == null then return # Skip broken attribute
var at = npropdef.get_single_annotation("noinit", self)
# Add the setter to the list
initializers.add(msetter.mproperty)
end
- if anode == null then anode = npropdef
end
end
- if anode == null then anode = nclassdef
if the_root_init_mmethod == null then return
private fun mclass_node(mclass: MClass): NeoNode do
var node = make_node(mclass)
node.labels.add "MClass"
- node["arity"] = mclass.arity
node["full_name"] = mclass.full_name
node["kind"] = mclass.kind.to_s
node["visibility"] = mclass.visibility.to_s
+ if not mclass.mparameters.is_empty then
+ var parameter_names = new Array[String]
+ for p in mclass.mparameters do parameter_names.add(p.name)
+ node["parameter_names"] = new JsonArray.from(parameter_names)
+ end
node.out_edges.add(new NeoEdge(node, "CLASSTYPE", to_node(mclass.mclass_type)))
return node
end
assert node.labels.has("MClass")
var mmodule = to_mmodule(model, node.in_nodes("INTRODUCES").first)
var name = node["name"].to_s
- var arity = node["arity"].to_s.to_i
var kind = to_kind(node["kind"].to_s)
var visibility = to_visibility(node["visibility"].to_s)
- var mclass = new MClass(mmodule, name, arity, kind, visibility)
+ var parameter_names = new Array[String]
+ if node.has_key("parameter_names") then
+ for e in node["parameter_names"].as(JsonArray) do
+ parameter_names.add e.to_s
+ end
+ end
+ var mclass = new MClass(mmodule, name, parameter_names, kind, visibility)
mentities[node] = mclass
set_doc(node, mclass)
return mclass
node.labels.add "MClassDef"
node["is_intro"] = mclassdef.is_intro
node["location"] = mclassdef.location.to_s
- if not mclassdef.parameter_names.is_empty then
- node["parameter_names"] = new JsonArray.from(mclassdef.parameter_names)
- end
node.out_edges.add(new NeoEdge(node, "BOUNDTYPE", to_node(mclassdef.bound_mtype)))
node.out_edges.add(new NeoEdge(node, "MCLASS", to_node(mclassdef.mclass)))
for mproperty in mclassdef.intro_mproperties do
var mmodule = to_mmodule(model, node.in_nodes("DEFINES").first)
var mtype = to_mtype(model, node.out_nodes("BOUNDTYPE").first).as(MClassType)
var location = to_location(node["location"].to_s)
- var parameter_names = new Array[String]
- if node.has_key("parameter_names") then
- for e in node["parameter_names"].as(JsonArray) do
- parameter_names.add e.to_s
- end
- end
- var mclassdef = new MClassDef(mmodule, mtype, location, parameter_names)
+ var mclassdef = new MClassDef(mmodule, mtype, location)
mentities[node] = mclassdef
set_doc(node, mclassdef)
var supertypes = new Array[MClassType]
else if node.labels.has("MParameterType") then
var mclass = to_mclass(model, node.out_nodes("CLASS").first)
var rank = node["rank"].to_s.to_i
- var mtype = new MParameterType(mclass, rank)
+ var mtype = mclass.mparameters[rank]
mentities[node] = mtype
return mtype
else if node.labels.has("MNullableType") then
var res = new FlatBuffer
if arity > 0 then
res.append("[")
- for i in [0..intro.parameter_names.length[ do
- res.append(intro.parameter_names[i])
- if i < intro.parameter_names.length - 1 then res.append(", ")
+ for i in [0..mparameters.length[ do
+ res.append(mparameters[i].name)
+ if i < mparameters.length - 1 then res.append(", ")
end
res.append("]")
end
end
redef class MParameterType
- redef fun to_console do return mclass.intro.parameter_names[rank]
+ redef fun to_console do return name
end
redef class MVirtualType
end
if arity > 0 then
t.add "["
- var formal = intro.parameter_names
- t.add formal.first
- for i in [1 .. formal.length[ do
+ t.add mparameters.first.name
+ for i in [1 .. mparameters.length[ do
t.add ", "
- t.add formal[i]
+ t.add mparameters[i].name
end
t.add "]"
end
redef class MParameterType
redef fun tpl_class(c, m) do
- var n = mclass.intro.parameter_names
- return n[rank]
+ return name
end
end
end
if mclass.arity > 0 then
t.add "["
- var formal = mclass.intro.parameter_names
- t.add formal.first
- for i in [1 .. formal.length[ do
+ var mparameters = mclass.mparameters
+ t.add mparameters.first.name
+ for i in [1 .. mparameters.length[ do
t.add ", "
- t.add formal[i]
+ t.add mparameters[i].name
end
t.add "]"
end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import base_gen2
+
+redef class B[E] #alt1# redef class B #alt2# redef class B[X] #alt3# redef class B[E,X]
+ fun output2 do e2.output
+ fun e2: E do return e
+ #alt2#fun e3: X do return e
+end
+
+var b = new B[Int](2)
+b.output2
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+class A
+ fun toto(i: Int) is autoinit do
+ 'A'.output
+ 'o'.output
+ i.output
+ end
+
+ fun tata is autoinit do
+ 'A'.output
+ 'a'.output
+ '\n'.output
+ end
+
+ init do
+ 'A'.output
+ '\n'.output
+ end
+end
+
+class B
+ super A
+ fun tutu=(j: Int) is autoinit do
+ # no super here!
+ 'B'.output
+ 'u'.output
+ j.output
+ end
+
+ redef fun toto(i)
+ do
+ super
+ 'B'.output
+ 'o'.output
+ i.output
+ end
+
+ redef fun tata do #alt1#redef fun tata is autoinit do
+ 'B'.output
+ 'a'.output
+ '\n'.output
+ end
+
+ init do
+ 'B'.output
+ '\n'.output
+ end
+end
+
+class C
+ super A
+ fun tete(k,l: Int) is autoinit do
+ 'C'.output
+ 'e'.output
+ k.output
+ l.output
+ end
+end
+
+var a = new A(1)
+
+'\n'.output
+
+var b = new B(10,20)
+
+'\n'.output
+
+var c = new C(100,200,300)
-base_as_notnull2.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
-base_as_notnull2.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+base_as_notnull2.nit:30,12--25: Warning: expression is already not null, since it is a `E: Object`.
+base_as_notnull2.nit:50,12--25: Warning: expression is already not null, since it is a `E: Object`.
1
1
2
-alt/base_as_notnull2_alt1.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
-alt/base_as_notnull2_alt1.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt1.nit:30,12--25: Warning: expression is already not null, since it is a `E: Object`.
+alt/base_as_notnull2_alt1.nit:50,12--25: Warning: expression is already not null, since it is a `E: Object`.
alt/base_as_notnull2_alt1.nit:58,7--10: Type error: expected Object, got null
-alt/base_as_notnull2_alt2.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
-alt/base_as_notnull2_alt2.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt2.nit:30,12--25: Warning: expression is already not null, since it is a `E: Object`.
+alt/base_as_notnull2_alt2.nit:50,12--25: Warning: expression is already not null, since it is a `E: Object`.
Runtime error: Cast failed (alt/base_as_notnull2_alt2.nit:40)
1
1
-alt/base_as_notnull2_alt3.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
-alt/base_as_notnull2_alt3.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt3.nit:30,12--25: Warning: expression is already not null, since it is a `E: Object`.
+alt/base_as_notnull2_alt3.nit:50,12--25: Warning: expression is already not null, since it is a `E: Object`.
alt/base_as_notnull2_alt3.nit:64,7--10: Type error: expected Int, got null
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_autocast_alt1.nit:22)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_autocast_alt1.nit:22)
1
2
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_covar_gen_1alt1_alt1.nit:19)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_covar_gen_1alt1_alt1.nit:19)
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_covar_gen_1alt1_alt2.nit:18)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_covar_gen_1alt1_alt2.nit:18)
-Runtime error: Cast failed. Expected `G#0`, got `G[Object]` (alt/base_covar_gen_alt3.nit:19)
+Runtime error: Cast failed. Expected `E`, got `G[Object]` (alt/base_covar_gen_alt3.nit:19)
-Runtime error: Cast failed. Expected `G#0`, got `G[Object]` (alt/base_covar_gen_alt4.nit:18)
+Runtime error: Cast failed. Expected `E`, got `G[Object]` (alt/base_covar_gen_alt4.nit:18)
-alt/base_gen_bound_alt1.nit:31,10: Type error: expected B, got H#0
+alt/base_gen_bound_alt1.nit:31,10: Type error: expected B, got F
-alt/base_gen_bound_alt2.nit:32,11: Type error: expected B, got H#0
+alt/base_gen_bound_alt2.nit:32,11: Type error: expected B, got F
-alt/base_gen_bound_alt3.nit:33,11: Type error: expected B, got H#0
+alt/base_gen_bound_alt3.nit:33,11: Type error: expected B, got F
-alt/base_gen_bound_alt4.nit:34,13: Type error: expected B, got H#0
+alt/base_gen_bound_alt4.nit:34,13: Type error: expected B, got F
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_gen_reassign_alt1.nit:23)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_gen_reassign_alt1.nit:23)
11
21
31
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_gen_reassign_alt2.nit:23)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_gen_reassign_alt2.nit:23)
11
21
31
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_gen_reassign_alt4.nit:23)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_gen_reassign_alt4.nit:23)
11
21
31
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_gen_reassign_alt5.nit:23)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_gen_reassign_alt5.nit:23)
11
21
31
-Runtime error: Cast failed. Expected `G#0`, got `Int` (alt/base_gen_reassign_alt6.nit:23)
+Runtime error: Cast failed. Expected `E`, got `Int` (alt/base_gen_reassign_alt6.nit:23)
11
21
31
--- /dev/null
+alt/base_gen_redef_alt2.nit:17,15: Error: Formal parameter type #0 `X` must be named `E' as in the original definition in module `base_gen2`.
--- /dev/null
+alt/base_gen_redef_alt3.nit:17,13: Redef error: Formal parameter arity missmatch; got 2, expected 1.
-Runtime error: Cast failed. Expected `G#0`, got `B` (alt/base_gen_variance2_alt1.nit:27)
+Runtime error: Cast failed. Expected `E`, got `B` (alt/base_gen_variance2_alt1.nit:27)
3
-Runtime error: Cast failed. Expected `G#0`, got `D` (alt/base_gen_variance2_alt2.nit:27)
+Runtime error: Cast failed. Expected `E`, got `D` (alt/base_gen_variance2_alt2.nit:27)
3
-Runtime error: Cast failed. Expected `G#0`, got `D` (alt/base_gen_variance3_alt1.nit:27)
+Runtime error: Cast failed. Expected `E`, got `D` (alt/base_gen_variance3_alt1.nit:27)
2
-Runtime error: Cast failed. Expected `nullable G#0`, got `C` (alt/base_gen_variance_alt3.nit:18)
+Runtime error: Cast failed. Expected `nullable E`, got `C` (alt/base_gen_variance_alt3.nit:18)
2
20
2
-Runtime error: Cast failed. Expected `nullable G#0`, got `G[C]` (alt/base_gen_variance_alt6.nit:18)
+Runtime error: Cast failed. Expected `nullable E`, got `G[C]` (alt/base_gen_variance_alt6.nit:18)
2
20
2
-Runtime error: Cast failed. Expected `nullable G#0`, got `G[A]` (alt/base_gen_variance_alt8.nit:18)
+Runtime error: Cast failed. Expected `nullable E`, got `G[A]` (alt/base_gen_variance_alt8.nit:18)
2
20
2
-Runtime error: Cast failed. Expected `G#0`, got `Char` (alt/base_gen_variance_int_alt1.nit:27)
+Runtime error: Cast failed. Expected `E`, got `Char` (alt/base_gen_variance_int_alt1.nit:27)
2
--- /dev/null
+Ao1
+Aa
+A
+
+Ao10
+Bo10
+Ba
+Bu20
+A
+B
+
+Ao100
+Aa
+Ce200
+300
+A
--- /dev/null
+alt/base_init_autoinit_alt1.nit:53,20--27: Error: `autoinit` cannot be set on redefinitions
-base_isa_vt_gen1.nit:30,10--34: Warning: Expression is already a Triple[A#0, A#1, V].
+base_isa_vt_gen1.nit:30,10--34: Warning: Expression is already a Triple[T, U, V].
base_isa_vt_gen1.nit:54,8--52: Warning: Expression is already a Triple[String, Int, nullable Object].
base_isa_vt_gen1.nit:57,8--46: Warning: Expression is already a Triple[String, String, String].
base_isa_vt_gen1.nit:60,8--48: Warning: Expression is already a Triple[String, String, B[String]].
-alt/error_class_generic_alt1.nit:17,13--17: Redef error: Formal parameter arity missmatch; got 0, expected 1.
+alt/error_class_generic_alt1.nit:25,8--12: Type error: 'Array' is a generic class.
-alt/error_class_generic_alt3.nit:19,13--17: Redef error: Formal parameter arity missmatch; got 2, expected 1.
+alt/error_class_generic_alt3.nit:19,29--34: Error: A formal parameter type `E' already exists
-alt/error_class_generic_alt6.nit:22,7--11: Redef error: Array is an imported class. Add the redef keyword to refine it.
+alt/error_class_generic_alt6.nit:22,23--28: Error: A formal parameter type `E' already exists
-error_inh_clash4.nit:15,7: Error: Incompatibles ancestors for A: Sequence[A#1], Sequence[A#0]
-error_inh_clash4.nit:15,7: Error: Incompatibles ancestors for A: SequenceRead[A#1], SequenceRead[A#0]
+error_inh_clash4.nit:15,7: Error: Incompatibles ancestors for A: Sequence[F], Sequence[E]
+error_inh_clash4.nit:15,7: Error: Incompatibles ancestors for A: SequenceRead[F], SequenceRead[E]
-test_multiconstraint_inh.nit:39,18--21: Redef Error: Wrong type for parameter `e'. found J, expected I[G#0] as in test_multiconstraint_inh#G#baz.
+test_multiconstraint_inh.nit:39,18--21: Redef Error: Wrong type for parameter `e'. found J, expected I[E] as in test_multiconstraint_inh#G#baz.
-Runtime error: Cast failed. Expected `NativeArray#0`, got `Bool` (../lib/standard/collection/array.nit:754)
+Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/standard/collection/array.nit:754)
NativeString
N
Nit
-test_paire.nit:45,7--10: Redef error: Pair is an imported class. Add the redef keyword to refine it.
-test_paire.nit:54,7--10: Redef error: Pair is an imported class. Add the redef keyword to refine it.
+test_paire.nit:45,27--39: Error: A formal parameter type `E' already exists
+test_paire.nit:54,20--25: Error: A formal parameter type `E' already exists
end
end
-class Pair[E: Comparable, E: Comparable]
+class Pair[E: Comparable, F: Comparable]
fun >(p: Pair[Comparable, Comparable]): Bool
do
end
end
-class Pair[E: Int, E: Int]
+class Pair[E: Int, F: Int]
fun sum: Int
do