-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Bad JS generated with staticInterop and DDC #51060
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
Comments
There are three parts that make the target method being called: the receiver object, the method name and the form of access. In the compiled code that @kevmoo showed me we see It seems like there are a few things that are not matching up correctly. If the receiver is correct, then the name and access form are probably wrong. I think it should be something more like If the method name and access form are correct then it should be accessing the property on some compiled module to get the top level method. |
Try importing it like this: import 'package:google_identity_services_web/oauth2.dart'; That exports an This is my dart code: And this is the generated one: Full dart code here. (I just noticed that what needs to be imported is quite unclear in the API docs from pub, that list the "libraries" but they're hard to tell apart from the entrypoints of the library, I guess I should only have a |
(I guess the js-interop bug is that the invocation over a named import (
|
Nick and I chatted offline, the oddity is that we're using @nshahan Based on dit's comments, I tried out the smaller example we used with namespacing e.g. @kevmoo Can you share with us your entire Dart code that repro's the issue? Is it just that one line of code + the import? |
It's weird, though. In So this uses |
Copy-pasting from chat for prosperity: Okay, I think I know what's going wrong. I think it has to do with modular compiles of some sort. When compiling the module that contains the invocation of the external extension member, we haven't necessarily visited the library that contains that member, so we might not have done the lowering yet where we mark it non-external. So, DDC sees an external member still, and emits code using I confirmed this in two ways:
This means we'll have to add a slightly annoying change to DDC. We lower not only external extension members but also other external members for |
This is a good explanation but it is also a little surprising to me. When does the lowering occur and how is it that we are compiling the use before we have applied the lowering in the imported library? Is this another case where the summary .dill file doesn't include the modifications made by the lowering? |
It's also surprising to me, as I'd expect the library that contains the member to be compiled first. And indeed, when I print out the modules, modular transformations occur first on
I thought modular transformations persist until the module is recompiled, and I don't think it's getting recompiled here, so I'm not exactly sure where the modular case pops up. |
I'm just throwing out possible ideas: Since we couldn't reproduce it using We should try to make a minimal reproduction with a build_web_compilers build with multiple packages. |
I think you're right. I really want to verify that this is a case that we should support with modular compilation, and not just an unusual ordering by build_web_compilers. We could also try our modular test suite to see if we can reproduce the ordering there. I'll respond back when I have try out some stuff. |
Just a couple thoughts:
|
I didnt realize @staticInterop was going to be deprecated in favor of inline classes... so nevermind? #49353 (comment) |
FYI - the plan is not to deprecate for a while. We still need to release inline classes and make sure all existing interop users have a path forward, so we still want to fix any bugs with @staticInterop. There's a very recent change to lower interop calls at the call-site instead of in the declaration that might make this bug obsolete: d4adfcc I can't seem to get your project working with the bleeding-edge SDK, however:
|
@srujzs Sorry, master is trash, try using the ‘dart3-ddc-issue’ branch which is a snapshot of the ‘dart3-explore’ branch (it is what I used for the screenshots above) those branches are where I started using Dart 3.0.2 and switched to using @staticInterop. |
@srujzs I actually had a chance to test it just now, and the issue seems to be resolved in Dart 3.1.0-155.0.dev woo thanks for the info and help! :) |
I'm not sure what went in to fix your specific issue, but I'll take it. :) @kevmoo, are you still coming across this issue? It seems like this package has been updated since the last time I took a look. |
@srujzs – no! it works now. Forgot to close out! |
Code defined in
import 'package:google_identity_services_web/oauth2.dart' as gis;
Invoking code in Dart
Generated JS (that fails)
This is on my machine w/ the Dart SDK. @ditman using Flutter get what seems to be the right code
CC @srujzs @nshahan
The text was updated successfully, but these errors were encountered: