model: MParameterType.resolve_for handle the case of primitive bounds
authorJean Privat <jean@pryen.org>
Thu, 24 Jul 2014 18:06:15 +0000 (14:06 -0400)
committerJean Privat <jean@pryen.org>
Thu, 24 Jul 2014 18:37:23 +0000 (14:37 -0400)
~~~
class G[E: Int]
   # Since Int cannot have sublclasses, E == Int
end
~~~

Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit

index 8f92a87..85aba5e 100644 (file)
@@ -1292,7 +1292,13 @@ class MParameterType
                #print "{class_name}: {self}/{mtype}/{anchor}?"
 
                if mtype isa MGenericType and mtype.mclass == self.mclass then
-                       return mtype.arguments[self.rank]
+                       var res = mtype.arguments[self.rank]
+                       if anchor != null and res.need_anchor then
+                               # Maybe the result can be resolved more if are bound to a final class
+                               var r2 = res.anchor_to(mmodule, anchor)
+                               if r2 isa MClassType and r2.mclass.kind == enum_kind then return r2
+                       end
+                       return res
                end
 
                # self is a parameter type of mtype (or of a super-class of mtype)