[CFE] Make macros work (more?) in the incremental compiler

Change-Id: I442bc817c91010690326d25327e919d53dbfce0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360864
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2024-04-05 10:48:49 +00:00 committed by Commit Queue
parent 9fcd15941d
commit 90add382e4
12 changed files with 616 additions and 16 deletions

View file

@ -274,6 +274,15 @@ class KernelTarget extends TargetImplementation {
}
}
void removeSourceInformation(Uri fileUri) {
uriToSource.remove(fileUri);
if (_hasAddedSources) {
// The sources have already been added to the component in [link] so we
// have to remove source directly here to create a consistent component.
component?.uriToSource.remove(fileUri);
}
}
/// Return list of same size as input with possibly translated uris.
List<Uri> setEntryPoints(List<Uri> entryPoints) {
List<Uri> result = <Uri>[];
@ -696,6 +705,9 @@ class KernelTarget extends TargetImplementation {
Component link(List<Library> libraries, {CanonicalName? nameRoot}) {
libraries.addAll(dillTarget.loader.libraries);
// Copy source data from the map in [CompilerContext] into a new map that is
// put on the component.
Map<Uri, Source> uriToSource = new Map<Uri, Source>();
void copySource(Uri uri, Source source) {
uriToSource[uri] = excludeSource

View file

@ -1033,13 +1033,11 @@ class MacroApplications {
enableNonNullable: true,
enableTripleShift: true,
forAugmentationLibrary: true));
component.uriToSource[augmentationFileUri] = new Source(
scannerResult.lineStarts,
source.codeUnits,
augmentationImportUri,
augmentationFileUri);
_sourceLoader.target.addSourceInformation(augmentationImportUri,
augmentationFileUri, scannerResult.lineStarts, source.codeUnits);
for (Uri intermediateAugmentationUri in intermediateAugmentationUris) {
component.uriToSource.remove(intermediateAugmentationUri);
_sourceLoader.target
.removeSourceInformation(intermediateAugmentationUri);
}
}

View file

@ -294,7 +294,19 @@ class SourceClassBuilder extends ClassBuilderImpl
// TODO(ahe): If `cls.supertype` is null, and this isn't Object, report a
// compile-time error.
cls.isAbstract = isAbstract;
cls.isMacro = isMacro;
if (!cls.isMacro) {
// TODO(jensj): cls / actualCls is not the same --- so for instance it sets
// macro on the "parent" class depending on whatever it processes last of
// "non-parent" classes.
// This means that when a macro class has an augmentation which is not a
// macro class the macro class will be marked as no longer a macro class
// and at least via the incremental compiler subsequent applications of it
// will fail.
// Now it's *only* set if it's not already a macro, i.e. once it's a macro
// it stays a macro which seems reasonable although I don't know what the
// actual rules are.
cls.isMacro = isMacro;
}
cls.isMixinClass = isMixinClass;
cls.isSealed = isSealed;
cls.isBase = isBase;

View file

@ -23,12 +23,17 @@ Uri _findSdkSummary({Uri? targetSdkSummary}) {
if (targetSdkSummary?.path == 'virtual_platform_kernel.dill') {
return targetSdkSummary!;
}
// This makes it work in the incremental test suite.
if (targetSdkSummary?.path == '/vm_platform_strong.dill') {
return targetSdkSummary!;
}
// If the currently-running tool is in a Dart SDK folder, use the platform
// dill from there. Failing that, try searching from the target dill.
List<Directory> searchDirectories = [
new File(Platform.resolvedExecutable).parent,
if (targetSdkSummary != null) new File.fromUri(targetSdkSummary).parent,
if (targetSdkSummary != null && targetSdkSummary.isScheme("file"))
new File.fromUri(targetSdkSummary).parent,
];
for (Directory searchDirectory in searchDirectories) {

View file

@ -682,11 +682,13 @@ Future<Map<String, List<int>>> createModules(
Target target,
Target originalTarget,
String sdkSummary,
{required bool trackNeededDillLibraries}) async {
{required bool trackNeededDillLibraries,
required Uri checkoutRoot}) async {
final Uri base = Uri.parse("org-dartlang-test:///");
final Uri sdkSummaryUri = base.resolve(sdkSummary);
TestMemoryFileSystem fs = new TestMemoryFileSystem(base);
TestMemoryFileSystem fs =
new TestMemoryFileSystem(base, holePunchBase: checkoutRoot);
fs.entityForUri(sdkSummaryUri).writeAsBytesSync(sdkSummaryData);
// Setup all sources
@ -1097,7 +1099,11 @@ class NewWorldTest {
});
Future<Result<TestData>> newWorldTest() async {
final Uri sdkRoot = computePlatformBinariesLocation(forceBuildDir: true);
final Uri platformBinariesRoot =
computePlatformBinariesLocation(forceBuildDir: true);
// This is somewhat of a hack but will do for now.
final Uri checkoutRoot = data.loadedFrom.resolve("../../../../");
TestTargetFlags targetFlags = new TestTargetFlags(
forceLateLoweringsForTesting:
@ -1129,12 +1135,12 @@ class NewWorldTest {
final Uri base = Uri.parse("org-dartlang-test:///");
final Uri sdkSummaryUri = base.resolve(sdkSummary);
final Uri initializeFrom = base.resolve("initializeFrom.dill");
Uri platformUri = sdkRoot.resolve(sdkSummary);
Uri platformUri = platformBinariesRoot.resolve(sdkSummary);
final List<int> sdkSummaryData =
await new File.fromUri(platformUri).readAsBytes();
List<int>? newestWholeComponentData;
MemoryFileSystem? fs;
TestMemoryFileSystem? fs;
Map<String, String?>? sourceFiles;
CompilerOptions? options;
TestIncrementalCompiler? compiler;
@ -1146,7 +1152,7 @@ class NewWorldTest {
if (modules != null) {
moduleData = await createModules(
modules!, sdkSummaryData, target, originalTarget, sdkSummary,
trackNeededDillLibraries: false);
checkoutRoot: checkoutRoot, trackNeededDillLibraries: false);
sdk = newestWholeComponent = new Component();
new BinaryBuilder(sdkSummaryData,
filename: null, disableLazyReading: false)
@ -1193,7 +1199,7 @@ class NewWorldTest {
}
if (!world.updateWorldType) {
fs = new TestMemoryFileSystem(base);
fs = new TestMemoryFileSystem(base, holePunchBase: checkoutRoot);
}
fs!.entityForUri(sdkSummaryUri).writeAsBytesSync(sdkSummaryData);
bool expectInitializeFromDill = false;
@ -2395,6 +2401,10 @@ String componentToStringSdkFiltered(Component component) {
if (lib.importUri.isScheme("dart")) {
dartUris.add(lib.importUri);
} else {
if (lib.fileUri.isScheme("holePunch")) {
// Skip this.
continue;
}
c.libraries.add(lib);
}
}
@ -2791,10 +2801,23 @@ void doSimulateTransformer(Component c) {
}
class TestMemoryFileSystem extends MemoryFileSystem {
TestMemoryFileSystem(Uri currentDirectory) : super(currentDirectory);
Uri holePunchBase;
TestMemoryFileSystem(Uri currentDirectory, {required this.holePunchBase})
: super(currentDirectory);
@override
MemoryFileSystemEntity entityForUri(Uri uri) {
if (uri.isScheme("holePunch")) {
// "Copy" the file into the memory file system.
Uri holePunchResolved = holePunchBase.resolve(uri.path);
File f = new File.fromUri(holePunchResolved);
MemoryFileSystemEntity entity = super.entityForUri(uri);
if (f.existsSync()) {
entity.writeAsBytesSync(f.readAsBytesSync());
}
return entity;
}
// Try to "sanitize" the uri as a real file system does, namely
// "a/b.dart" and "a//b.dart" returns the same file.
if (uri.pathSegments.contains("")) {

View file

@ -390,6 +390,7 @@ hi
hints
hits
hkt
hole
home
hoo
hook
@ -625,6 +626,7 @@ proxy
pseudocode
pt
pubspec
punch
pv
px
py

View file

@ -0,0 +1,109 @@
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Incremental compiler scenario coped from the tests in
# tests/language/macros/nesting/
# where macro_impl_uses_macro1_test.dart becomes
# macro_impl_uses_macro2_test.dart.
type: newworld
worlds:
- entry: main.dart
experiments: macros
sources:
.dart_tool/package_config.json: |
{
"configVersion": 2,
"packages": [
{
"name": "macros",
"rootUri": "holePunch:pkg/macros",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "_macros",
"rootUri": "holePunch:pkg/_macros",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "meta",
"rootUri": "holePunch:pkg/meta",
"packageUri": "lib/"
}
]
}
main.dart: |
import 'impl/declare_count1_macro.dart';
@DeclareCount1()
@override
class A {}
void main() {
print(A().count);
}
impl/declare_count2_macro.dart: |
import 'package:macros/macros.dart';
import 'declare_count1_macro.dart';
@DeclareCount1()
macro class DeclareCount2 implements ClassDeclarationsMacro {
const DeclareCount2();
@override
Future<void> buildDeclarationsForClass(
ClassDeclaration clazz, MemberDeclarationBuilder builder) async {
builder.declareInType(DeclarationCode.fromString('int get count => ${count + 1};'));
}
}
impl/declare_count1_macro.dart: |
import 'package:macros/macros.dart';
import 'declare_count0_macro.dart';
@DeclareCount0()
macro class DeclareCount1 implements ClassDeclarationsMacro {
const DeclareCount1();
@override
Future<void> buildDeclarationsForClass(
ClassDeclaration clazz, MemberDeclarationBuilder builder) async {
builder.declareInType(DeclarationCode.fromString('int get count => ${count + 1};'));
}
}
impl/declare_count0_macro.dart: |
import 'package:macros/macros.dart';
macro class DeclareCount0 implements ClassDeclarationsMacro {
const DeclareCount0();
@override
Future<void> buildDeclarationsForClass(
ClassDeclaration clazz, MemberDeclarationBuilder builder) async {
builder.declareInType(DeclarationCode.fromString('int get count => 0;'));
}
}
expectedLibraryCount: 5
- entry: main.dart
worldType: updated
expectInitializeFromDill: false
experiments: macros
invalidate:
- main.dart
sources:
main.dart: |
import 'impl/declare_count2_macro.dart';
@DeclareCount2()
@override
class A {}
void main() {
print(A().count);
}
expectedLibraryCount: 6
advancedInvalidation: outlineChange

View file

@ -0,0 +1,80 @@
main = main::main;
library from "org-dartlang-test:///impl/declare_count0_macro.dart" as dec {
import "package:macros/macros.dart";
macro class DeclareCount0 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec::DeclareCount0
: super dart.core::Object::•()
;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => 0;")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///impl/declare_count1_macro.dart" as dec2 {
import "package:macros/macros.dart";
import "org-dartlang-test:///impl/declare_count0_macro.dart";
@#C2
macro class DeclareCount1 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec2::DeclareCount1
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///impl/declare_count1_macro.dart */ count() → dart.core::int
return 0;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => ${this.{dec2::DeclareCount1::count}{dart.core::int}.{dart.core::num::+}(1){(dart.core::num) → dart.core::int}};")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///main.dart" as main {
import "org-dartlang-test:///impl/declare_count1_macro.dart";
@#C3
@#C1
class A extends dart.core::Object {
synthetic constructor •() → main::A
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///main.dart */ count() → dart.core::int
return 1;
}
static method main() → void {
dart.core::print(new main::A::•().{main::A::count}{dart.core::int});
}
}
constants {
#C1 = dart.core::_Override {}
#C2 = dec::DeclareCount0 {}
#C3 = dec2::DeclareCount1 {}
}
Constructor coverage from constants:
org-dartlang-test:///main.dart:
- DeclareCount1. (from org-dartlang-test:///impl/declare_count1_macro.dart:7:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
org-dartlang-test:///impl/declare_count1_macro.dart:
- DeclareCount0. (from org-dartlang-test:///impl/declare_count0_macro.dart:4:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/builders.dart:
- Deprecated. (from org-dartlang-sdk:///sdk/lib/core/annotations.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/code.dart:
- CodeKind. (from holepunch:pkg/_macros/lib/src/api/code.dart:460:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/diagnostic.dart:
- Severity. (from holepunch:pkg/_macros/lib/src/api/diagnostic.dart:93:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)

View file

@ -0,0 +1,103 @@
main = main::main;
library from "org-dartlang-test:///impl/declare_count0_macro.dart" as dec {
import "package:macros/macros.dart";
macro class DeclareCount0 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec::DeclareCount0
: super dart.core::Object::•()
;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => 0;")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///impl/declare_count1_macro.dart" as dec2 {
import "package:macros/macros.dart";
import "org-dartlang-test:///impl/declare_count0_macro.dart";
@#C2
macro class DeclareCount1 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec2::DeclareCount1
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///impl/declare_count1_macro.dart */ count() → dart.core::int
return 0;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => ${this.{dec2::DeclareCount1::count}{dart.core::int}.{dart.core::num::+}(1){(dart.core::num) → dart.core::int}};")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///impl/declare_count2_macro.dart" as dec3 {
import "package:macros/macros.dart";
import "org-dartlang-test:///impl/declare_count1_macro.dart";
@#C3
macro class DeclareCount2 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec3::DeclareCount2
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///impl/declare_count2_macro.dart */ count() → dart.core::int
return 1;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => ${this.{dec3::DeclareCount2::count}{dart.core::int}.{dart.core::num::+}(1){(dart.core::num) → dart.core::int}};")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///main.dart" as main {
import "org-dartlang-test:///impl/declare_count2_macro.dart";
@#C4
@#C1
class A extends dart.core::Object {
synthetic constructor •() → main::A
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///main.dart */ count() → dart.core::int
return 2;
}
static method main() → void {
dart.core::print(new main::A::•().{main::A::count}{dart.core::int});
}
}
constants {
#C1 = dart.core::_Override {}
#C2 = dec::DeclareCount0 {}
#C3 = dec2::DeclareCount1 {}
#C4 = dec3::DeclareCount2 {}
}
Constructor coverage from constants:
org-dartlang-test:///impl/declare_count1_macro.dart:
- DeclareCount0. (from org-dartlang-test:///impl/declare_count0_macro.dart:4:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/builders.dart:
- Deprecated. (from org-dartlang-sdk:///sdk/lib/core/annotations.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/code.dart:
- CodeKind. (from holepunch:pkg/_macros/lib/src/api/code.dart:460:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/diagnostic.dart:
- Severity. (from holepunch:pkg/_macros/lib/src/api/diagnostic.dart:93:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
org-dartlang-test:///main.dart:
- DeclareCount2. (from org-dartlang-test:///impl/declare_count2_macro.dart:7:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
org-dartlang-test:///impl/declare_count2_macro.dart:
- DeclareCount1. (from org-dartlang-test:///impl/declare_count1_macro.dart:7:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)

View file

@ -0,0 +1,95 @@
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Incremental compiler scenario coped from the tests in
# tests/language/macros/nesting/
# where macro_impl_uses_macro1_test.dart is recompiled.
type: newworld
worlds:
- entry: main.dart
experiments: macros
sources:
.dart_tool/package_config.json: |
{
"configVersion": 2,
"packages": [
{
"name": "macros",
"rootUri": "holePunch:pkg/macros",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "_macros",
"rootUri": "holePunch:pkg/_macros",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "meta",
"rootUri": "holePunch:pkg/meta",
"packageUri": "lib/"
}
]
}
main.dart: |
import 'impl/declare_count1_macro.dart';
@DeclareCount1()
@override
class A {}
void main() {
print(A().count);
}
impl/declare_count1_macro.dart: |
import 'package:macros/macros.dart';
import 'declare_count0_macro.dart';
@DeclareCount0()
macro class DeclareCount1 implements ClassDeclarationsMacro {
const DeclareCount1();
@override
Future<void> buildDeclarationsForClass(
ClassDeclaration clazz, MemberDeclarationBuilder builder) async {
builder.declareInType(DeclarationCode.fromString('int get count => ${count + 1};'));
}
}
impl/declare_count0_macro.dart: |
import 'package:macros/macros.dart';
macro class DeclareCount0 implements ClassDeclarationsMacro {
const DeclareCount0();
@override
Future<void> buildDeclarationsForClass(
ClassDeclaration clazz, MemberDeclarationBuilder builder) async {
builder.declareInType(DeclarationCode.fromString('int get count => 0;'));
}
}
expectedLibraryCount: 5
- entry: main.dart
errors: false
worldType: updated
expectInitializeFromDill: false
experiments: macros
invalidate:
- main.dart
sources:
main.dart: |
import 'impl/declare_count1_macro.dart';
@DeclareCount1()
@override
@override // make it an outline change
class A {}
void main() {
print(A().count);
}
expectedLibraryCount: 5
advancedInvalidation: outlineChange

View file

@ -0,0 +1,80 @@
main = main::main;
library from "org-dartlang-test:///impl/declare_count0_macro.dart" as dec {
import "package:macros/macros.dart";
macro class DeclareCount0 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec::DeclareCount0
: super dart.core::Object::•()
;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => 0;")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///impl/declare_count1_macro.dart" as dec2 {
import "package:macros/macros.dart";
import "org-dartlang-test:///impl/declare_count0_macro.dart";
@#C2
macro class DeclareCount1 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec2::DeclareCount1
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///impl/declare_count1_macro.dart */ count() → dart.core::int
return 0;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => ${this.{dec2::DeclareCount1::count}{dart.core::int}.{dart.core::num::+}(1){(dart.core::num) → dart.core::int}};")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///main.dart" as main {
import "org-dartlang-test:///impl/declare_count1_macro.dart";
@#C3
@#C1
class A extends dart.core::Object {
synthetic constructor •() → main::A
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///main.dart */ count() → dart.core::int
return 1;
}
static method main() → void {
dart.core::print(new main::A::•().{main::A::count}{dart.core::int});
}
}
constants {
#C1 = dart.core::_Override {}
#C2 = dec::DeclareCount0 {}
#C3 = dec2::DeclareCount1 {}
}
Constructor coverage from constants:
org-dartlang-test:///main.dart:
- DeclareCount1. (from org-dartlang-test:///impl/declare_count1_macro.dart:7:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
org-dartlang-test:///impl/declare_count1_macro.dart:
- DeclareCount0. (from org-dartlang-test:///impl/declare_count0_macro.dart:4:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/builders.dart:
- Deprecated. (from org-dartlang-sdk:///sdk/lib/core/annotations.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/code.dart:
- CodeKind. (from holepunch:pkg/_macros/lib/src/api/code.dart:460:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/diagnostic.dart:
- Severity. (from holepunch:pkg/_macros/lib/src/api/diagnostic.dart:93:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)

View file

@ -0,0 +1,81 @@
main = main::main;
library from "org-dartlang-test:///impl/declare_count0_macro.dart" as dec {
import "package:macros/macros.dart";
macro class DeclareCount0 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec::DeclareCount0
: super dart.core::Object::•()
;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => 0;")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///impl/declare_count1_macro.dart" as dec2 {
import "package:macros/macros.dart";
import "org-dartlang-test:///impl/declare_count0_macro.dart";
@#C2
macro class DeclareCount1 extends dart.core::Object implements #lib1::ClassDeclarationsMacro /*hasConstConstructor*/ {
const constructor •() → dec2::DeclareCount1
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///impl/declare_count1_macro.dart */ count() → dart.core::int
return 0;
@#C1
method buildDeclarationsForClass(#lib1::ClassDeclaration clazz, #lib1::MemberDeclarationBuilder builder) → dart.async::Future<void> async /* emittedValueType= void */ {
builder.{#lib1::MemberDeclarationBuilder::declareInType}(new #lib1::DeclarationCode::fromString("int get count => ${this.{dec2::DeclareCount1::count}{dart.core::int}.{dart.core::num::+}(1){(dart.core::num) → dart.core::int}};")){(#lib1::DeclarationCode) → void};
}
}
}
library from "org-dartlang-test:///main.dart" as main {
import "org-dartlang-test:///impl/declare_count1_macro.dart";
@#C3
@#C1
@#C1
class A extends dart.core::Object {
synthetic constructor •() → main::A
: super dart.core::Object::•()
;
get /* from dart-macro+org-dartlang-test:///main.dart */ count() → dart.core::int
return 1;
}
static method main() → void {
dart.core::print(new main::A::•().{main::A::count}{dart.core::int});
}
}
constants {
#C1 = dart.core::_Override {}
#C2 = dec::DeclareCount0 {}
#C3 = dec2::DeclareCount1 {}
}
Constructor coverage from constants:
org-dartlang-test:///impl/declare_count1_macro.dart:
- DeclareCount0. (from org-dartlang-test:///impl/declare_count0_macro.dart:4:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/builders.dart:
- Deprecated. (from org-dartlang-sdk:///sdk/lib/core/annotations.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/code.dart:
- CodeKind. (from holepunch:pkg/_macros/lib/src/api/code.dart:460:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
holepunch:pkg/_macros/lib/src/api/diagnostic.dart:
- Severity. (from holepunch:pkg/_macros/lib/src/api/diagnostic.dart:93:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
org-dartlang-test:///main.dart:
- DeclareCount1. (from org-dartlang-test:///impl/declare_count1_macro.dart:7:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)