You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6130 Reporter: gerd Status: acknowledged (set by @damiendoligez on 2013-08-19T17:13:31Z) Resolution: open Priority: normal Severity: feature Version: 4.00.1 Category: typing Monitored by:@lpw25@hcarty
Bug description
Currently, this does not work:
class type x = object
method p : [ `P ] -> unit
(* many more methods *)
end
class type y = object
inherit x
method p : [ `P | `Q ] -> unit
end
The suggestion is to allow that method types can be subtypes of the inherited types (maybe requiring method! syntax).
Additional information
This would be extremely helpful, because in some situations there is no easy workaround, especially if the definition of x is not in my own code base.
As classes allow method overriding with subtypes, permitting the same for class types would also be good for the symmetry in the language.
The text was updated successfully, but these errors were encountered:
This is a long standing request.
There are 3 reasons it was not implemented:
since ocaml allows to use the "type of self", ensuring the soundness of this feature can be tricky.
(This looks ok, but I think nobody has proved that formally yet)
this requires important changes in the type inference of classes: currently, the typing of inheritance just uses unification, which is not compatible with subtyping
to preserve backward compatibility, all such methods would have to be explicitly annotated, so it would be a bit heavy to use
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.
Original bug ID: 6130
Reporter: gerd
Status: acknowledged (set by @damiendoligez on 2013-08-19T17:13:31Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.00.1
Category: typing
Monitored by: @lpw25 @hcarty
Bug description
Currently, this does not work:
The suggestion is to allow that method types can be subtypes of the inherited types (maybe requiring method! syntax).
Additional information
This would be extremely helpful, because in some situations there is no easy workaround, especially if the definition of x is not in my own code base.
As classes allow method overriding with subtypes, permitting the same for class types would also be good for the symmetry in the language.
The text was updated successfully, but these errors were encountered: