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

@proxy doesn't work anymore #32358

Closed
Hixie opened this issue Feb 28, 2018 · 8 comments
Closed

@proxy doesn't work anymore #32358

Hixie opened this issue Feb 28, 2018 · 8 comments
Labels
closed-as-intended Closed as the reported issue is expected behavior

Comments

@Hixie
Copy link
Contributor

Hixie commented Feb 28, 2018

I have a class called Json that implements noSuchMethod so that you can write code like data.foo.bar.baz to dereference through JSON objects. It worked fine in the past, but now it gives tons of analyzer warnings.

@matanlurey matanlurey added the closed-as-intended Closed as the reported issue is expected behavior label Feb 28, 2018
@matanlurey
Copy link
Contributor

Proxy has been removed in Dart2: #32251

See this commit from @lrhn with details: eaf4921

@matanlurey
Copy link
Contributor

A bit more information: #30220

@Hixie
Copy link
Contributor Author

Hixie commented Feb 28, 2018

Ok but that's a non-starter. It breaks this code in an irrecoverable way.

@matanlurey
Copy link
Contributor

Lots of Dart2 breaks code in a an irrecoverable way.

You may want to setup a meeting with @leafpetersen to discuss this further, this change has already been implemented, decided, and landed (and I don't think we plan to change it).

@Hixie
Copy link
Contributor Author

Hixie commented Feb 28, 2018

ok, will do when I get back in the office. In the meantime I'll file a feature request.

@leafpetersen
Copy link
Member

You can still use the "NSM implements everything" path if you type things as dynamic, but the most basic property we're aiming for in Dart 2 is that if you say something has static type Widget, the Widget methods are there. You can make a class which implements Widget, and use NSM to automatically implement all of the methods, but you can't make a class that implements everything everywhere.

I do think we want a feature here to replace this. It might looks something like having some way to specify a static type which means "Treat this like a Widget for method call analysis, but do dynamic lookup on everything and don't allow it to be assigned to real Widgets". Or it might look like some kind of delegation feature. Or it might look like some kind of drop in extension method feature. Or something else?

We're definitely interested in hearing about use cases.

cc @lrhn

@lrhn
Copy link
Member

lrhn commented Feb 28, 2018

The use case here is an object that responds to any message, but doesn't try to implement any interface. It's a non-dynamic type with dynamic dispatch. That is one use-case for proxy, but it's also a use-case that can be handled by dynamic itself, so it's not essential. It's not really a property of the object, it's a property of the way it's called, and floating it around like an implicitly inherited annotation isn't making that very clear.
Replacing the Json type with dynamic everywhere (writing it explicitly to avoid inferring Json) should make the program work again.

@leafpetersen
Copy link
Member

Moving further comments over to #32360.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-as-intended Closed as the reported issue is expected behavior
Projects
None yet
Development

No branches or pull requests

4 participants