return false
end
end
+
+ if closures.length != s.closures.length then return false
+ for i in [0..closures.length[ do
+ if not s.closures[i] < closures[i] then return false
+ end
return true
end
redef meth to_s
do
- var s: String
+ var s = new Buffer
if _params != null and _params.length > 0 then
var tmp: String
var a = new Array[String].with_capacity(_params.length)
#a.add("{pn}: {p}")
a.add(p.to_s)
end
- s = "({a.join(",")})"
- else
- s = ""
+ s.append("({a.join(",")})")
end
if _return_type != null then
s.append(": {_return_type}")
end
- return s
+ return s.to_s
end
# Adapt the signature to a different receiver
return self
end
end
+
+ meth <(c: MMClosure): Bool
+ do
+ if c.is_optional and not is_optional then return false
+ if not c.is_break and is_break then return false
+ return c.signature < signature
+ end
end
# Inheritance relation between two types
# Adapt self to another local class context
# Useful for genericity
+ # 'c' Must be a super-class of self
+ # Example:
+ # class A[E]
+ # class B[F] special A[F]
+ # class C[G] special B[String]
+ # class D special C[Float]
+ # 'A[Int]'.upcast_for('A') -> 'A[Int]'
+ # 'A[Int]'.upcast_for('B') -> abort
+ # 'B[Int]'.upcast_for('B') -> 'B[Int]'
+ # 'B[Int]'.upcast_for('A') -> 'A[Int]'
+ # 'B[Int]'.upcast_for('C') -> abort
+ # 'C[Int]'.upcast_for('C') -> 'C[Int]'
+ # 'C[Int]'.upcast_for('B') -> 'B[String]'
+ # 'C[Int]'.upcast_for('A') -> 'A[String]'
+ # 'D'.upcast_for('D') -> 'D'
+ # 'D'.upcast_for('C') -> 'C[Float]'
+ # 'D'.upcast_for('B') -> 'C[String]'
+ # 'D'.upcast_for('A') -> 'A[String]'
meth upcast_for(c: MMLocalClass): MMType is abstract
# Return a type approximation if the reveiver is not self
# The type of null
class MMTypeNone
special MMType
- redef readable attr _module: MMModule
- redef meth <(t) do return true
- redef meth is_supertype(t) do return false
- redef meth local_class do abort
- redef meth upcast_for(c) do return self
+ redef readable attr _module: MMModule
+ redef meth <(t) do return true
+ redef meth to_s do return "null"
+ redef meth is_supertype(t) do return false
+ redef meth local_class do abort
+ redef meth upcast_for(c) do abort
private init(m: MMModule) do _module = m
end