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

[cfe/macros]: empty metadata iterable at compile time #55983

Closed
helightdev opened this issue Jun 11, 2024 · 1 comment
Closed

[cfe/macros]: empty metadata iterable at compile time #55983

helightdev opened this issue Jun 11, 2024 · 1 comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-feature-macros Implement macros features in the CFE feature-macros Implementation of the macros feature

Comments

@helightdev
Copy link

Trying to resolve method metadata at definion class definition phase returns an empty metadata iterable at compile time but doesn't throw an exception, while the analyzer correctly generated the augmentation and correctly passes the full metadata list to the macro.

@TestMacro()
class TestClass {

  @TestAnnotation("Value!")
  void testMethod() {}

}

This example class generates following augmentation code using the analyzer

augment class TestClass {
external static prefix0.List<prefix1.GeneratedObject> get objects;
  augment static prefix0.List<prefix1.GeneratedObject> get objects => [prefix1.GeneratedObject([],0),prefix1.GeneratedObject([prefix2.TestAnnotation("Value!",),],1)];
}

but retrieving the getter generated by this at runtime results in following output:

void main(List<String> arguments) {
 for (var obj in TestClass.objects) {
   print(obj.count);
   print(obj.annotations);
 }
}
/usr/lib/dart/bin/dart --enable-experiment=macros --no-serve-devtools bin/cfe_metadata_reconstruction.dart
0
[]
0
[]

I took a while to even notice this behaviour since the analyzer output looks correct and the compiler doesn't throw an (Unimplemented-)Exception. Only noticed it once my stuff which actually needed the metadata entries broke.

The code of the macro is available at https://github.com/helightdev/cfe_metadata_reconstruction

The bug has been tested on a build of the current main branch

Dart SDK version: 3.5.0-edge.5a49a95b399cbed956d808bdfe594e1a3f2c9382 (main) (Tue Jun 11 12:36:05 2024 +0000) on "linux_x64"
@jakemac53 jakemac53 added area-front-end Use area-front-end for front end / CFE / kernel format related issues. feature-macros Implementation of the macros feature labels Jun 11, 2024
@johnniwinther johnniwinther added the cfe-feature-macros Implement macros features in the CFE label Jun 12, 2024
@davidmorgan
Copy link
Contributor

That's because we don't have a design that works for the CFE yet :) ... please follow dart-lang/language#3847 for progress on this one. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-feature-macros Implement macros features in the CFE feature-macros Implementation of the macros feature
Projects
Development

No branches or pull requests

4 participants