Navigation Menu

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

js_helper declares a class that appears to be abstract, but then instantiates it #16566

Closed
efortuna opened this issue Feb 5, 2014 · 4 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@efortuna
Copy link
Contributor

efortuna commented Feb 5, 2014

Error caught by the dart analyzer:

ERROR|STATIC_WARNING|FUNCTION_WITHOUT_CALL|/Users/efortuna/dart-git2/dart/sdk/lib/_internal/lib/js_helper.dart|2127|7|14|Concrete classes that implement Function must implement the method call()
ERROR|STATIC_WARNING|FUNCTION_WITHOUT_CALL|/Users/efortuna/dart-git2/dart/sdk/lib/_internal/lib/js_helper.dart|2132|7|12|Concrete classes that implement Function must implement the method call()

Basically we have a class defined like so:
class TearOffClosure extends Closure {
}

that doesn't define call(). However, if you mark it as abstract, you find that there are other spots in the code where we are instantiating TearOffClosure objects (?). I'm not tremendously familiar with the JShelper code, so I'm hoping someone more familiar with that corner of the codebase can tell me what the best fix is. (sra?)

filing for now under dart2js, even though the problem is the intersetion of dart2js, dart:html, and the analyzer.

@rakudrama
Copy link
Member

There is no way to fix this in the source.

class TearOffClosure is a magical implementation class. It is a concrete class and it does have a 'call' method, but call method is programatically defined in ways that cannot be expressed in Dart.

You can't add a definition of 'call' since TearOffClosure can implement any signature, and different instances will implement different signatures. The one you try to define will be wrong.

This is another case where if we want the benefits of dartanalyzer in this library we need a mechanism to tell dartanalyzer which parts have apparent errors and warnings as a consequence of low level implementation details.


cc @bwilkerson.

@kasperl
Copy link

kasperl commented Feb 7, 2014

Should we consider using external/patch to pull this (problematic) code in?

@rakudrama
Copy link
Member

At first sight it would seem that the 'call' method could be declared as 'external'.
However, there is no syntax for declaring a method that may have any signature.

TearOffClosure #­1 might implement
   void call([a = 0]);
TearOffClosure #­2 might implement
   bool call(b, {c: true});

There is no way to declare a call method that covers both possibilities:

class TearOffClosure implements Closure {
  external call( ?? what goes here?? );
}

Even if we could express combined positional and named optional arguments, the alphabet of parameter names is a function of the whole application.

I'm not sure how patch is supposed to help - the result of merging a patch is supposed to be a valid class in the patch's context.

Fundamentally, this code is doing something that cannot be expressed in the language.

If I declare a call method, I get extra generated code and the TearOffClosures accidentally implement the chosen signature. I can make the implementation call noSuchMethod, but that adds about 10k of code and causes widespread code quality issues related to the type analysis precision costs of noSuchMethod. This is a very high price to pay for suppressing a couple of warnings.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@vsmenon vsmenon added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jul 20, 2019
@joshualitt
Copy link
Contributor

Closing because this bug is not fixable currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

6 participants