Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sub-class methods to make superclass method parameters optional. #2824

Closed
lrhn opened this issue Apr 30, 2012 · 2 comments
Closed

Allow sub-class methods to make superclass method parameters optional. #2824

lrhn opened this issue Apr 30, 2012 · 2 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented Apr 30, 2012

If you have a class A:
 class A{
  foo(int a, int b) {}
 }
please make it possible to specialize this by making some parameters optional, e.g.:
 class B extends A {
  foo(int a, [int bar]) {}
 }
(ditto for interfaces).

This is a safe generalization of the superclass interface, since all calls to the superclass method are still valid for the subclass.

It also allows a unified implementation of different interfaces, e.g.,
  interface I {
    foo(int a, int b);
  }
  interface J {
    foo(String v);
  }
  class Unifier implements I,J {
    foo(Object x, [int bar]) {]
  }
This is currently not possible, because for one function type to be a subtype of another, they need to have the same number of non-optional arguments.

@DartBot
Copy link

DartBot commented Apr 30, 2012

This comment was originally written by @seaneagan


this should be merged with issue #1827 or issue #2706

@gbracha
Copy link
Contributor

gbracha commented May 8, 2012

Added Duplicate label.
Marked as being merged into #2706.

@lrhn lrhn added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels May 8, 2012
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants