Skip to content

Commit

Permalink
Version 3.5.0-288.0.dev
Browse files Browse the repository at this point in the history
Merge efb3807 into dev
  • Loading branch information
Dart CI committed Jun 21, 2024
2 parents 4483d67 + efb3807 commit fc1e591
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ vars = {

# co19 is a cipd package automatically generated for each co19 commit.
# Use tests/co19/update.sh to update this hash.
"co19_rev": "831b22d5e496fe63a813ca1c1b64f533c2f9fa0c",
"co19_rev": "3a1b6f75c771d62e7150f2dd69595a98fd6930f4",

# The internal benchmarks to use. See go/dart-benchmarks-internal
"benchmarks_internal_rev": "a7c23b2422492dcc515d1ba4abe3609b50e2a139",
Expand Down
11 changes: 10 additions & 1 deletion benchmarks/WasmDataTransfer/dart/WasmDataTransfer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ void main(List<String> args) {
WasmDataTransferToBrowserBytes(largeDartBytes, '1MB').report();
}

class PrintEmitter implements ScoreEmitter {
const PrintEmitter();

@override
void emit(String testName, double value) {
print('$testName(RunTimeRaw): $value us.');
}
}

abstract class Benchmark extends BenchmarkBase {
Benchmark(super.name);
Benchmark(super.name) : super(emitter: const PrintEmitter());

@override
void exercise() {
Expand Down
4 changes: 4 additions & 0 deletions pkg/_macros/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.2

- Fix bug where augmenting classes with type parameters didn't work.

## 0.3.1

- Make it an error for macros to complete with pending async work scheduled.
Expand Down
20 changes: 19 additions & 1 deletion pkg/_macros/lib/src/executor/augmentation_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,26 @@ class _Builder {
];
// Has the effect of adding a space after the keywords
if (keywords.isNotEmpty) keywords.add('');

var hasTypeParams = typeDeclaration is ParameterizedTypeDeclaration &&
typeDeclaration.typeParameters.isNotEmpty;
_writeDirectiveStringPart(TypeDeclarationContentKey.declaration(key),
'augment ${keywords.join(' ')}$declarationKind ${type.name} ');
'augment ${keywords.join(' ')}$declarationKind ${type.name}${hasTypeParams ? '' : ' '}');

if (hasTypeParams) {
var typeParameters = typeDeclaration.typeParameters;
_writeDirectiveStringPart(
TypeDeclarationContentKey.typeParametersStart(key), '<');
for (var param in typeParameters) {
_buildCode(
key,
param == typeParameters.first
? param.code
: RawCode.fromParts([', ', param.code]));
}
_writeDirectiveStringPart(
TypeDeclarationContentKey.typeParametersEnd(key), '> ');
}

if (mergedExtendsResults[type] case (var superclassKey, var superclass)) {
Key fixedKey = TypeDeclarationContentKey.superclass(key);
Expand Down
18 changes: 18 additions & 0 deletions pkg/_macros/lib/src/executor/span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ enum _TypeDeclarationContentKind {
enumValueEnd,
declarationSeparator,
bodyEnd,
typeParameterStart,
typeParameterEnd,
}

/// Content of a [TypeDeclaration].
Expand Down Expand Up @@ -381,6 +383,22 @@ class TypeDeclarationContentKey implements Key {
TypeDeclarationContentKey.bodyEnd(Key parent)
: this._(parent, _TypeDeclarationContentKind.bodyEnd);

/// The start of the type parameters, that is, "<" in
///
/// augment class Foo<T> {
/// }
///
TypeDeclarationContentKey.typeParametersStart(Key parent)
: this._(parent, _TypeDeclarationContentKind.typeParameterStart);

/// The end of the type parameters, that is, ">" in
///
/// augment class Foo<T> {
/// }
///
TypeDeclarationContentKey.typeParametersEnd(Key parent)
: this._(parent, _TypeDeclarationContentKind.typeParameterEnd);

@override
bool operator ==(Object other) =>
identical(this, other) ||
Expand Down
2 changes: 1 addition & 1 deletion pkg/_macros/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: _macros
version: 0.3.1
version: 0.3.2
description: >-
This is a private SDK vendored package, which is re-exported by the public
`macros` package, which is a pub package. Every change to this package is
Expand Down
77 changes: 77 additions & 0 deletions pkg/_macros/test/executor/augmentation_library_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ void main() {
kind: IdentifierKind.topLevelMember,
staticScope: null,
uri: Uri.parse('dart:core'));
final objectIdentifier = TestIdentifier(
id: RemoteInstance.uniqueId,
name: 'Object',
kind: IdentifierKind.topLevelMember,
staticScope: null,
uri: Uri.parse('dart:core'));
final superclassIdentifier = TestIdentifier(
id: RemoteInstance.uniqueId,
name: 'SomeSuperclass',
Expand Down Expand Up @@ -619,6 +625,77 @@ void main() {
'''));
}
});

test('copies generic types and bounds', () async {
final clazz = ClassDeclarationImpl(
id: RemoteInstance.uniqueId,
identifier:
IdentifierImpl(id: RemoteInstance.uniqueId, name: 'MyClass'),
library: Fixtures.library,
metadata: [],
typeParameters: [
TypeParameterDeclarationImpl(
id: RemoteInstance.uniqueId,
identifier:
IdentifierImpl(id: RemoteInstance.uniqueId, name: 'T'),
library: Fixtures.library,
metadata: [],
bound: NamedTypeAnnotationImpl(
id: RemoteInstance.uniqueId,
isNullable: false,
identifier: objectIdentifier,
typeArguments: [])),
TypeParameterDeclarationImpl(
id: RemoteInstance.uniqueId,
identifier:
IdentifierImpl(id: RemoteInstance.uniqueId, name: 'S'),
library: Fixtures.library,
metadata: [],
bound: null),
],
interfaces: [],
hasAbstract: false,
hasBase: false,
hasExternal: false,
hasFinal: false,
hasInterface: false,
hasMixin: false,
hasSealed: false,
mixins: [],
superclass: null);

var results = [
MacroExecutionResultImpl(
diagnostics: [],
enumValueAugmentations: {},
extendsTypeAugmentations: {},
typeAugmentations: {
clazz.identifier: [
DeclarationCode.fromParts(['']),
]
},
interfaceAugmentations: {},
mixinAugmentations: {},
newTypeNames: [],
libraryAugmentations: []),
];
var library = _TestExecutor().buildAugmentationLibrary(
Fixtures.library.uri,
results,
(Identifier i) =>
i == clazz.identifier ? clazz : throw UnimplementedError(),
(Identifier i) => (i as TestIdentifier).resolved,
(OmittedTypeAnnotation i) =>
(i as TestOmittedTypeAnnotation).inferredType);
expect(library, equalsIgnoringWhitespace('''
augment library 'package:foo/bar.dart';
import 'dart:core' as prefix0;
augment class MyClass<T extends prefix0.Object, S> {
}
'''));
});
});
}

Expand Down
13 changes: 10 additions & 3 deletions pkg/front_end/lib/src/kernel_generator_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ Future<CompilerResult> generateKernel(ProcessedOptions options,
});
}

/// Note that if [buildSummary] is true it will be default serialize the summary
/// but this can be disabled by setting [serializeIfBuildingSummary] to false.
Future<InternalCompilerResult> generateKernelInternal(
{bool buildSummary = false,
bool serializeIfBuildingSummary = true,
bool buildComponent = true,
bool truncateSummary = false,
bool includeOffsets = true,
Expand Down Expand Up @@ -133,6 +136,7 @@ Future<InternalCompilerResult> generateKernelInternal(
sdkSummary: sdkSummary,
loadedComponents: loadedComponents,
buildSummary: buildSummary,
serializeIfBuildingSummary: serializeIfBuildingSummary,
truncateSummary: truncateSummary,
buildComponent: buildComponent,
includeOffsets: includeOffsets,
Expand All @@ -152,6 +156,7 @@ Future<InternalCompilerResult> _buildInternal(
required Component? sdkSummary,
required List<Component> loadedComponents,
required bool buildSummary,
required bool serializeIfBuildingSummary,
required bool truncateSummary,
required bool buildComponent,
required bool includeOffsets,
Expand Down Expand Up @@ -213,9 +218,11 @@ Future<InternalCompilerResult> _buildInternal(
options.target.performOutlineTransformations(trimmedSummaryComponent);
options.ticker.logMs("Transformed outline");
}
// Don't include source (but do add it above to include importUris).
summary = serializeComponent(trimmedSummaryComponent,
includeSources: false, includeOffsets: includeOffsets);
if (serializeIfBuildingSummary) {
// Don't include source (but do add it above to include importUris).
summary = serializeComponent(trimmedSummaryComponent,
includeSources: false, includeOffsets: includeOffsets);
}
options.ticker.logMs("Generated outline");
}

Expand Down
1 change: 1 addition & 0 deletions pkg/front_end/presubmit_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'dart:isolate';
import 'test/utils/io_utils.dart';

Future<void> main(List<String> args) async {
Directory.current = Directory.fromUri(_repoDir);
Stopwatch stopwatch = new Stopwatch()..start();
// Expect something like /full/path/to/sdk/pkg/some_dir/whatever/else
if (args.length != 1) throw "Need exactly one argument.";
Expand Down
2 changes: 2 additions & 0 deletions pkg/front_end/test/fasta/testing/suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,7 @@ class Outline extends Step<TestDescription, ComponentResult, FastaContext> {
InternalCompilerResult internalCompilerResult =
await generateKernelInternal(
buildSummary: compileMode != CompileMode.full,
serializeIfBuildingSummary: false,
buildComponent: compileMode == CompileMode.full,
includeHierarchyAndCoreTypes: true,
retainDataForTesting: true,
Expand Down Expand Up @@ -2094,6 +2095,7 @@ class Outline extends Step<TestDescription, ComponentResult, FastaContext> {
InternalCompilerResult internalCompilerResult =
await generateKernelInternal(
buildSummary: compileMode == CompileMode.outline,
serializeIfBuildingSummary: false,
buildComponent: compileMode != CompileMode.outline,
instrumentation: instrumentation,
retainDataForTesting: true,
Expand Down
2 changes: 0 additions & 2 deletions pkg/front_end/test/lint_test.status
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ front_end/lib/src/api_prototype/lowering_predicates/Exports: Fail
front_end/lib/src/api_prototype/static_weak_references/Exports: Fail
front_end/lib/src/api_prototype/terminal_color_support/Exports: Fail
front_end/lib/src/api_prototype/try_constant_evaluator/Exports: Fail
front_end/lib/src/api_unstable/bazel_worker/Exports: Fail
front_end/lib/src/api_unstable/vm/Exports: Fail
front_end/lib/src/codes/cfe_codes/Exports: Fail
front_end/lib/src/fasta/messages/Exports: Fail
front_end/lib/src/testing/id_testing_helper/Exports: Fail
Expand Down
10 changes: 8 additions & 2 deletions pkg/front_end/tool/_fasta/entry_points.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ Future<void> outline(List<String> arguments, {Benchmarker? benchmarker}) async {
print("Building outlines for ${arguments.join(' ')}");
}
CompilerResult compilerResult = await generateKernelInternal(
buildSummary: true, buildComponent: false, benchmarker: benchmarker);
buildSummary: true,
serializeIfBuildingSummary: false,
buildComponent: false,
benchmarker: benchmarker);
Component component = compilerResult.component!;
await _emitComponent(c.options, component,
benchmarker: benchmarker, message: "Wrote outline to ");
Expand Down Expand Up @@ -375,7 +378,10 @@ Future<Uri?> deps(List<String> arguments) async {
if (c.options.verbose) {
print("Computing deps: ${arguments.join(' ')}");
}
await generateKernelInternal(buildSummary: true);
await generateKernelInternal(
buildSummary: true,
serializeIfBuildingSummary: false,
);
return await _emitDeps(c, c.options.output);
});
});
Expand Down
4 changes: 4 additions & 0 deletions pkg/macros/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.2-main.4

- Fix bug where augmenting classes with type parameters didn't work.

## 0.1.2-main.3

- Re-export 'package:_macros/src/executor/response_impls.dart'.
Expand Down
4 changes: 2 additions & 2 deletions pkg/macros/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: macros
version: 0.1.2-main.3
version: 0.1.2-main.4
description: >-
This package is for macro authors, and exposes the APIs necessary to write
a macro. It exports the APIs from the private `_macros` SDK vendored package.
Expand All @@ -11,4 +11,4 @@ environment:
dependencies:
_macros:
sdk: dart
version: 0.3.1
version: 0.3.2
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 5
PATCH 0
PRERELEASE 287
PRERELEASE 288
PRERELEASE_PATCH 0

0 comments on commit fc1e591

Please sign in to comment.