Version 2.19.0-13.0.dev
Merge commit '4c6fcad188a294f398ffb47aff990f8a9ac52bff' into 'dev'
diff --git a/DEPS b/DEPS
index 8b3cb84..c7b269e 100644
--- a/DEPS
+++ b/DEPS
@@ -108,7 +108,7 @@
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "d7b73536a8079331c888b7da539b80e6825270ea", # manually rev'd
- "dartdoc_rev": "ff89da1c9831c81834977d3d67cf6f2462ee4936",
+ "dartdoc_rev": "e6c8861ad3559a6dd61066a12bb81310ce131ae5",
"devtools_rev": "95d292626da26505b02417735f77e8922783b477",
"ffi_rev": "18b2b549d55009ff594600b04705ff6161681e07",
"file_rev": "0132eeedea2933513bf230513a766a8baeab0c4f",
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
index d4c3681..40fdf76 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
@@ -46,15 +46,15 @@
/// This is usually the default value, but can be overridden via
/// initializationOptions (used for tests, but may also be useful for
/// debugging).
- late final CompletionBudget completionBudget;
+ late final Duration completionBudgetDuration;
CompletionHandler(super.server, LspInitializationOptions options)
: suggestFromUnimportedLibraries = options.suggestFromUnimportedLibraries,
previewNotImportedCompletions = options.previewNotImportedCompletions {
final budgetMs = options.completionBudgetMilliseconds;
- completionBudget = CompletionBudget(budgetMs != null
+ completionBudgetDuration = budgetMs != null
? Duration(milliseconds: budgetMs)
- : CompletionBudget.defaultDuration);
+ : CompletionBudget.defaultDuration;
}
@override
@@ -356,7 +356,7 @@
final serverSuggestions2 =
await performance.runAsync('computeSuggestions', (performance) async {
var contributor = DartCompletionManager(
- budget: completionBudget,
+ budget: CompletionBudget(completionBudgetDuration),
includedElementKinds: includedElementKinds,
includedElementNames: includedElementNames,
includedSuggestionRelevanceTags: includedSuggestionRelevanceTags,
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_default_value.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_default_value.dart
new file mode 100644
index 0000000..cf766e4
--- /dev/null
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_default_value.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2022, 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.
+
+import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
+import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:analyzer_plugin/utilities/range_factory.dart';
+
+class RemoveDefaultValue extends CorrectionProducer {
+ @override
+ // Not predictably the correct action.
+ bool get canBeAppliedInBulk => false;
+
+ @override
+ // Not predictably the correct action.
+ bool get canBeAppliedToFile => false;
+
+ @override
+ FixKind get fixKind => DartFixKind.REMOVE_DEFAULT_VALUE;
+
+ @override
+ Future<void> compute(ChangeBuilder builder) async {
+ var defaultFormalParameter =
+ node.thisOrAncestorOfType<DefaultFormalParameter>();
+ if (defaultFormalParameter is! DefaultFormalParameter) return;
+ var separator = defaultFormalParameter.separator;
+ if (separator == null) return;
+ var defaultValue = defaultFormalParameter.defaultValue;
+ if (defaultValue == null) return;
+
+ await builder.addDartFileEdit(file, (builder) {
+ builder.addDeletion(
+ range.endStart(separator.previous!, defaultValue.endToken.next!));
+ });
+ }
+}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index ec29617..74cce40 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -914,6 +914,11 @@
DartFixKindPriority.DEFAULT,
'Remove dead code',
);
+ static const REMOVE_DEFAULT_VALUE = FixKind(
+ 'dart.fix.remove.defaultValue',
+ DartFixKindPriority.DEFAULT,
+ "Remove the default value",
+ );
static const REMOVE_DEPRECATED_NEW_IN_COMMENT_REFERENCE = FixKind(
'dart.fix.remove.deprecatedNewInCommentReference',
DartFixKindPriority.DEFAULT,
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 57a79eb..0d781fb 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -116,6 +116,7 @@
import 'package:analysis_server/src/services/correction/dart/remove_constructor_name.dart';
import 'package:analysis_server/src/services/correction/dart/remove_dead_code.dart';
import 'package:analysis_server/src/services/correction/dart/remove_dead_if_null.dart';
+import 'package:analysis_server/src/services/correction/dart/remove_default_value.dart';
import 'package:analysis_server/src/services/correction/dart/remove_deprecated_new_in_comment_reference.dart';
import 'package:analysis_server/src/services/correction/dart/remove_duplicate_case.dart';
import 'package:analysis_server/src/services/correction/dart/remove_empty_catch.dart';
@@ -914,6 +915,7 @@
ReplaceWithFilled.new,
],
CompileTimeErrorCode.DEFAULT_VALUE_ON_REQUIRED_PARAMETER: [
+ RemoveDefaultValue.new,
RemoveRequired.new,
],
CompileTimeErrorCode.ENUM_WITH_ABSTRACT_MEMBER: [
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_default_value_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_default_value_test.dart
new file mode 100644
index 0000000..22d6d24
--- /dev/null
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_default_value_test.dart
@@ -0,0 +1,36 @@
+// Copyright (c) 2022, 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.
+
+import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'fix_processor.dart';
+
+void main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveDefaultValueTest);
+ });
+}
+
+@reflectiveTest
+class RemoveDefaultValueTest extends FixProcessorTest {
+ @override
+ FixKind get kind => DartFixKind.REMOVE_DEFAULT_VALUE;
+
+ Future<void> test_default_value_on_required_parameter() async {
+ await resolveTestCode('''
+class A {
+ int i;
+ A({required this.i = 1});
+}
+''');
+ await assertHasFix('''
+class A {
+ int i;
+ A({required this.i});
+}
+''');
+ }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
index 688c987..71a3037 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
@@ -141,6 +141,7 @@
import 'remove_const_test.dart' as remove_const;
import 'remove_constructor_name_test.dart' as remove_constructor_name;
import 'remove_dead_code_test.dart' as remove_dead_code;
+import 'remove_default_value_test.dart' as remove_default_value;
import 'remove_deprecated_new_in_comment_reference_test.dart'
as remove_deprecated_new_in_comment_reference;
import 'remove_duplicate_case_test.dart' as remove_duplicate_case;
@@ -361,6 +362,7 @@
remove_const.main();
remove_constructor_name.main();
remove_dead_code.main();
+ remove_default_value.main();
remove_deprecated_new_in_comment_reference.main();
remove_duplicate_case.main();
remove_empty_catch.main();
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 1b1265e..c0781e9 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -4,6 +4,7 @@
* Deprecated `LibraryElement.exports`, use `libraryexports` instead.
* Deprecated `LibraryElement.imports`, use `libraryImports` instead.
* Deprecated `Element.enclosingElement`, use `enclosingElement2` instead.
+* `Member` is not equal to `ElementImpl`, use `Element.declaration`.
## 4.2.0
* Update SDK constraints to `>=2.17.0 <3.0.0`.
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index b14447a..4eb024d 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -1626,7 +1626,7 @@
CompilationUnitElement get definingCompilationUnit;
/// Return a list containing all of the exports defined in this library.
- @Deprecated('Use exports2 instead')
+ @Deprecated('Use libraryExports instead')
List<ExportElement> get exports;
/// The set of features available to this library.
@@ -1637,7 +1637,7 @@
FeatureSet get featureSet;
/// Return a list containing all of the imports defined in this library.
- @Deprecated('Use imports2 instead')
+ @Deprecated('Use libraryImports instead')
List<ImportElement> get imports;
bool get isNonNullableByDefault;
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 471c997..e37b820 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -2569,7 +2569,9 @@
if (identical(this, other)) {
return true;
}
- return other is Element && other.kind == kind && other.location == location;
+ return other is ElementImpl &&
+ other.kind == kind &&
+ other.location == location;
}
/// Append a textual representation of this element to the given [builder].
@@ -4020,14 +4022,6 @@
_exportNamespace = exportNamespace;
}
- @Deprecated('Use exports2 instead')
- @override
- List<ExportElement> get exports {
- return libraryExports
- .map((e) => ExportElementImpl(e as LibraryExportElementImpl))
- .toList();
- }
-
bool get hasPartOfDirective {
return hasModifier(Modifier.HAS_PART_OF_DIRECTIVE);
}
@@ -4048,14 +4042,6 @@
.toList();
}
- @Deprecated('Use imports2 instead')
- @override
- List<ImportElement> get imports {
- return libraryImports
- .map((e) => ImportElementImpl(e as LibraryImportElementImpl))
- .toList();
- }
-
@override
bool get isBrowserApplication =>
entryPoint != null && isOrImportsBrowserLibrary;
@@ -4571,7 +4557,7 @@
return _definingCompilationUnit;
}
- @Deprecated('Use exports2 instead')
+ @Deprecated('Use libraryExports instead')
@override
List<ExportElement> get exports {
return libraryExports
@@ -4586,7 +4572,7 @@
@override
String get identifier => '${_definingCompilationUnit.source.uri}';
- @Deprecated('Use imports2 instead')
+ @Deprecated('Use libraryImports instead')
@override
List<ImportElement> get imports {
return libraryImports
diff --git a/pkg/analyzer/lib/src/error/imports_verifier.dart b/pkg/analyzer/lib/src/error/imports_verifier.dart
index 66afde0..549c43b 100644
--- a/pkg/analyzer/lib/src/error/imports_verifier.dart
+++ b/pkg/analyzer/lib/src/error/imports_verifier.dart
@@ -579,18 +579,26 @@
if (identifiers == null) {
return;
}
+
+ /// When an element is used, it might be converted into a `Member`,
+ /// to apply substitution, or turn it into legacy. But using something
+ /// is purely declaration based.
+ bool hasElement(SimpleIdentifier identifier, Element element) {
+ return identifier.staticElement?.declaration == element.declaration;
+ }
+
int length = identifiers.length;
for (int i = 0; i < length; i++) {
- Identifier identifier = identifiers[i];
+ var identifier = identifiers[i];
if (element is PropertyAccessorElement) {
// If the getter or setter of a variable is used, then the variable (the
// shown name) is used.
- if (identifier.staticElement == element.variable) {
+ if (hasElement(identifier, element.variable)) {
identifiers.remove(identifier);
break;
}
} else {
- if (identifier.staticElement == element) {
+ if (hasElement(identifier, element)) {
identifiers.remove(identifier);
break;
}
diff --git a/pkg/analyzer/lib/src/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
index 9467514..b4242a8 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
@@ -559,6 +559,7 @@
nameOffset: -1, // TODO(scheglov) implement, test
);
augmentation.definingCompilationUnit = definingUnit;
+ augmentation.reference = definingUnit.reference!;
final resolutionOffset = _baseResolutionOffset + _reader.readUInt30();
_readLibraryOrAugmentationElement(augmentation);
@@ -988,7 +989,9 @@
final uri = _readDirectiveUri(
container: container,
);
- final prefix = _readImportElementPrefix();
+ final prefix = _readImportElementPrefix(
+ container: container,
+ );
final combinators = _reader.readTypedList(_readNamespaceCombinator);
final element = LibraryImportElementImpl(
@@ -1000,9 +1003,13 @@
return element;
}
- ImportElementPrefixImpl? _readImportElementPrefix() {
+ ImportElementPrefixImpl? _readImportElementPrefix({
+ required LibraryOrAugmentationElementImpl container,
+ }) {
PrefixElementImpl buildElement(String name) {
- final reference = _reference.getChild('@prefix').getChild(name);
+ // TODO(scheglov) Make reference required.
+ final containerRef = container.reference!;
+ final reference = containerRef.getChild('@prefix').getChild(name);
final existing = reference.element;
if (existing is PrefixElementImpl) {
return existing;
diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart
index 690daa8..b18aafb 100644
--- a/pkg/analyzer/lib/src/summary2/library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/library_builder.dart
@@ -159,7 +159,7 @@
void buildElements() {
_buildDirectives(
kind: kind,
- element: element,
+ container: element,
);
for (var linkingUnit in units) {
@@ -467,10 +467,11 @@
nameOffset: importedAugmentation.unlinked.libraryKeywordOffset,
);
augmentation.definingCompilationUnit = unitElement;
+ augmentation.reference = unitElement.reference!;
_buildDirectives(
kind: importedAugmentation,
- element: augmentation,
+ container: augmentation,
);
uri = DirectiveUriWithAugmentationImpl(
@@ -537,13 +538,18 @@
/// augmentations.
void _buildDirectives({
required LibraryOrAugmentationFileKind kind,
- required LibraryOrAugmentationElementImpl element,
+ required LibraryOrAugmentationElementImpl container,
}) {
- element.libraryExports = kind.libraryExports.map(_buildExport).toList();
- element.libraryImports = kind.libraryImports.map(_buildImport).toList();
+ container.libraryExports = kind.libraryExports.map(_buildExport).toList();
+ container.libraryImports = kind.libraryImports.map((state) {
+ return _buildImport(
+ container: container,
+ state: state,
+ );
+ }).toList();
- element.augmentationImports = kind.augmentationImports.map((state) {
- return _buildAugmentationImport(element, state);
+ container.augmentationImports = kind.augmentationImports.map((state) {
+ return _buildAugmentationImport(container, state);
}).toList();
}
@@ -614,21 +620,23 @@
)..combinators = combinators;
}
- LibraryImportElementImpl _buildImport(LibraryImportState state) {
+ LibraryImportElementImpl _buildImport({
+ required LibraryOrAugmentationElementImpl container,
+ required LibraryImportState state,
+ }) {
final importPrefix = state.unlinked.prefix.mapOrNull((unlinked) {
+ final prefix = _buildPrefix(
+ name: unlinked.name,
+ nameOffset: unlinked.nameOffset,
+ container: container,
+ );
if (unlinked.deferredOffset != null) {
return DeferredImportElementPrefixImpl(
- element: _buildPrefix(
- name: unlinked.name,
- nameOffset: unlinked.nameOffset,
- ),
+ element: prefix,
);
} else {
return ImportElementPrefixImpl(
- element: _buildPrefix(
- name: unlinked.name,
- nameOffset: unlinked.nameOffset,
- ),
+ element: prefix,
);
}
});
@@ -705,8 +713,11 @@
PrefixElementImpl _buildPrefix({
required String name,
required int nameOffset,
+ required LibraryOrAugmentationElementImpl container,
}) {
- final reference = this.reference.getChild('@prefix').getChild(name);
+ // TODO(scheglov) Make reference required.
+ final containerRef = container.reference!;
+ final reference = containerRef.getChild('@prefix').getChild(name);
final existing = reference.element;
if (existing is PrefixElementImpl) {
return existing;
@@ -716,7 +727,7 @@
nameOffset,
reference: reference,
);
- element.encloseElement(result);
+ container.encloseElement(result);
return result;
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
index 3a0d6d5..061e109 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
@@ -2230,7 +2230,13 @@
var constructorName = creation.constructorName;
expect(constructorName.name, isNull);
- expect(constructorName.staticElement, defaultConstructor);
+ assertElement(
+ constructorName.staticElement,
+ elementMatcher(
+ defaultConstructor,
+ substitution: {'T': 'int'},
+ ),
+ );
NamedType namedType = constructorName.type;
expect(namedType.typeArguments, isNull);
@@ -2258,9 +2264,21 @@
expect(creation.staticType, cTypeDouble);
var constructorName = creation.constructorName;
- expect(constructorName.name!.staticElement, namedConstructor);
+ assertElement(
+ constructorName.name!.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'dynamic'},
+ ),
+ );
expect(constructorName.name!.staticType, isNull);
- expect(constructorName.staticElement, namedConstructor);
+ assertElement(
+ constructorName.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'double'},
+ ),
+ );
NamedType namedType = constructorName.type;
expect(namedType.typeArguments, isNull);
@@ -2288,9 +2306,21 @@
expect(creation.staticType, cTypeBool);
var constructorName = creation.constructorName;
- expect(constructorName.name!.staticElement, namedConstructor);
+ assertElement(
+ constructorName.name!.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'bool'},
+ ),
+ );
expect(constructorName.name!.staticType, isNull);
- expect(constructorName.staticElement, namedConstructor);
+ assertElement(
+ constructorName.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'bool'},
+ ),
+ );
NamedType namedType = constructorName.type;
expect(namedType.typeArguments!.arguments, hasLength(1));
@@ -2345,7 +2375,13 @@
var constructorName = creation.constructorName;
expect(constructorName.name, isNull);
- expect(constructorName.staticElement, defaultConstructor);
+ assertElement(
+ constructorName.staticElement,
+ elementMatcher(
+ defaultConstructor,
+ substitution: {'T': 'int'},
+ ),
+ );
NamedType namedType = constructorName.type;
expect(namedType.typeArguments, isNull);
@@ -2367,7 +2403,13 @@
var constructorName = creation.constructorName;
expect(constructorName.name, isNull);
- expect(constructorName.staticElement, defaultConstructor);
+ assertElement(
+ constructorName.staticElement,
+ elementMatcher(
+ defaultConstructor,
+ substitution: {'T': 'bool'},
+ ),
+ );
NamedType namedType = constructorName.type;
expect(namedType.typeArguments!.arguments, hasLength(1));
@@ -2390,9 +2432,21 @@
expect(creation.staticType, cTypeDouble);
var constructorName = creation.constructorName;
- expect(constructorName.name!.staticElement, namedConstructor);
+ assertElement(
+ constructorName.name!.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'dynamic'},
+ ),
+ );
expect(constructorName.name!.staticType, isNull);
- expect(constructorName.staticElement, namedConstructor);
+ assertElement(
+ constructorName.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'double'},
+ ),
+ );
NamedType namedType = constructorName.type;
expect(namedType.typeArguments, isNull);
@@ -2413,9 +2467,21 @@
expect(creation.staticType, cTypeBool);
var constructorName = creation.constructorName;
- expect(constructorName.name!.staticElement, namedConstructor);
+ assertElement(
+ constructorName.name!.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'bool'},
+ ),
+ );
expect(constructorName.name!.staticType, isNull);
- expect(constructorName.staticElement, namedConstructor);
+ assertElement(
+ constructorName.staticElement,
+ elementMatcher(
+ namedConstructor,
+ substitution: {'T': 'bool'},
+ ),
+ );
NamedType namedType = constructorName.type;
expect(namedType.typeArguments!.arguments, hasLength(1));
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 3fa8eab..0d394cc 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -23,6 +23,7 @@
defineReflectiveTests(FieldElementImplTest);
defineReflectiveTests(FunctionTypeImplTest);
defineReflectiveTests(InterfaceTypeImplTest);
+ defineReflectiveTests(MethodElementImplTest);
defineReflectiveTests(TypeParameterTypeImplTest);
defineReflectiveTests(VoidTypeImplTest);
defineReflectiveTests(ClassElementImplTest);
@@ -1241,6 +1242,30 @@
}
@reflectiveTest
+class MethodElementImplTest extends AbstractTypeSystemTest {
+ void test_equal() {
+ var foo = method('foo', intNone);
+ var T = typeParameter('T');
+ var A = class_(
+ name: 'A',
+ typeParameters: [T],
+ methods: [foo],
+ );
+
+ // MethodElementImpl is equal to itself.
+ expect(foo == foo, isTrue);
+
+ // MethodMember is not equal to MethodElementImpl.
+ var foo_int = A.instantiate(
+ typeArguments: [intNone],
+ nullabilitySuffix: NullabilitySuffix.none,
+ ).getMethod('foo')!;
+ expect(foo == foo_int, isFalse);
+ expect(foo_int == foo, isFalse);
+ }
+}
+
+@reflectiveTest
class TopLevelVariableElementImplTest extends PubPackageResolutionTest {
test_computeConstantValue() async {
newFile('$testPackageLibPath/a.dart', r'''
diff --git a/pkg/analyzer/test/src/summary/elements_test.dart b/pkg/analyzer/test/src/summary/elements_test.dart
index c80647b..3d18ac2 100644
--- a/pkg/analyzer/test/src/summary/elements_test.dart
+++ b/pkg/analyzer/test/src/summary/elements_test.dart
@@ -300,7 +300,7 @@
''');
}
- test_augmentation_importScope_constant_field() async {
+ test_augmentation_importScope_constant_class_field() async {
newFile('$testPackageLibPath/a.dart', r'''
class A {
static const a = 0;
@@ -395,6 +395,89 @@
''');
}
+ test_augmentation_importScope_constant_prefix_class_field() async {
+ newFile('$testPackageLibPath/a.dart', r'''
+class A {
+ static const a = 0;
+}
+''');
+
+ newFile('$testPackageLibPath/b.dart', r'''
+library augment 'test.dart';
+import 'a.dart' as prefix;
+const b = prefix.A.a;
+''');
+
+ final library = await buildLibrary(r'''
+import augment 'b.dart';
+''');
+
+ checkElementText(library, r'''
+library
+ augmentationImports
+ package:test/b.dart
+ imports
+ package:test/a.dart as prefix @48
+ definingUnit
+ topLevelVariables
+ static const b @62
+ type: int
+ constantInitializer
+ PropertyAccess
+ target: PrefixedIdentifier
+ prefix: SimpleIdentifier
+ token: prefix @66
+ staticElement: self::@augmentation::package:test/b.dart::@prefix::prefix
+ staticType: null
+ period: . @72
+ identifier: SimpleIdentifier
+ token: A @73
+ staticElement: package:test/a.dart::@class::A
+ staticType: null
+ staticElement: package:test/a.dart::@class::A
+ staticType: null
+ operator: . @74
+ propertyName: SimpleIdentifier
+ token: a @75
+ staticElement: package:test/a.dart::@class::A::@getter::a
+ staticType: int
+ staticType: int
+ accessors
+ synthetic static get b @-1
+ returnType: int
+ definingUnit
+''');
+ }
+
+ test_augmentation_importScope_prefixed() async {
+ newFile('$testPackageLibPath/a.dart', r'''
+class A {}
+''');
+
+ newFile('$testPackageLibPath/b.dart', r'''
+library augment 'test.dart';
+import 'a.dart' as prefix;
+prefix.A f() {}
+''');
+
+ final library = await buildLibrary(r'''
+import augment 'b.dart';
+''');
+
+ checkElementText(library, r'''
+library
+ augmentationImports
+ package:test/b.dart
+ imports
+ package:test/a.dart as prefix @48
+ definingUnit
+ functions
+ f @65
+ returnType: A
+ definingUnit
+''');
+ }
+
test_augmentation_importScope_topInference() async {
newFile('$testPackageLibPath/a.dart', r'''
final a = 0;
diff --git a/pkg/compiler/lib/compiler_api.dart b/pkg/compiler/lib/compiler_api.dart
index 893b07e..bb73103 100644
--- a/pkg/compiler/lib/compiler_api.dart
+++ b/pkg/compiler/lib/compiler_api.dart
@@ -108,6 +108,20 @@
/// is expected to hold a zero element at the last position. If this is not
/// the case, the entire data structure is copied before scanning.
Future<Input> readFromUri(Uri uri, {InputKind inputKind = InputKind.UTF8});
+
+ /// Register that [uri] should be an `InputKind.UTF8` input with the
+ /// given [source] as its zero-terminated list of contents.
+ ///
+ /// If [uri] was read prior to this call, this registration has no effect,
+ /// otherwise it is expected that a future [readFromUri] will return the
+ /// contents provided here.
+ ///
+ /// The main purpose of this API is to assist in error reporting when
+ /// compiling from kernel binary files. Binary files embed the contents
+ /// of source files that may not be available on disk. By using these
+ /// registered contents, dart2js will be able to provide accurate line/column
+ /// information on an error.
+ void registerUtf8ContentsForDiagnostics(Uri uri, List<int> source);
}
/// Output types used in `CompilerOutput.createOutputSink`.
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index bb3680f..7765e59 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -1085,7 +1085,6 @@
return result;
}
- diagnosticHandler.autoReadFileUri = true;
CompilerOptions compilerOptions = CompilerOptions.parse(options,
featureOptions: features,
librariesSpecificationUri: librariesSpecificationUri,
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index 4eb1c89..25a334b 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -104,11 +104,11 @@
/// [FeatureOption]s which default to enabled.
late final List<FeatureOption> shipping = [
useContentSecurityPolicy,
+ deferredSerialization,
];
/// [FeatureOption]s which default to disabled.
late final List<FeatureOption> canary = [
- deferredSerialization,
writeUtf8,
newDumpInfo,
simpleAsyncToFuture,
diff --git a/pkg/compiler/lib/src/phase/load_kernel.dart b/pkg/compiler/lib/src/phase/load_kernel.dart
index de39f19..6145d84 100644
--- a/pkg/compiler/lib/src/phase/load_kernel.dart
+++ b/pkg/compiler/lib/src/phase/load_kernel.dart
@@ -196,6 +196,8 @@
if (options.cfeOnly) {
_doGlobalTransforms(component);
}
+
+ registerSources(component, compilerInput);
return _LoadFromKernelResult(component, entryLibrary, moduleLibraries);
}
@@ -287,6 +289,7 @@
if (isModularCompile) {
component?.computeCanonicalNames();
}
+ registerSources(component, compilerInput);
return _LoadFromSourceResult(
component, initializedCompilerState, isModularCompile ? sources : []);
}
@@ -394,3 +397,16 @@
return _createOutput(options, reporter, entryLibrary, component,
moduleLibraries, initializedCompilerState);
}
+
+/// Registers with the dart2js compiler all sources embeded in a kernel
+/// component. This may include sources that were read from disk directly as
+/// files, but also sources that were embedded in binary `.dill` files (like the
+/// platform kernel file and kernel files from modular compilation pipelines).
+///
+/// This registration improves how locations are presented when errors
+/// or crashes are reported by the dart2js compiler.
+void registerSources(ir.Component? component, api.CompilerInput compilerInput) {
+ component?.uriToSource.forEach((uri, source) {
+ compilerInput.registerUtf8ContentsForDiagnostics(uri, source.source);
+ });
+}
diff --git a/pkg/compiler/lib/src/serialization/indexed_sink_source.dart b/pkg/compiler/lib/src/serialization/indexed_sink_source.dart
index ec54310..b341713 100644
--- a/pkg/compiler/lib/src/serialization/indexed_sink_source.dart
+++ b/pkg/compiler/lib/src/serialization/indexed_sink_source.dart
@@ -18,8 +18,6 @@
void write(E value, void writeValue(E value));
}
-const int _defaultStartOffset = 1;
-
/// Data sink helper that canonicalizes [E?] values using IDs.
///
/// Writes a unique ID in place of previously visited indexable values. This
@@ -39,7 +37,7 @@
{Map<E?, int>? cache, int? startOffset})
: // [cache] slot 1 is pre-allocated to `null`.
this._cache = cache ?? {null: 1},
- this._startOffset = startOffset ?? _defaultStartOffset;
+ this._startOffset = startOffset ?? 0;
/// Write a reference to [value] to the data sink.
///
diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart
index ee9dea5..8813a7f 100644
--- a/pkg/compiler/lib/src/source_file_provider.dart
+++ b/pkg/compiler/lib/src/source_file_provider.dart
@@ -29,15 +29,7 @@
if (!resourceUri.isAbsolute) {
resourceUri = cwd.resolveUri(resourceUri);
}
- api.Input<List<int>> input;
- switch (inputKind) {
- case api.InputKind.UTF8:
- input = utf8SourceFiles[resourceUri];
- break;
- case api.InputKind.binary:
- input = binarySourceFiles[resourceUri];
- break;
- }
+ api.Input<List<int>> input = _loadInputFromCache(resourceUri, inputKind);
if (input != null) return Future.value(input);
if (resourceUri.isScheme('file')) {
@@ -49,6 +41,52 @@
}
}
+ /// Fetches any existing value of [resourceUri] in a cache.
+ ///
+ /// For `api.InputKind.UTF8` inputs, this looks up both the cache of
+ /// utf8 source files and binary source files. This is done today because of
+ /// how dart2js binds to the CFE's file system. While dart2js reads sources as
+ /// utf8, the CFE file system may read them as binary inputs. In case the CFE
+ /// needs to report errors, dart2js will only find the location data if it
+ /// checks both caches.
+ api.Input<List<int>> _loadInputFromCache(
+ Uri resourceUri, api.InputKind inputKind) {
+ switch (inputKind) {
+ case api.InputKind.UTF8:
+ var input = utf8SourceFiles[resourceUri];
+ if (input != null) return input;
+ input = binarySourceFiles[resourceUri];
+ if (input == null) return null;
+ return _storeSourceInCache(resourceUri, input.data, api.InputKind.UTF8);
+ case api.InputKind.binary:
+ return binarySourceFiles[resourceUri];
+ }
+ return null;
+ }
+
+ /// Adds [source] to the cache under the [resourceUri] key.
+ api.Input _storeSourceInCache(
+ Uri resourceUri, List<int> source, api.InputKind inputKind) {
+ switch (inputKind) {
+ case api.InputKind.UTF8:
+ return utf8SourceFiles[resourceUri] = CachingUtf8BytesSourceFile(
+ resourceUri, relativizeUri(resourceUri), source);
+ case api.InputKind.binary:
+ return binarySourceFiles[resourceUri] = Binary(resourceUri, source);
+ }
+ return null;
+ }
+
+ @override
+ void registerUtf8ContentsForDiagnostics(Uri resourceUri, List<int> source) {
+ if (!resourceUri.isAbsolute) {
+ resourceUri = cwd.resolveUri(resourceUri);
+ }
+ if (!utf8SourceFiles.containsKey(resourceUri)) {
+ _storeSourceInCache(resourceUri, source, api.InputKind.UTF8);
+ }
+ }
+
api.Input _readFromFileSync(Uri resourceUri, api.InputKind inputKind) {
assert(resourceUri.isScheme('file'));
List<int> source;
@@ -61,29 +99,19 @@
throw "Error reading '${relativizeUri(resourceUri)}' $detail";
}
dartCharactersRead += source.length;
- api.Input input;
- switch (inputKind) {
- case api.InputKind.UTF8:
- input = utf8SourceFiles[resourceUri] = CachingUtf8BytesSourceFile(
- resourceUri, relativizeUri(resourceUri), source);
- break;
- case api.InputKind.binary:
- input = binarySourceFiles[resourceUri] = Binary(resourceUri, source);
- break;
- }
- return input;
+ return _storeSourceInCache(resourceUri, source, inputKind);
}
/// Read [resourceUri] directly as a UTF-8 file. If reading fails, `null` is
/// returned.
- api.Input autoReadFromFile(Uri resourceUri) {
+ api.Input readUtf8FromFileSyncForTesting(Uri resourceUri) {
try {
return _readFromFileSync(resourceUri, api.InputKind.UTF8);
} catch (e) {
// Silence the error. The [resourceUri] was not requested by the user and
// was only needed to give better error messages.
+ return null;
}
- return null;
}
Future<api.Input<List<int>>> _readFromFile(
@@ -139,11 +167,14 @@
relativizeUri(Uri uri) => fe.relativizeUri(cwd, uri, isWindows);
SourceFile<List<int>> getUtf8SourceFile(Uri resourceUri) {
- return utf8SourceFiles[resourceUri];
+ return _loadInputFromCache(resourceUri, api.InputKind.UTF8);
}
Iterable<Uri> getSourceUris() {
Set<Uri> uris = Set<Uri>();
+ // Note: this includes also indirect sources that were used to create
+ // `.dill` inputs to the compiler. This is OK, since this API is only
+ // used to calculate DEPS for gn build systems.
uris.addAll(utf8SourceFiles.keys);
uris.addAll(binarySourceFiles.keys);
return uris;
@@ -179,7 +210,6 @@
bool isAborting = false;
bool enableColors = false;
bool throwOnError = false;
- bool autoReadFileUri = false;
int throwOnErrorCount = 0;
api.Diagnostic lastKind = null;
int fatalCount = 0;
@@ -265,17 +295,6 @@
print('${color(message)}');
} else {
api.Input file = provider.getUtf8SourceFile(uri);
- if (file == null &&
- autoReadFileUri &&
- (uri.isScheme('file') || !uri.isAbsolute) &&
- uri.path.endsWith('.dart')) {
- if (!uri.isAbsolute) {
- uri = provider.cwd.resolveUri(uri);
- }
- // When reading from .dill files, the original source files haven't been
- // loaded. Load the file if possible to provide a better error message.
- file = provider.autoReadFromFile(uri);
- }
if (file is SourceFile) {
print(file.getLocationMessage(color(message), begin, end,
colorize: color));
@@ -574,21 +593,6 @@
}
return result;
}
-
- @override
- api.Input autoReadFromFile(Uri resourceUri) {
- var path = resourceUri.path;
- if (path.startsWith('/bazel-root')) {
- path = path.substring('/bazel-root/'.length);
- for (var dir in dirs) {
- var file = dir.resolve(path);
- if (File.fromUri(file).existsSync()) {
- return super.autoReadFromFile(file);
- }
- }
- }
- return null;
- }
}
/// Adapter to support one or more synthetic uri schemes.
@@ -635,18 +639,4 @@
}
return result;
}
-
- @override
- api.Input autoReadFromFile(Uri resourceUri) {
- if (resourceUri.isScheme(markerScheme)) {
- var path = resourceUri.path;
- for (var dir in roots) {
- var file = dir.resolve(path);
- if (File.fromUri(file).existsSync()) {
- return super.autoReadFromFile(file);
- }
- }
- }
- return null;
- }
}
diff --git a/pkg/compiler/test/dump_info/data/deferred/main.dart b/pkg/compiler/test/dump_info/data/deferred/main.dart
index 95af0bd..b562e90 100644
--- a/pkg/compiler/test/dump_info/data/deferred/main.dart
+++ b/pkg/compiler/test/dump_info/data/deferred/main.dart
@@ -4,7 +4,122 @@
// @dart = 2.7
-/*library:
+/*spec.library:
+ constant=[
+ {
+ "id": "constant/B.C_Deferred = A.lib__funky$closure();\n",
+ "kind": "constant",
+ "name": "",
+ "size": 39,
+ "outputUnit": "outputUnit/1",
+ "code": "B.C_Deferred = A.lib__funky$closure();\n"
+},
+ {
+ "id": "constant/B.C_JS_CONST = function getTagFallback(o) {\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n};\n",
+ "kind": "constant",
+ "name": "",
+ "size": 131,
+ "outputUnit": "outputUnit/main",
+ "code": "B.C_JS_CONST = function getTagFallback(o) {\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n};\n"
+},
+ {
+ "id": "constant/B.C__RootZone = new A._RootZone();\n",
+ "kind": "constant",
+ "name": "",
+ "size": 35,
+ "outputUnit": "outputUnit/main",
+ "code": "B.C__RootZone = new A._RootZone();\n"
+},
+ {
+ "id": "constant/B.C__StringStackTrace = new A._StringStackTrace();\n",
+ "kind": "constant",
+ "name": "",
+ "size": 51,
+ "outputUnit": "outputUnit/main",
+ "code": "B.C__StringStackTrace = new A._StringStackTrace();\n"
+},
+ {
+ "id": "constant/B.Interceptor_methods = J.Interceptor.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 49,
+ "outputUnit": "outputUnit/main",
+ "code": "B.Interceptor_methods = J.Interceptor.prototype;\n"
+},
+ {
+ "id": "constant/B.JSArray_methods = J.JSArray.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 41,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSArray_methods = J.JSArray.prototype;\n"
+},
+ {
+ "id": "constant/B.JSInt_methods = J.JSInt.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 37,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSInt_methods = J.JSInt.prototype;\n"
+},
+ {
+ "id": "constant/B.JSString_methods = J.JSString.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 43,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSString_methods = J.JSString.prototype;\n"
+},
+ {
+ "id": "constant/B.JavaScriptObject_methods = J.JavaScriptObject.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 59,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JavaScriptObject_methods = J.JavaScriptObject.prototype;\n"
+}],
+ deferredFiles=[{
+ "main.dart": {
+ "name": "<unnamed>",
+ "imports": {
+ "lib": [
+ "out_1.part.js"
+ ]
+ }
+ }
+}],
+ dependencies=[{}],
+ library=[{
+ "id": "library/memory:sdk/tests/web/native/main.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 301,
+ "children": [
+ "function/memory:sdk/tests/web/native/main.dart::main"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/main.dart"
+}],
+ outputUnits=[
+ {
+ "id": "outputUnit/1",
+ "kind": "outputUnit",
+ "name": "1",
+ "size": 1087,
+ "filename": "out_1.part.js",
+ "imports": [
+ "lib"
+ ]
+},
+ {
+ "id": "outputUnit/main",
+ "kind": "outputUnit",
+ "name": "main",
+ "filename": "out",
+ "imports": []
+}]
+*/
+
+/*canary.library:
constant=[
{
"id": "constant/B.C_Deferred = A.lib__funky$closure();\n",
diff --git a/pkg/compiler/test/dump_info/data/deferred_future/main.dart b/pkg/compiler/test/dump_info/data/deferred_future/main.dart
index e95b65c..0d5b68a 100644
--- a/pkg/compiler/test/dump_info/data/deferred_future/main.dart
+++ b/pkg/compiler/test/dump_info/data/deferred_future/main.dart
@@ -2,7 +2,130 @@
// 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.
-/*library:
+/*spec.library:
+ constant=[
+ {
+ "id": "constant/B.C_A = new A.A();\n",
+ "kind": "constant",
+ "name": "",
+ "size": 19,
+ "outputUnit": "outputUnit/1",
+ "code": "B.C_A = new A.A();\n"
+},
+ {
+ "id": "constant/B.C_Deferred = B.C_A;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 22,
+ "outputUnit": "outputUnit/1",
+ "code": "B.C_Deferred = B.C_A;\n"
+},
+ {
+ "id": "constant/B.C_JS_CONST = function getTagFallback(o) {\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n};\n",
+ "kind": "constant",
+ "name": "",
+ "size": 131,
+ "outputUnit": "outputUnit/main",
+ "code": "B.C_JS_CONST = function getTagFallback(o) {\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n};\n"
+},
+ {
+ "id": "constant/B.C__RootZone = new A._RootZone();\n",
+ "kind": "constant",
+ "name": "",
+ "size": 35,
+ "outputUnit": "outputUnit/main",
+ "code": "B.C__RootZone = new A._RootZone();\n"
+},
+ {
+ "id": "constant/B.C__StringStackTrace = new A._StringStackTrace();\n",
+ "kind": "constant",
+ "name": "",
+ "size": 51,
+ "outputUnit": "outputUnit/main",
+ "code": "B.C__StringStackTrace = new A._StringStackTrace();\n"
+},
+ {
+ "id": "constant/B.Interceptor_methods = J.Interceptor.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 49,
+ "outputUnit": "outputUnit/main",
+ "code": "B.Interceptor_methods = J.Interceptor.prototype;\n"
+},
+ {
+ "id": "constant/B.JSArray_methods = J.JSArray.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 41,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSArray_methods = J.JSArray.prototype;\n"
+},
+ {
+ "id": "constant/B.JSInt_methods = J.JSInt.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 37,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSInt_methods = J.JSInt.prototype;\n"
+},
+ {
+ "id": "constant/B.JSString_methods = J.JSString.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 43,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JSString_methods = J.JSString.prototype;\n"
+},
+ {
+ "id": "constant/B.JavaScriptObject_methods = J.JavaScriptObject.prototype;\n",
+ "kind": "constant",
+ "name": "",
+ "size": 59,
+ "outputUnit": "outputUnit/main",
+ "code": "B.JavaScriptObject_methods = J.JavaScriptObject.prototype;\n"
+}],
+ deferredFiles=[{
+ "main.dart": {
+ "name": "<unnamed>",
+ "imports": {
+ "lib1": [
+ "out_1.part.js"
+ ]
+ }
+ }
+}],
+ dependencies=[{}],
+ library=[{
+ "id": "library/memory:sdk/tests/web/native/main.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 857,
+ "children": [
+ "function/memory:sdk/tests/web/native/main.dart::main"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/main.dart"
+}],
+ outputUnits=[
+ {
+ "id": "outputUnit/1",
+ "kind": "outputUnit",
+ "name": "1",
+ "size": 870,
+ "filename": "out_1.part.js",
+ "imports": [
+ "lib1"
+ ]
+},
+ {
+ "id": "outputUnit/main",
+ "kind": "outputUnit",
+ "name": "main",
+ "filename": "out",
+ "imports": []
+}]
+*/
+
+/*canary.library:
constant=[
{
"id": "constant/B.C_A = new A.A();\n",
diff --git a/pkg/compiler/test/equivalence/show_helper.dart b/pkg/compiler/test/equivalence/show_helper.dart
index 4aa3850..a022064 100644
--- a/pkg/compiler/test/equivalence/show_helper.dart
+++ b/pkg/compiler/test/equivalence/show_helper.dart
@@ -71,7 +71,7 @@
if (show != null && !show.any((f) => '$fileUri'.endsWith(f))) {
continue;
}
- SourceFile sourceFile = await provider.autoReadFromFile(fileUri);
+ SourceFile sourceFile = provider.readUtf8FromFileSyncForTesting(fileUri);
String sourceCode = sourceFile?.slowText();
if (sourceCode == null) {
sourceCode = new File.fromUri(fileUri).readAsStringSync();
diff --git a/pkg/compiler/test/helpers/memory_compiler.dart b/pkg/compiler/test/helpers/memory_compiler.dart
index 310120a..451ebc7 100644
--- a/pkg/compiler/test/helpers/memory_compiler.dart
+++ b/pkg/compiler/test/helpers/memory_compiler.dart
@@ -60,13 +60,10 @@
api.CompilerDiagnostics handler = diagnostics;
if (showDiagnostics) {
if (diagnostics == null) {
- handler = new FormattingDiagnosticHandler(provider)
- ..verbose = verbose
- ..autoReadFileUri = true;
+ handler = new FormattingDiagnosticHandler(provider)..verbose = verbose;
} else {
var formattingHandler = new FormattingDiagnosticHandler(provider)
- ..verbose = verbose
- ..autoReadFileUri = true;
+ ..verbose = verbose;
handler = new MultiDiagnostics([diagnostics, formattingHandler]);
}
} else if (diagnostics == null) {
diff --git a/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart b/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart
index 35628cd..3d20d8e 100644
--- a/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart
+++ b/pkg/compiler/test/sourcemaps/helpers/sourcemap_helper.dart
@@ -105,7 +105,7 @@
@override
SourceFile getSourceFile(uri) {
SourceFile sourceFile = sourceFileProvider.getUtf8SourceFile(uri);
- sourceFile ??= sourceFileProvider.autoReadFromFile(uri);
+ sourceFile ??= sourceFileProvider.readUtf8FromFileSyncForTesting(uri);
if (sourceFile == null) {
sourceFile = outputProvider.getSourceFile(uri);
}
diff --git a/pkg/dev_compiler/bin/dartdevc.dart b/pkg/dev_compiler/bin/dartdevc.dart
index 09d9ca8..7ca5376 100644
--- a/pkg/dev_compiler/bin/dartdevc.dart
+++ b/pkg/dev_compiler/bin/dartdevc.dart
@@ -3,8 +3,6 @@
// 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.
-// @dart = 2.9
-
/// Command line entry point for Dart Development Compiler (dartdevc), used to
/// compile a collection of dart libraries into a single JS module
@@ -16,6 +14,6 @@
///
/// [sendPort] may be passed in when started in an isolate. If provided, it is
/// used for bazel worker communication instead of stdin/stdout.
-Future main(List<String> args, [SendPort sendPort]) async {
+Future main(List<String> args, [SendPort? sendPort]) async {
return ddc.internalMain(args, sendPort);
}
diff --git a/pkg/dev_compiler/lib/dev_compiler.dart b/pkg/dev_compiler/lib/dev_compiler.dart
index 899fd4f..ca0a8bd 100644
--- a/pkg/dev_compiler/lib/dev_compiler.dart
+++ b/pkg/dev_compiler/lib/dev_compiler.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
// The dev_compiler does not have a publishable public API, instead this is
// intended for other consumers within the Dart SDK.
export 'src/compiler/module_builder.dart' show ModuleFormat, parseModuleFormat;
diff --git a/pkg/dev_compiler/tool/compile_dartdevc_sdk.dart b/pkg/dev_compiler/tool/compile_dartdevc_sdk.dart
index 2fcc44e..f24c12e 100644
--- a/pkg/dev_compiler/tool/compile_dartdevc_sdk.dart
+++ b/pkg/dev_compiler/tool/compile_dartdevc_sdk.dart
@@ -3,8 +3,6 @@
// 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.
-// @dart = 2.9
-
/// Tool that consumes the .dill file of an entire dart-sdk and produces the
/// corresponding Javascript module.
diff --git a/pkg/test_runner/tool/update_static_error_tests.dart b/pkg/test_runner/tool/update_static_error_tests.dart
index a66e98c..2259c4a 100644
--- a/pkg/test_runner/tool/update_static_error_tests.dart
+++ b/pkg/test_runner/tool/update_static_error_tests.dart
@@ -21,8 +21,7 @@
"Usage: dart update_static_error_tests.dart [flags...] <path glob>";
final _dartPath = _findBinary("dart", "exe");
-final _analyzerPath = _findBinary("dartanalyzer", "bat");
-final _dart2jsPath = _findBinary("dart2js", "bat");
+final _analyzerPath = p.join('pkg', 'analyzer_cli', 'bin', 'analyzer.dart');
Future<void> main(List<String> args) async {
var sources = ErrorSource.all.map((e) => e.marker).toList();
@@ -210,7 +209,8 @@
// TODO(rnystrom): Running the analyzer command line each time is very slow.
// Either import the analyzer as a library, or at least invoke it in a batch
// mode.
- var result = await Process.run(_analyzerPath, [
+ var result = await Process.run(_dartPath, [
+ _analyzerPath,
...options,
"--format=json",
file.absolute.path,
@@ -265,7 +265,9 @@
/// Invoke dart2js on [file] and gather all static errors it reports.
Future<List<StaticError>> runDart2js(
File file, List<String> options, List<StaticError> cfeErrors) async {
- var result = await Process.run(_dart2jsPath, [
+ var result = await Process.run(_dartPath, [
+ 'compile',
+ 'js',
...options,
"-o",
"dev:null", // Output is only created for file URIs.
diff --git a/runtime/lib/date.cc b/runtime/lib/date.cc
index e605c05..118461f 100644
--- a/runtime/lib/date.cc
+++ b/runtime/lib/date.cc
@@ -36,11 +36,6 @@
return Integer::New(offset);
}
-DEFINE_NATIVE_ENTRY(DateTime_localTimeZoneAdjustmentInSeconds, 0, 0) {
- int adjustment = OS::GetLocalTimeZoneAdjustmentInSeconds();
- return Integer::New(adjustment);
-}
-
DEFINE_NATIVE_ENTRY(DateTime_currentTimeMicros, 0, 0) {
return Integer::New(OS::GetCurrentTimeMicros());
}
diff --git a/runtime/vm/bootstrap_natives.h b/runtime/vm/bootstrap_natives.h
index 6e82679..a380012 100644
--- a/runtime/vm/bootstrap_natives.h
+++ b/runtime/vm/bootstrap_natives.h
@@ -145,7 +145,6 @@
V(DateTime_currentTimeMicros, 0) \
V(DateTime_timeZoneName, 1) \
V(DateTime_timeZoneOffsetInSeconds, 1) \
- V(DateTime_localTimeZoneAdjustmentInSeconds, 0) \
V(AssertionError_throwNew, 3) \
V(AssertionError_throwNewSource, 4) \
V(Error_throwWithStackTrace, 2) \
diff --git a/runtime/vm/os.h b/runtime/vm/os.h
index ccc0bf7..d0f9e4c 100644
--- a/runtime/vm/os.h
+++ b/runtime/vm/os.h
@@ -34,11 +34,6 @@
// For example 3600 for CET, and 7200 for CEST.
static int GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch);
- // Returns the difference in seconds between local time and UTC when no
- // daylight saving is active.
- // For example 3600 in CET and CEST.
- static int GetLocalTimeZoneAdjustmentInSeconds();
-
// Returns the current time in milliseconds measured
// from midnight January 1, 1970 UTC.
static int64_t GetCurrentTimeMillis();
diff --git a/runtime/vm/os_android.cc b/runtime/vm/os_android.cc
index adc2a06..08af326 100644
--- a/runtime/vm/os_android.cc
+++ b/runtime/vm/os_android.cc
@@ -121,14 +121,6 @@
return succeeded ? static_cast<int>(decomposed.tm_gmtoff) : 0;
}
-int OS::GetLocalTimeZoneAdjustmentInSeconds() {
- // TODO(floitsch): avoid excessive calls to tzset?
- tzset();
- // Even if the offset was 24 hours it would still easily fit into 32 bits.
- // Note that Unix and Dart disagree on the sign.
- return static_cast<int>(-timezone);
-}
-
int64_t OS::GetCurrentTimeMillis() {
return GetCurrentTimeMicros() / 1000;
}
diff --git a/runtime/vm/os_fuchsia.cc b/runtime/vm/os_fuchsia.cc
index aa9684c..07150b3 100644
--- a/runtime/vm/os_fuchsia.cc
+++ b/runtime/vm/os_fuchsia.cc
@@ -415,14 +415,6 @@
return status == ZX_OK ? local_offset + dst_offset : 0;
}
-int OS::GetLocalTimeZoneAdjustmentInSeconds() {
- int32_t local_offset, dst_offset;
- int64_t now_seconds = GetCurrentTimeNanos() / ZX_SEC(1);
- zx_status_t status =
- GetLocalAndDstOffsetInSeconds(now_seconds, &local_offset, &dst_offset);
- return status == ZX_OK ? local_offset : 0;
-}
-
int64_t OS::GetCurrentTimeMillis() {
return GetCurrentTimeNanos() / ZX_MSEC(1);
}
diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc
index 782cd0e..411871a 100644
--- a/runtime/vm/os_linux.cc
+++ b/runtime/vm/os_linux.cc
@@ -440,14 +440,6 @@
return succeeded ? static_cast<int>(decomposed.tm_gmtoff) : 0;
}
-int OS::GetLocalTimeZoneAdjustmentInSeconds() {
- // TODO(floitsch): avoid excessive calls to tzset?
- tzset();
- // Even if the offset was 24 hours it would still easily fit into 32 bits.
- // Note that Unix and Dart disagree on the sign.
- return static_cast<int>(-timezone);
-}
-
int64_t OS::GetCurrentTimeMillis() {
return GetCurrentTimeMicros() / 1000;
}
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc
index 97090fc..a4f58f6 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -60,14 +60,6 @@
return succeeded ? static_cast<int>(decomposed.tm_gmtoff) : 0;
}
-int OS::GetLocalTimeZoneAdjustmentInSeconds() {
- // TODO(floitsch): avoid excessive calls to tzset?
- tzset();
- // Even if the offset was 24 hours it would still easily fit into 32 bits.
- // Note that Unix and Dart disagree on the sign.
- return static_cast<int>(-timezone);
-}
-
int64_t OS::GetCurrentTimeMillis() {
return GetCurrentTimeMicros() / 1000;
}
diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc
index 5a4b01c..a19fb63 100644
--- a/runtime/vm/os_win.cc
+++ b/runtime/vm/os_win.cc
@@ -106,13 +106,6 @@
}
}
-int OS::GetLocalTimeZoneAdjustmentInSeconds() {
- // TODO(floitsch): avoid excessive calls to _tzset?
- _tzset();
- // Dart and Windows disagree on the sign of the bias.
- return static_cast<int>(-_timezone);
-}
-
int64_t OS::GetCurrentTimeMillis() {
return GetCurrentTimeMicros() / 1000;
}
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
index 3c7ccc7..0d8ebd4 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
@@ -1156,35 +1156,40 @@
}
@notNull
-String typeName(type) => JS('', '''(() => {
- if ($type === void 0) return "undefined type";
- if ($type === null) return "null type";
+String typeName(type) {
+ if (JS<bool>('!', '# === void 0', type)) return 'undefined type';
+ if (JS<bool>('!', '# === null', type)) return 'null type';
// Non-instance types
- if (${_jsInstanceOf(type, DartType)}) {
- return $type.toString();
+ if (_jsInstanceOf(type, DartType)) {
+ return JS<String>('!', '#.toString()', type);
}
// Instance types
- let tag = $type[$_runtimeType];
- if (tag === $Type) {
- let name = $type.name;
- let args = ${getGenericArgs(type)};
+ var tag = JS('', '#[#]', type, _runtimeType);
+ if (JS<bool>('!', '# === #', tag, Type)) {
+ var name = JS<String>('!', '#.name', type);
+ var args = getGenericArgs(type);
if (args == null) return name;
- if (${getGenericClass(type)} == ${getGenericClassStatic<JSArray>()}) name = 'List';
+ if (JS<bool>('!', '# == #', getGenericClass(type),
+ getGenericClassStatic<JSArray>())) {
+ name = 'List';
+ }
- let result = name;
- result += '<';
- for (let i = 0; i < args.length; ++i) {
+ var result = name + '<';
+ for (var i = 0; i < JS<int>('!', '#.length', args); ++i) {
if (i > 0) result += ', ';
- result += $typeName(args[i]);
+ result += typeName(JS('', '#[#]', args, i));
}
result += '>';
return result;
}
- if (tag) return "Not a type: " + tag.name;
- return "JSObject<" + $type.name + ">";
-})()''');
+ // Test the JavaScript "truthiness" of `tag`.
+ if (JS<bool>('!', '!!#', tag)) {
+ return 'Not a type: ' + JS<String>('!', '#.name', tag);
+ }
+ return 'JSObject<' + JS<String>('!', '#.name', type) + '>';
+}
/// Returns true if [ft1] <: [ft2].
@notNull
diff --git a/sdk/lib/_internal/vm/lib/date_patch.dart b/sdk/lib/_internal/vm/lib/date_patch.dart
index d404a16..1fc5550 100644
--- a/sdk/lib/_internal/vm/lib/date_patch.dart
+++ b/sdk/lib/_internal/vm/lib/date_patch.dart
@@ -19,10 +19,6 @@
external static int _timeZoneOffsetInSecondsForClampedSeconds(
int secondsSinceEpoch);
- // Daylight-savings independent adjustment for the local time zone.
- @pragma("vm:external-name", "DateTime_localTimeZoneAdjustmentInSeconds")
- external static int _localTimeZoneAdjustmentInSeconds();
-
static const _MICROSECOND_INDEX = 0;
static const _MILLISECOND_INDEX = 1;
static const _SECOND_INDEX = 2;
diff --git a/sdk/lib/_internal/wasm/lib/date_patch.dart b/sdk/lib/_internal/wasm/lib/date_patch.dart
index f2f0672..9b31078 100644
--- a/sdk/lib/_internal/wasm/lib/date_patch.dart
+++ b/sdk/lib/_internal/wasm/lib/date_patch.dart
@@ -28,10 +28,6 @@
external static int _timeZoneOffsetInSecondsForClampedSeconds(
int secondsSinceEpoch);
- // Daylight-savings independent adjustment for the local time zone.
- @pragma("vm:external-name", "DateTime_localTimeZoneAdjustmentInSeconds")
- external static int _localTimeZoneAdjustmentInSeconds();
-
static const _MICROSECOND_INDEX = 0;
static const _MILLISECOND_INDEX = 1;
static const _SECOND_INDEX = 2;
diff --git a/tools/VERSION b/tools/VERSION
index 1e7230c..f20d368 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 19
PATCH 0
-PRERELEASE 12
+PRERELEASE 13
PRERELEASE_PATCH 0
\ No newline at end of file