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

Methods should be able to override function-typed getters #15108

Closed
nex3 opened this issue Nov 16, 2013 · 5 comments
Closed

Methods should be able to override function-typed getters #15108

nex3 opened this issue Nov 16, 2013 · 5 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@nex3
Copy link
Member

nex3 commented Nov 16, 2013

Consider the following code:

    typedef void ZeroArgumentFunction();

    abstract class Parent {
      ZeroArgumentFunction get fn;
    }

    class Child extends Parent {
      void fn() => print("hello");
    }

Currently, this prints an error because [Child.fn] conflicts with [Parent.fn], despite the fact that "child.fn" will return a ZeroArgumentFunction.

This makes [ZoneSpecification] particularly difficult to work with, since it declares numerous getters that return functions.

@gbracha
Copy link
Contributor

gbracha commented Nov 16, 2013

We'll see what we can do in the future.


Set owner to @gbracha.
Added Accepted label.

@DartBot
Copy link

DartBot commented Nov 17, 2013

This comment was originally written by @seaneagan


This is a duplicate of issue #1616. The proposal there:

https://docs.google.com/document/d/1Y-ec5lID7P0lf0nhNtgwAdGagnDqQN0KDeEOOrBFMik/edit

suggests to actually make methods desugar to Function-typed getters, so that it is transparent when using mirrors. Otherwise people will try to invoke a method using:

objectMirror.invoke(#m, [...], {...});

and it won't work in the case that m is implemented as a Function-typed getter, unless ObjectMirror#invoke is made to support this.

Fortunately, ObjectMirror#getField already does the right thing by closurizing methods.

@DartBot
Copy link

DartBot commented Nov 18, 2013

This comment was originally written by @seaneagan


I filed issue #15138 for making this work with mirrors as well.

@lrhn
Copy link
Member

lrhn commented Dec 13, 2013

It's worth noting that it works at runtime.

That is:
  x.foo()
works whether x has a method named foo or a getter named foo that returns a function.

That means that this is the static type system getting in the way of something that the writer knows will work at runtime - something that Dart tries to avoid in general.

@nex3 nex3 added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Dec 13, 2013
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@lrhn
Copy link
Member

lrhn commented Jun 22, 2018

With the Dart 2 type system, this is definitely not viable.

@lrhn lrhn closed this as completed Jun 22, 2018
@lrhn lrhn added the closed-not-planned Closed as we don't intend to take action on the reported issue label Jun 22, 2018
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-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants