Open alexeyinkin opened 1 week ago
Labels: area-language
, type-bug
Summary: Types generated by a macro within a library are not visible outside that library, even when the library is imported. This contradicts the expected behavior where generated types should be accessible in the augmented library's top-level scope.
No, that one concerned using macros from a different package. This one is within the same project. By library I mean just a .dart
file.
Also, with this issue a macro works (this is seen by application.dart
having no errors) but what it declares on the top level is not merged into the augmented library's top-level scope from the standpoint of anyone importing it.
And there's no workaround for this I could find. I just have to declare empty classes and let a macro fill them instead of fully creating them. It's OK for playing around but I can't release my betas with this.
@alexeyinkin Does the analyzer give an error, or do you only see the error when running dart run
?
@jakemac53 as of 3.5.0-292 the analyzer is showing no issues, just dart run
.
Sounds like a CFE issue then (already categorized as such).
When a macro is applied in a library
application.dart
and generates a class there, this class can only be used inside that library. When importingapplication.dart
in another library, the generated class can't be used there.macro.dart:
application.dart:
main.dart:
pubspec.yaml
```yaml name: temp1 environment: sdk: ^3.5.0-180 dependencies: macros: ^0.1.0-main.5 # For 3.5.0-180 ```
The expected behavior is that
GeneratedClass
is available everywhereapplication.dart
is imported. Quoting the augmentation feature specification:If the erroneous line in
main.dart
is commented out, the program runs as expected.dart info
``` #### General info - Dart 3.5.0-180.3.beta (beta) (Wed Jun 5 15:06:15 2024 +0000) on "macos_arm64" - on macos / Version 13.6 (Build 22G120) - locale is en-GE #### Project info - sdk constraint: '^3.5.0-180' - dependencies: macros - dev_dependencies: #### Process info | Memory | CPU | Elapsed time | Command line | | -----: | ---: | -----------: | ------------------------------------------------------------------------------------------ | | 124 MB | 0.0% | 05:57:34 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 110 MB | 0.0% | 12:14:41 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 88 MB | 0.0% | 01-10:36:02 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 112 MB | 0.0% | 04:56:23 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 101 MB | 0.0% | 04:41:48 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 107 MB | 0.0% | 01-08:01:56 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 89 MB | 0.0% | 04:31:30 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 73 MB | 0.0% | 04:30:53 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 111 MB | 0.0% | 04:58 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 240 MB | 0.0% | 07:40:44 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer | | 57 MB | 0.0% | 04-11:59:25 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.90.0 | | 27 MB | 0.0% | 04-11:59:25 | dart tooling-daemon --machine | | 49 MB | 0.0% | 05:57:34 | flutter_tools.snapshot daemon | | 41 MB | 0.0% | 12:14:40 | flutter_tools.snapshot daemon | | 47 MB | 0.0% | 04:56:23 | flutter_tools.snapshot daemon | | 48 MB | 0.0% | 04:41:48 | flutter_tools.snapshot daemon | | 41 MB | 0.0% | 01-08:01:56 | flutter_tools.snapshot daemon | | 47 MB | 0.0% | 07:40:44 | flutter_tools.snapshot daemon | ```