Version 2.17.0-88.0.dev
Merge commit 'b285d2103c733a625716cb2562d410e4a5c7d07d' into 'dev'
diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index e47664f..76aed36 100644
--- a/.dart_tool/package_config.json
+++ b/.dart_tool/package_config.json
@@ -11,7 +11,7 @@
"constraint, update this by running tools/generate_package_config.dart."
],
"configVersion": 2,
- "generated": "2022-01-12T18:16:46.198227",
+ "generated": "2022-02-02T12:23:40.780016",
"generator": "tools/generate_package_config.dart",
"packages": [
{
@@ -345,7 +345,7 @@
"name": "glob",
"rootUri": "../third_party/pkg/glob",
"packageUri": "lib/",
- "languageVersion": "2.12"
+ "languageVersion": "2.15"
},
{
"name": "html",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fec38ce..7367659 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,13 @@
The standalone `dartdoc` tool has been removed as
previously announced. Its replacement is the `dart doc` command.
+## 2.16.1 - 2022-02-09
+
+This is a patch release that fixes an AOT precompiler crash when building some
+Flutter apps (issue [flutter/flutter#97301][]).
+
+[flutter/flutter#97301]: https://github.com/flutter/flutter/issues/97301
+
## 2.16.0 - 2022-02-03
### Core libraries
@@ -102,6 +109,14 @@
[an issue]: https://github.com/dart-lang/sdk/issues/new
+- **Breaking Change** [#46100](https://github.com/dart-lang/sdk/issues/46100):
+ The deprecated standalone `pub` tool has been removed.
+ Its replacement is the `dart pub` command.
+ Should you find any issues, or missing features, in the replacement
+ command, kindly file [an issue][].
+
+[an issue]: https://github.com/dart-lang/pub/issues/new
+
#### Pub
- Fixed race conditions in `dart pub get`, `dart run` and `dart pub global run`.
diff --git a/DEPS b/DEPS
index 046a19c..375023d 100644
--- a/DEPS
+++ b/DEPS
@@ -114,7 +114,7 @@
"ffi_rev": "4dd32429880a57b64edaf54c9d5af8a9fa9a4ffb",
"fixnum_rev": "848341f061359ef7ddc0cad472c2ecbb036b28ac",
"file_rev": "0e09370f581ab6388d46fda4cdab66638c0171a1",
- "glob_rev": "a62acf590598f458d3198d9f2930c1c9dd4b1379",
+ "glob_rev": "da1f4595ee2f87982cbcc663d4cac244822d9227",
"html_rev": "00cd3c22dac0e68e6ed9e7e4945101aedb1b3109",
"http_io_rev": "2fa188caf7937e313026557713f7feffedd4978b",
"http_multi_server_rev": "34bf7f04b61cce561f47f7f275c2cc811534a05a",
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index c1661dc..aeb07b2 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -397,7 +397,6 @@
_addBuilder(
_createCompletionSuggestionBuilder(
parameter,
- elementKind: protocol.ElementKind.PARAMETER,
kind: CompletionSuggestionKind.IDENTIFIER,
relevance: relevance,
isNotImported: isNotImportedLibrary,
@@ -1281,21 +1280,15 @@
/// than the kind normally used for the element. If a [prefix] is provided,
/// then the element name (or completion) will be prefixed. The [relevance] is
/// the relevance of the suggestion.
- ///
- /// TODO(scheglov) Consider removing [elementKind]
CompletionSuggestionBuilder? _createCompletionSuggestionBuilder(
Element element, {
String? completion,
- protocol.ElementKind? elementKind,
required CompletionSuggestionKind kind,
required int relevance,
required bool isNotImported,
String? prefix,
}) {
- var elementData = _getElementCompletionData(
- element,
- elementKind: elementKind,
- );
+ var elementData = _getElementCompletionData(element);
if (elementData == null) {
return null;
}
@@ -1316,10 +1309,7 @@
}
/// The non-caching implementation of [_getElementCompletionData].
- ElementCompletionData? _createElementCompletionData(
- Element element, {
- protocol.ElementKind? elementKind,
- }) {
+ ElementCompletionData? _createElementCompletionData(Element element) {
// Do not include operators in suggestions.
if (element is ExecutableElement && element.isOperator) {
return null;
@@ -1328,13 +1318,10 @@
var completion = element.displayName;
var documentation = _getDocumentation(element);
- var suggestedElement = protocol.convertElement(element,
- withNullability: _isNonNullableByDefault);
-
- // TODO(scheglov) Update a copy.
- if (elementKind != null) {
- suggestedElement.kind = elementKind;
- }
+ var suggestedElement = protocol.convertElement(
+ element,
+ withNullability: _isNonNullableByDefault,
+ );
var enclosingElement = element.enclosingElement;
@@ -1422,12 +1409,7 @@
/// Return [ElementCompletionData] for the [element], or `null` if the
/// element cannot be suggested for completion.
- ///
- /// TODO(scheglov) Consider removing [elementKind]
- ElementCompletionData? _getElementCompletionData(
- Element element, {
- protocol.ElementKind? elementKind,
- }) {
+ ElementCompletionData? _getElementCompletionData(Element element) {
ElementCompletionData? result;
var hasCompletionData = element.ifTypeOrNull<HasCompletionData>();
@@ -1435,10 +1417,7 @@
result = hasCompletionData.completionData.ifTypeOrNull();
}
- result ??= _createElementCompletionData(
- element,
- elementKind: elementKind,
- );
+ result ??= _createElementCompletionData(element);
hasCompletionData?.completionData = result;
return result;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/replace_return_type_future.dart b/pkg/analysis_server/lib/src/services/correction/dart/replace_return_type_future.dart
index 9d3b8dd..dfa48e4 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/replace_return_type_future.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/replace_return_type_future.dart
@@ -13,15 +13,24 @@
String _typeArgument = '';
@override
+ bool get canBeAppliedInBulk => true;
+
+ @override
+ bool get canBeAppliedToFile => true;
+
+ @override
List<Object>? get fixArguments => [_typeArgument];
@override
FixKind get fixKind => DartFixKind.REPLACE_RETURN_TYPE_FUTURE;
@override
+ FixKind get multiFixKind => DartFixKind.REPLACE_RETURN_TYPE_FUTURE_MULTI;
+
+ @override
Future<void> compute(ChangeBuilder builder) async {
// prepare the existing type
- var typeAnnotation = node.thisOrAncestorOfType<TypeAnnotation>();
+ var typeAnnotation = _getTypeAnnotation(node);
if (typeAnnotation == null) {
return;
}
@@ -34,4 +43,13 @@
/// Return an instance of this class. Used as a tear-off in `FixProcessor`.
static ReplaceReturnTypeFuture newInstance() => ReplaceReturnTypeFuture();
+
+ static TypeAnnotation? _getTypeAnnotation(AstNode node) {
+ var function = node.thisOrAncestorOfType<FunctionDeclaration>();
+ if (function != null) {
+ return function.returnType;
+ }
+ var method = node.thisOrAncestorOfType<MethodDeclaration>();
+ return method?.returnType;
+ }
}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index 51f8992..5a003bb 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -1288,6 +1288,11 @@
DartFixKindPriority.DEFAULT,
"Return 'Future<{0}>'",
);
+ static const REPLACE_RETURN_TYPE_FUTURE_MULTI = FixKind(
+ 'dart.fix.replace.returnTypeFuture.multi',
+ DartFixKindPriority.IN_FILE,
+ "Return a 'Future' where required in file.",
+ );
static const REPLACE_RETURN_TYPE_ITERABLE = FixKind(
'dart.fix.replace.returnTypeIterable',
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 c3cdf0a..b007623 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -407,6 +407,9 @@
LintNames.avoid_unnecessary_containers: [
FlutterRemoveWidget.newInstance,
],
+ LintNames.avoid_void_async: [
+ ReplaceReturnTypeFuture.newInstance,
+ ],
LintNames.await_only_futures: [
RemoveAwait.newInstance,
],
@@ -666,12 +669,7 @@
DataDriven.newInstance,
ImportLibrary.forType,
],
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT: [
- AddSuperConstructorInvocation.newInstance,
- ],
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_NOT_ENOUGH_POSITIONAL_ARGUMENTS: [
+ CompileTimeErrorCode.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS: [
AddSuperConstructorInvocation.newInstance,
],
CompileTimeErrorCode.INVALID_ANNOTATION: [
diff --git a/pkg/analysis_server/lib/src/services/linter/lint_names.dart b/pkg/analysis_server/lib/src/services/linter/lint_names.dart
index c5df9b7..1a6d4e2 100644
--- a/pkg/analysis_server/lib/src/services/linter/lint_names.dart
+++ b/pkg/analysis_server/lib/src/services/linter/lint_names.dart
@@ -42,6 +42,7 @@
'avoid_unused_constructor_parameters';
static const String avoid_unnecessary_containers =
'avoid_unnecessary_containers';
+ static const String avoid_void_async = 'avoid_void_async';
static const String await_only_futures = 'await_only_futures';
static const String curly_braces_in_flow_control_structures =
'curly_braces_in_flow_control_structures';
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index c463ed9..235ed40 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -1658,7 +1658,7 @@
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
- assertSuggestParameter('e', 'E');
+ assertSuggestLocalVariable('e', 'E');
assertSuggestMethod('a', 'A', null);
assertNotSuggested('Object');
assertNotSuggested('x');
@@ -1671,8 +1671,8 @@
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
- assertSuggestParameter('e', 'Object');
- assertSuggestParameter('s', 'StackTrace');
+ assertSuggestLocalVariable('e', 'Object');
+ assertSuggestLocalVariable('s', 'StackTrace');
assertSuggestMethod('a', 'A', null);
assertNotSuggested('Object');
assertNotSuggested('x');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_return_type_future_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_return_type_future_test.dart
index 818dad5..9f22bf1 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_return_type_future_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_return_type_future_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -11,11 +12,118 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceReturnTypeFutureLintBulkTest);
+ defineReflectiveTests(ReplaceReturnTypeFutureLintTest);
defineReflectiveTests(ReplaceReturnTypeFutureTest);
});
}
@reflectiveTest
+class ReplaceReturnTypeFutureLintBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_void_async;
+
+ Future<void> test_bulk() async {
+ await resolveTestCode('''
+void f1() async {}
+
+void f2() async => null;
+
+class C {
+ void m1() async {}
+
+ void m2() async => null;
+
+ void m3() async {
+ void f() async {};
+ f();
+ }
+}
+''');
+ await assertHasFix('''
+Future<void> f1() async {}
+
+Future<void> f2() async => null;
+
+class C {
+ Future<void> m1() async {}
+
+ Future<void> m2() async => null;
+
+ Future<void> m3() async {
+ Future<void> f() async {};
+ f();
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
+class ReplaceReturnTypeFutureLintTest extends FixProcessorLintTest {
+ @override
+ FixKind get kind => DartFixKind.REPLACE_RETURN_TYPE_FUTURE;
+
+ @override
+ String get lintCode => LintNames.avoid_void_async;
+
+ Future<void> test_function() async {
+ await resolveTestCode('void f() async {}');
+ await assertHasFix('Future<void> f() async {}');
+ }
+
+ Future<void> test_functionInMethod() async {
+ await resolveTestCode('''
+class C {
+ void m() {
+ void f() async {};
+ f();
+ }
+}
+''');
+ await assertHasFix('''
+class C {
+ void m() {
+ Future<void> f() async {};
+ f();
+ }
+}
+''');
+ }
+
+ Future<void> test_functionReturnNull() async {
+ await resolveTestCode('void f() async => null;');
+ await assertHasFix('Future<void> f() async => null;');
+ }
+
+ Future<void> test_method() async {
+ await resolveTestCode('''
+class C {
+ void m() async {}
+}
+''');
+ await assertHasFix('''
+class C {
+ Future<void> m() async {}
+}
+''');
+ }
+
+ Future<void> test_methodReturnNull() async {
+ await resolveTestCode('''
+class C {
+ void m() async => null;
+}
+''');
+ await assertHasFix('''
+class C {
+ Future<void> m() async => null;
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceReturnTypeFutureTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REPLACE_RETURN_TYPE_FUTURE;
@@ -55,6 +163,19 @@
});
}
+ Future<void> test_method() async {
+ await resolveTestCode('''
+class C {
+ int m() async {}
+}
+''');
+ await assertHasFix('''
+class C {
+ Future<int> m() async {}
+}
+''');
+ }
+
Future<void> test_simpleTypeName_withImport() async {
await resolveTestCode('''
import 'dart:async';
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 487f5f95..56c9b15 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -162,6 +162,7 @@
CompileTimeErrorCode.DUPLICATE_PART,
CompileTimeErrorCode.ENUM_CONSTANT_SAME_NAME_AS_ENCLOSING,
CompileTimeErrorCode.ENUM_MIXIN_WITH_INSTANCE_VARIABLE,
+ CompileTimeErrorCode.ENUM_WITH_ABSTRACT_MEMBER,
CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET,
CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP,
CompileTimeErrorCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS,
@@ -211,7 +212,10 @@
CompileTimeErrorCode.IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY,
CompileTimeErrorCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE,
CompileTimeErrorCode.ILLEGAL_ASYNC_RETURN_TYPE,
+ CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION,
+ CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE,
CompileTimeErrorCode.ILLEGAL_LANGUAGE_VERSION_OVERRIDE,
+ CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX,
CompileTimeErrorCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE,
CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS,
CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS,
@@ -220,10 +224,7 @@
CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS,
CompileTimeErrorCode.IMPLEMENTS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER,
CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER,
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT,
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_NOT_ENOUGH_POSITIONAL_ARGUMENTS,
+ CompileTimeErrorCode.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS,
CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY,
CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY,
CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
@@ -447,6 +448,8 @@
CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER,
CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT,
CompileTimeErrorCode.UNDEFINED_ENUM_CONSTANT,
+ CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_NAMED,
+ CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED,
CompileTimeErrorCode.UNDEFINED_EXTENSION_GETTER,
CompileTimeErrorCode.UNDEFINED_EXTENSION_METHOD,
CompileTimeErrorCode.UNDEFINED_EXTENSION_OPERATOR,
@@ -725,6 +728,7 @@
ParserErrorCode.DUPLICATE_PREFIX,
ParserErrorCode.DUPLICATED_MODIFIER,
ParserErrorCode.EMPTY_ENUM_BODY,
+ ParserErrorCode.ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS,
ParserErrorCode.ENUM_IN_CLASS,
ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND,
ParserErrorCode.EXPECTED_BODY,
diff --git a/pkg/analyzer/lib/src/dart/analysis/index.dart b/pkg/analyzer/lib/src/dart/analysis/index.dart
index f9aebb6..8dc00f0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/index.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/index.dart
@@ -644,6 +644,27 @@
}
@override
+ visitEnumConstantDeclaration(node) {
+ var constructorElement = node.constructorElement;
+ if (constructorElement != null) {
+ int offset;
+ int length;
+ var constructorSelector = node.arguments?.constructorSelector;
+ if (constructorSelector != null) {
+ offset = constructorSelector.period.offset;
+ length = constructorSelector.name.end - offset;
+ } else {
+ offset = node.name.end;
+ length = 0;
+ }
+ recordRelationOffset(constructorElement, IndexRelationKind.IS_INVOKED_BY,
+ offset, length, true);
+ }
+
+ super.visitEnumConstantDeclaration(node);
+ }
+
+ @override
void visitExportDirective(ExportDirective node) {
ExportElement? element = node.element;
recordUriReference(element?.exportedLibrary, node.uri);
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index a5e5f49..229d450 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -2788,6 +2788,17 @@
return super.typeParameters;
}
+ ConstFieldElementImpl? get valuesField {
+ for (var field in fields) {
+ if (field is ConstFieldElementImpl &&
+ field.name == 'values' &&
+ field.isSyntheticEnumField) {
+ return field;
+ }
+ }
+ return null;
+ }
+
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeEnumElement(this);
@@ -3018,7 +3029,7 @@
/// A concrete implementation of an [ExtensionElement].
class ExtensionElementImpl extends _ExistingElementImpl
- with TypeParameterizedElementMixin
+ with TypeParameterizedElementMixin, HasCompletionData
implements ExtensionElement {
/// The type being extended.
DartType? _extendedType;
@@ -3202,6 +3213,7 @@
/// A concrete implementation of a [FieldElement].
class FieldElementImpl extends PropertyInducingElementImpl
+ with HasCompletionData
implements FieldElement {
/// True if this field inherits from a covariant parameter. This happens
/// when it overrides a field in a supertype that is covariant.
@@ -5475,7 +5487,7 @@
///
/// Clients may not extend, implement or mix-in this class.
class TypeAliasElementImpl extends _ExistingElementImpl
- with TypeParameterizedElementMixin
+ with TypeParameterizedElementMixin, HasCompletionData
implements TypeAliasElement {
/// Is `true` if the element has direct or indirect reference to itself
/// from anywhere except a class element or type parameter bounds.
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
index 1a6f7b2..e9762a2 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
@@ -458,6 +458,13 @@
correctionMessage: "Try declaring a constant.",
);
+ static const ParserErrorCode
+ ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS = ParserErrorCode(
+ 'ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS',
+ "Missing arguments in enum constructor invocation.",
+ correctionMessage: "Try adding an argument list.",
+ );
+
static const ParserErrorCode ENUM_IN_CLASS = ParserErrorCode(
'ENUM_IN_CLASS',
"Enums can't be declared inside classes.",
diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart
index a9c1500..f916a7c 100644
--- a/pkg/analyzer/lib/src/error/codes.g.dart
+++ b/pkg/analyzer/lib/src/error/codes.g.dart
@@ -3672,6 +3672,18 @@
);
/**
+ * Parameters:
+ * 0: the name of the abstract method
+ * 1: the name of the enclosing enum
+ */
+ static const CompileTimeErrorCode ENUM_WITH_ABSTRACT_MEMBER =
+ CompileTimeErrorCode(
+ 'ENUM_WITH_ABSTRACT_MEMBER',
+ "'{0}' must have a method body because '{1}' is an enum.",
+ correctionMessage: "Try adding a body to '{0}'.",
+ );
+
+ /**
* No parameters.
*/
// #### Description
@@ -5725,6 +5737,26 @@
hasPublishedDocs: true,
);
+ static const CompileTimeErrorCode ILLEGAL_ENUM_VALUES_DECLARATION =
+ CompileTimeErrorCode(
+ 'ILLEGAL_ENUM_VALUES_DECLARATION',
+ "An instance member named 'values' can't be declared in a class that "
+ "implements 'Enum'.",
+ correctionMessage: "Try using a different name.",
+ );
+
+ /**
+ * Parameters:
+ * 0: the name of the class that declares 'values'
+ */
+ static const CompileTimeErrorCode ILLEGAL_ENUM_VALUES_INHERITANCE =
+ CompileTimeErrorCode(
+ 'ILLEGAL_ENUM_VALUES_INHERITANCE',
+ "An instance member named 'values' can't be inherited from '{0}' in a "
+ "class that implements 'Enum'.",
+ correctionMessage: "Try using a different name.",
+ );
+
static const CompileTimeErrorCode ILLEGAL_LANGUAGE_VERSION_OVERRIDE =
CompileTimeErrorCode(
'ILLEGAL_LANGUAGE_VERSION_OVERRIDE',
@@ -5733,6 +5765,14 @@
"Try removing the language version override and migrating the code.",
);
+ static const CompileTimeErrorCode ILLEGAL_NON_ABSTRACT_ENUM_INDEX =
+ CompileTimeErrorCode(
+ 'ILLEGAL_NON_ABSTRACT_ENUM_INDEX',
+ "A non-abstract instance member named 'index' can't be declared in a class "
+ "that implements 'Enum'.",
+ correctionMessage: "Try using a different name.",
+ );
+
/**
* No parameters.
*/
@@ -5944,6 +5984,19 @@
/**
* Parameters:
+ * 0: the name of the superclass
+ */
+ static const CompileTimeErrorCode
+ IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS = CompileTimeErrorCode(
+ 'IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS',
+ "The implicitly invoked unnamed constructor from '{0}' has required "
+ "parameters.",
+ correctionMessage:
+ "Try adding an explicit super initializer with the required arguments.",
+ );
+
+ /**
+ * Parameters:
* 0: the name of the instance member
*/
// #### Description
@@ -6002,28 +6055,6 @@
hasPublishedDocs: true,
);
- static const CompileTimeErrorCode
- IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT =
- CompileTimeErrorCode(
- 'IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT',
- "The named parameter '{0}' is required in the implicitly invoked unnamed "
- "constructor of '{1}'.",
- correctionMessage:
- "Try declaring corresponding named super-parameter, or explicitly "
- "invoking a different constructor.",
- );
-
- static const CompileTimeErrorCode
- IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_NOT_ENOUGH_POSITIONAL_ARGUMENTS =
- CompileTimeErrorCode(
- 'IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_NOT_ENOUGH_POSITIONAL_ARGUMENTS',
- "The implicitly invoked unnamed constructor of '{0}' expects {1} "
- "positional arguments, but {2} found.",
- correctionMessage:
- "Try declaring positional super-parameters, or explicitly invoking a "
- "different constructor.",
- );
-
/**
* Parameters:
* 0: the uri pointing to a library
@@ -14294,6 +14325,30 @@
/**
* Parameters:
+ * 0: the name of the constructor that is undefined
+ */
+ static const CompileTimeErrorCode UNDEFINED_ENUM_CONSTRUCTOR_NAMED =
+ CompileTimeErrorCode(
+ 'UNDEFINED_ENUM_CONSTRUCTOR',
+ "The enum doesn't have a constructor named '{0}'.",
+ correctionMessage:
+ "Try correcting the name to the name of an existing constructor, or "
+ "defining constructor with the name '{0}'.",
+ uniqueName: 'UNDEFINED_ENUM_CONSTRUCTOR_NAMED',
+ );
+
+ static const CompileTimeErrorCode UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED =
+ CompileTimeErrorCode(
+ 'UNDEFINED_ENUM_CONSTRUCTOR',
+ "The enum doesn't have an unnamed constructor.",
+ correctionMessage:
+ "Try adding the name of an existing constructor, or defining an "
+ "unnamed constructor.",
+ uniqueName: 'UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED',
+ );
+
+ /**
+ * Parameters:
* 0: the name of the getter that is undefined
* 1: the name of the extension that was explicitly specified
*/
diff --git a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
index 08b53b9..ed4297e 100644
--- a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
+++ b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
@@ -47,17 +47,41 @@
var enumElement = node.declaredElement as EnumElementImpl;
var enumName = enumElement.name;
+ var constructorNames = <String>{};
var instanceGetters = <String, Element>{};
var instanceSetters = <String, Element>{};
var staticGetters = <String, Element>{};
var staticSetters = <String, Element>{};
+ var valuesField = enumElement.valuesField;
+ if (valuesField != null) {
+ staticGetters['values'] = valuesField;
+ }
+
for (EnumConstantDeclaration constant in node.constants) {
_checkDuplicateIdentifier(staticGetters, constant.name);
}
for (var member in node.members) {
- if (member is FieldDeclaration) {
+ if (member is ConstructorDeclaration) {
+ if (member.returnType.name == enumElement.name) {
+ var name = member.declaredElement!.name;
+ if (!constructorNames.add(name)) {
+ if (name.isEmpty) {
+ _errorReporter.reportErrorForName(
+ CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT,
+ member,
+ );
+ } else {
+ _errorReporter.reportErrorForName(
+ CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME,
+ member,
+ arguments: [name],
+ );
+ }
+ }
+ }
+ } else if (member is FieldDeclaration) {
for (var field in member.fields.variables) {
var identifier = field.name;
_checkDuplicateIdentifier(
@@ -84,26 +108,57 @@
}
}
- var staticExecutable = [
- ...enumElement.accessors,
- ...enumElement.methods,
- ].where((element) => element.isStatic);
- for (var executable in staticExecutable) {
- var baseName = executable.displayName;
- var instanceGetter = _inheritanceManager.getMember2(
- enumElement,
- Name(_currentLibrary.source.uri, baseName),
- );
- var instanceSetter = _inheritanceManager.getMember2(
- enumElement,
- Name(_currentLibrary.source.uri, '$baseName='),
- );
- if (instanceGetter != null || instanceSetter != null) {
- _errorReporter.reportErrorForElement(
- CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE,
- executable,
- [enumName, baseName, enumName],
- );
+ for (var accessor in enumElement.accessors) {
+ var baseName = accessor.displayName;
+ if (accessor.isStatic) {
+ var instance = _getInterfaceMember(enumElement, baseName);
+ if (instance != null && baseName != 'values') {
+ _errorReporter.reportErrorForElement(
+ CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE,
+ accessor,
+ [enumName, baseName, enumName],
+ );
+ }
+ } else {
+ var inherited = _getInheritedMember(enumElement, baseName);
+ if (inherited is MethodElement) {
+ _errorReporter.reportErrorForElement(
+ CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD,
+ accessor,
+ [
+ enumElement.displayName,
+ baseName,
+ inherited.enclosingElement.displayName,
+ ],
+ );
+ }
+ }
+ }
+
+ for (var method in enumElement.methods) {
+ var baseName = method.displayName;
+ if (method.isStatic) {
+ var instance = _getInterfaceMember(enumElement, baseName);
+ if (instance != null) {
+ _errorReporter.reportErrorForElement(
+ CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE,
+ method,
+ [enumName, baseName, enumName],
+ );
+ }
+ } else {
+ var inherited = _getInheritedMember(enumElement, baseName);
+ if (inherited is PropertyAccessorElement) {
+ _errorReporter.reportErrorForElement(
+ CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD,
+ method,
+ [
+ enumElement.displayName,
+ baseName,
+ inherited.enclosingElement.displayName,
+ ],
+ );
+ }
}
}
}
@@ -459,6 +514,34 @@
}
}
+ ExecutableElement? _getInheritedMember(
+ ClassElement element, String baseName) {
+ var libraryUri = _currentLibrary.source.uri;
+
+ var getterName = Name(libraryUri, baseName);
+ var getter = _inheritanceManager.getInherited2(element, getterName);
+ if (getter != null) {
+ return getter;
+ }
+
+ var setterName = Name(libraryUri, '$baseName=');
+ return _inheritanceManager.getInherited2(element, setterName);
+ }
+
+ ExecutableElement? _getInterfaceMember(
+ ClassElement element, String baseName) {
+ var libraryUri = _currentLibrary.source.uri;
+
+ var getterName = Name(libraryUri, baseName);
+ var getter = _inheritanceManager.getMember2(element, getterName);
+ if (getter != null) {
+ return getter;
+ }
+
+ var setterName = Name(libraryUri, '$baseName=');
+ return _inheritanceManager.getMember2(element, setterName);
+ }
+
static bool _isGetterSetterPair(Element a, Element b) {
if (a is PropertyAccessorElement && b is PropertyAccessorElement) {
return a.isGetter && b.isSetter || a.isSetter && b.isGetter;
diff --git a/pkg/analyzer/lib/src/error/inheritance_override.dart b/pkg/analyzer/lib/src/error/inheritance_override.dart
index aa1f7c1..d78da68 100644
--- a/pkg/analyzer/lib/src/error/inheritance_override.dart
+++ b/pkg/analyzer/lib/src/error/inheritance_override.dart
@@ -71,6 +71,7 @@
library: library,
classNameNode: declaration.name,
implementsClause: declaration.implementsClause,
+ members: declaration.members,
withClause: declaration.withClause,
).verify();
} else if (declaration is MixinDeclaration) {
@@ -117,6 +118,9 @@
final List<InterfaceType> directSuperInterfaces = [];
+ late final implementsDartCoreEnum =
+ classElement.allSupertypes.any((e) => e.isDartCoreEnum);
+
_ClassVerifier({
required this.typeSystem,
required this.typeProvider,
@@ -142,7 +146,7 @@
if (!classElement.isEnum &&
!classElement.isAbstract &&
- classElement.allSupertypes.any((e) => e.isDartCoreEnum)) {
+ implementsDartCoreEnum) {
reporter.reportErrorForNode(
CompileTimeErrorCode.NON_ABSTRACT_CLASS_HAS_ENUM_SUPERINTERFACE,
classNameNode,
@@ -193,6 +197,10 @@
var fieldElement = field.declaredElement as FieldElement;
_checkDeclaredMember(field.name, libraryUri, fieldElement.getter);
_checkDeclaredMember(field.name, libraryUri, fieldElement.setter);
+ if (!member.isStatic) {
+ _checkIllegalNonAbstractEnumIndex(field.name);
+ _checkIllegalEnumValuesDeclaration(field.name);
+ }
}
} else if (member is MethodDeclaration) {
var hasError = _reportNoCombinedSuperSignature(member);
@@ -202,9 +210,17 @@
_checkDeclaredMember(member.name, libraryUri, member.declaredElement,
methodParameterNodes: member.parameters?.parameters);
+ if (!member.isStatic) {
+ _checkIllegalEnumValuesDeclaration(member.name);
+ }
+ if (!(member.isStatic || member.isAbstract || member.isSetter)) {
+ _checkIllegalNonAbstractEnumIndex(member.name);
+ }
}
}
+ _checkIllegalEnumValuesInheritance();
+
GetterSetterTypesVerifier(
typeSystem: typeSystem,
errorReporter: reporter,
@@ -615,6 +631,45 @@
return false;
}
+ void _checkIllegalEnumValuesDeclaration(SimpleIdentifier name) {
+ if (implementsDartCoreEnum && name.name == 'values') {
+ reporter.reportErrorForNode(
+ CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION,
+ name,
+ );
+ }
+ }
+
+ void _checkIllegalEnumValuesInheritance() {
+ if (implementsDartCoreEnum) {
+ var getter = inheritance.getInherited2(
+ classElement,
+ Name(libraryUri, 'values'),
+ );
+ var setter = inheritance.getInherited2(
+ classElement,
+ Name(libraryUri, 'values='),
+ );
+ var inherited = getter ?? setter;
+ if (inherited != null) {
+ reporter.reportErrorForNode(
+ CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE,
+ classNameNode,
+ [inherited.enclosingElement.name!],
+ );
+ }
+ }
+ }
+
+ void _checkIllegalNonAbstractEnumIndex(SimpleIdentifier name) {
+ if (implementsDartCoreEnum && name.name == 'index') {
+ reporter.reportErrorForNode(
+ CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX,
+ name,
+ );
+ }
+ }
+
/// Return the error code that should be used when the given class [element]
/// references itself directly.
ErrorCode _getRecursiveErrorCode(ClassElement element) {
@@ -645,9 +700,12 @@
bool checkMemberNameCombo(ClassMember member, String memberName) {
if (memberName == name) {
reporter.reportErrorForNode(
- CompileTimeErrorCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER,
- member,
- [name, classElement.name]);
+ classElement.isEnum
+ ? CompileTimeErrorCode.ENUM_WITH_ABSTRACT_MEMBER
+ : CompileTimeErrorCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER,
+ member,
+ [name, classElement.name],
+ );
return true;
} else {
return false;
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index db03646..0816e6c 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -61,11 +61,12 @@
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/dart/ast/ast.dart'
show
+ ArgumentListImpl,
ClassDeclarationImpl,
CompilationUnitImpl,
ConstructorNameImpl,
- EnumConstantArgumentsImpl,
ConstructorSelectorImpl,
+ EnumConstantArgumentsImpl,
EnumConstantDeclarationImpl,
EnumDeclarationImpl,
ExtensionDeclarationImpl,
@@ -76,6 +77,7 @@
TypeArgumentListImpl,
TypeParameterImpl;
import 'package:analyzer/src/dart/ast/ast_factory.dart';
+import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'package:analyzer/src/fasta/error_converter.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/summary2/ast_binary_tokens.dart';
@@ -2814,6 +2816,7 @@
debugEvent("EnumElement");
var tmpArguments = pop() as MethodInvocationImpl?;
var tmpConstructor = pop() as ConstructorNameImpl?;
+ var constant = pop() as EnumConstantDeclarationImpl;
if (!enableEnhancedEnums &&
(tmpArguments != null ||
@@ -2834,23 +2837,31 @@
);
}
- var constant = pop() as EnumConstantDeclarationImpl;
+ var argumentList = tmpArguments?.argumentList;
+
+ TypeArgumentListImpl? typeArguments;
+ ConstructorSelectorImpl? constructorName;
+ if (tmpConstructor != null) {
+ typeArguments = tmpConstructor.type2.typeArguments;
+ var constructorNamePeriod = tmpConstructor.period;
+ var constructorNameId = tmpConstructor.name;
+ if (constructorNamePeriod != null && constructorNameId != null) {
+ constructorName = ConstructorSelectorImpl(
+ period: constructorNamePeriod,
+ name: constructorNameId,
+ );
+ }
+ if (typeArguments != null && argumentList == null) {
+ errorReporter.errorReporter?.reportErrorForNode(
+ ParserErrorCode.ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS,
+ typeArguments,
+ );
+ argumentList = _syntheticArgumentList(typeArguments.endToken);
+ }
+ }
// Replace the constant to include arguments.
- if (tmpArguments != null) {
- TypeArgumentListImpl? typeArguments;
- ConstructorSelectorImpl? constructorName;
- if (tmpConstructor != null) {
- typeArguments = tmpConstructor.type2.typeArguments;
- var constructorNamePeriod = tmpConstructor.period;
- var constructorNameId = tmpConstructor.name;
- if (constructorNamePeriod != null && constructorNameId != null) {
- constructorName = ConstructorSelectorImpl(
- period: constructorNamePeriod,
- name: constructorNameId,
- );
- }
- }
+ if (argumentList != null) {
constant = EnumConstantDeclarationImpl(
documentationComment: constant.documentationComment,
metadata: constant.metadata,
@@ -2858,7 +2869,7 @@
arguments: EnumConstantArgumentsImpl(
typeArguments: typeArguments,
constructorSelector: constructorName,
- argumentList: tmpArguments.argumentList,
+ argumentList: argumentList,
),
);
}
@@ -4257,12 +4268,13 @@
return ast.variableDeclaration(name, equals, initializer);
}
- ArgumentList _syntheticArgumentList(Token precedingToken) {
- int syntheticOffset = precedingToken.end;
- return ast.argumentList(
- SyntheticToken(TokenType.OPEN_PAREN, syntheticOffset),
- [],
- SyntheticToken(TokenType.CLOSE_PAREN, syntheticOffset));
+ ArgumentListImpl _syntheticArgumentList(Token precedingToken) {
+ var syntheticOffset = precedingToken.end;
+ var left = SyntheticToken(TokenType.OPEN_PAREN, syntheticOffset)
+ ..previous = precedingToken;
+ var right = SyntheticToken(TokenType.CLOSE_PAREN, syntheticOffset)
+ ..previous = left;
+ return ast.argumentList(left, [], right);
}
SimpleIdentifier _tmpSimpleIdentifier() {
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 42cca4f..84ae1df 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -4379,22 +4379,11 @@
);
if (requiredPositionalParameterCount >
- superParametersResult.positionalArgumentCount) {
+ superParametersResult.positionalArgumentCount ||
+ requiredNamedParameters.isNotEmpty) {
reportError(
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_NOT_ENOUGH_POSITIONAL_ARGUMENTS,
- [
- superType,
- requiredPositionalParameterCount,
- superParametersResult.positionalArgumentCount,
- ],
- );
- }
- for (var requiredNamedParameterName in requiredNamedParameters) {
- reportError(
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT,
- [requiredNamedParameterName, superType],
+ CompileTimeErrorCode.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS,
+ [superType],
);
}
}
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 375c076..7761fe1 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -1406,7 +1406,7 @@
node.parameters.accept(this);
node.initializers.accept(this);
node.redirectedConstructor?.accept(this);
- node.body.resolve(this, returnType);
+ node.body.resolve(this, returnType.isDynamic ? null : returnType);
elementResolver.visitConstructorDeclaration(node);
} finally {
_enclosingFunction = outerFunction;
@@ -1561,16 +1561,36 @@
var element = node.declaredElement as ConstFieldElementImpl;
var initializer = element.constantInitializer;
if (initializer is InstanceCreationExpression) {
- var constructor = initializer.constructorName.staticElement;
- node.constructorElement = constructor;
+ var constructorName = initializer.constructorName;
+ var constructorElement = constructorName.staticElement;
+ if (constructorElement != null) {
+ node.constructorElement = constructorElement;
+ } else {
+ var typeName = constructorName.type2.name;
+ if (typeName.staticElement is EnumElementImpl) {
+ var nameNode = node.arguments?.constructorSelector?.name;
+ if (nameNode != null) {
+ errorReporter.reportErrorForNode(
+ CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_NAMED,
+ nameNode,
+ [nameNode.name],
+ );
+ } else {
+ errorReporter.reportErrorForNode(
+ CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED,
+ node.name,
+ );
+ }
+ }
+ }
var arguments = node.arguments;
if (arguments != null) {
var argumentList = arguments.argumentList;
- if (constructor != null) {
+ if (constructorElement != null) {
argumentList.correspondingStaticParameters =
ResolverVisitor.resolveArgumentsToParameters(
argumentList: argumentList,
- parameters: constructor.parameters,
+ parameters: constructorElement.parameters,
);
for (var argument in argumentList.arguments) {
analyzeExpression(argument, argument.staticParameterElement?.type);
@@ -2029,7 +2049,7 @@
node.name.accept(this);
node.typeParameters?.accept(this);
node.parameters?.accept(this);
- node.body.resolve(this, returnType);
+ node.body.resolve(this, returnType.isDynamic ? null : returnType);
elementResolver.visitMethodDeclaration(node);
} finally {
_enclosingFunction = outerFunction;
diff --git a/pkg/analyzer/lib/src/test_utilities/find_element.dart b/pkg/analyzer/lib/src/test_utilities/find_element.dart
index 4a4b593..0c572a2 100644
--- a/pkg/analyzer/lib/src/test_utilities/find_element.dart
+++ b/pkg/analyzer/lib/src/test_utilities/find_element.dart
@@ -505,7 +505,11 @@
}
ConstructorElement unnamedConstructor(String name) {
- return class_(name).unnamedConstructor!;
+ return _findInClassesLike(
+ className: name,
+ fromClass: (e) => e.unnamedConstructor,
+ fromExtension: (_) => null,
+ );
}
T _findInClassesLike<T extends Element>({
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index b63ff5f..25d0a13 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -3354,6 +3354,13 @@
ENUM_MIXIN_WITH_INSTANCE_VARIABLE:
problemMessage: Mixins applied to enums can't have instance variables.
correctionMessage: Try replacing the instance variables with getters.
+ ENUM_WITH_ABSTRACT_MEMBER:
+ problemMessage: "'{0}' must have a method body because '{1}' is an enum."
+ correctionMessage: "Try adding a body to '{0}'."
+ comment: |-
+ Parameters:
+ 0: the name of the abstract method
+ 1: the name of the enclosing enum
EQUAL_ELEMENTS_IN_CONST_SET:
problemMessage: "Two elements in a constant set literal can't be equal."
correctionMessage: Change or remove the duplicate element.
@@ -5011,9 +5018,21 @@
```dart
int f() => 0;
```
+ ILLEGAL_ENUM_VALUES_DECLARATION:
+ problemMessage: An instance member named 'values' can't be declared in a class that implements 'Enum'.
+ correctionMessage: Try using a different name.
+ ILLEGAL_ENUM_VALUES_INHERITANCE:
+ problemMessage: An instance member named 'values' can't be inherited from '{0}' in a class that implements 'Enum'.
+ correctionMessage: Try using a different name.
+ comment: |-
+ Parameters:
+ 0: the name of the class that declares 'values'
ILLEGAL_LANGUAGE_VERSION_OVERRIDE:
problemMessage: The language version must be {0}.
correctionMessage: Try removing the language version override and migrating the code.
+ ILLEGAL_NON_ABSTRACT_ENUM_INDEX:
+ problemMessage: A non-abstract instance member named 'index' can't be declared in a class that implements 'Enum'.
+ correctionMessage: Try using a different name.
ILLEGAL_SYNC_GENERATOR_RETURN_TYPE:
problemMessage: "Functions marked 'sync*' must have a return type that is a supertype of 'Iterable<T>' for some type 'T'."
correctionMessage: "Try fixing the return type of the function, or removing the modifier 'sync*' from the function body."
@@ -5217,12 +5236,12 @@
int get defaultX => 0;
}
```
- IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT:
- problemMessage: The named parameter '{0}' is required in the implicitly invoked unnamed constructor of '{1}'.
- correctionMessage: Try declaring corresponding named super-parameter, or explicitly invoking a different constructor.
- IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_NOT_ENOUGH_POSITIONAL_ARGUMENTS:
- problemMessage: The implicitly invoked unnamed constructor of '{0}' expects {1} positional arguments, but {2} found.
- correctionMessage: Try declaring positional super-parameters, or explicitly invoking a different constructor.
+ IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS:
+ problemMessage: The implicitly invoked unnamed constructor from '{0}' has required parameters.
+ correctionMessage: Try adding an explicit super initializer with the required arguments.
+ comment: |-
+ Parameters:
+ 0: the name of the superclass
IMPORT_INTERNAL_LIBRARY:
problemMessage: "The library '{0}' is internal and can't be imported."
hasPublishedDocs: true
@@ -12271,6 +12290,17 @@
var e = E.b;
```
+ UNDEFINED_ENUM_CONSTRUCTOR_NAMED:
+ sharedName: UNDEFINED_ENUM_CONSTRUCTOR
+ problemMessage: The enum doesn't have a constructor named '{0}'.
+ correctionMessage: Try correcting the name to the name of an existing constructor, or defining constructor with the name '{0}'.
+ comment: |-
+ Parameters:
+ 0: the name of the constructor that is undefined
+ UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED:
+ sharedName: UNDEFINED_ENUM_CONSTRUCTOR
+ problemMessage: The enum doesn't have an unnamed constructor.
+ correctionMessage: Try adding the name of an existing constructor, or defining an unnamed constructor.
UNDEFINED_EXTENSION_GETTER:
problemMessage: "The getter '{0}' isn't defined for the extension '{1}'."
correctionMessage: "Try correcting the name to the name of an existing getter, or defining a getter named '{0}'."
@@ -18939,6 +18969,9 @@
EMPTY_ENUM_BODY:
problemMessage: An enum must declare at least one constant name.
correctionMessage: Try declaring a constant.
+ ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS:
+ problemMessage: Missing arguments in enum constructor invocation.
+ correctionMessage: Try adding an argument list.
EXPECTED_CASE_OR_DEFAULT:
problemMessage: "Expected 'case' or 'default'."
correctionMessage: Try placing this code inside a case clause.
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index 940d786..73ea37b 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -3303,4 +3303,34 @@
}
''');
}
+
+ test_yieldStar_inside_method_async() async {
+ await assertNoErrorsInCode('''
+class A {
+ m() async* {
+ yield* Stream.fromIterable([1]);
+ }
+}
+''');
+
+ assertType(
+ findNode
+ .yieldStatement('yield* Stream.fromIterable([1]);')
+ .expression
+ .staticType,
+ 'Stream<int>');
+ }
+
+ test_yieldStar_inside_method_sync() async {
+ await assertNoErrorsInCode('''
+class A {
+ m() sync* {
+ yield* [1];
+ }
+}
+''');
+
+ assertType(findNode.yieldStatement('yield* [1];').expression.staticType,
+ 'List<int>');
+ }
}
diff --git a/pkg/analyzer/test/src/dart/analysis/index_test.dart b/pkg/analyzer/test/src/dart/analysis/index_test.dart
index 9375dc1..d1bcdbf 100644
--- a/pkg/analyzer/test/src/dart/analysis/index_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/index_test.dart
@@ -215,6 +215,19 @@
..isReferencedAt('B; // 3', false);
}
+ test_isImplementedBy_enum() async {
+ await _indexTestUnit('''
+class A {} // 1
+enum E implements A { // 2
+ v;
+}
+''');
+ ClassElement elementA = findElement.class_('A');
+ assertThat(elementA)
+ ..isImplementedAt('A { // 2', false)
+ ..isReferencedAt('A { // 2', false);
+ }
+
test_isImplementedBy_MixinDeclaration_implementsClause() async {
await _indexTestUnit('''
class A {} // 1
@@ -269,7 +282,7 @@
assertThat(element).isInvokedAt('loadLibrary(); // 2', true);
}
- test_isInvokedBy_MethodElement() async {
+ test_isInvokedBy_MethodElement_class() async {
await _indexTestUnit('''
class A {
foo() {}
@@ -284,6 +297,26 @@
..isInvokedAt('foo(); // nq', false);
}
+ test_isInvokedBy_MethodElement_enum() async {
+ await _indexTestUnit('''
+enum E {
+ v;
+ void foo() {}
+ void bar() {
+ this.foo(); // q1
+ foo(); // nq
+ }
+}
+void f(E e) {
+ e.foo(); // q2
+}
+''');
+ assertThat(findElement.method('foo'))
+ ..isInvokedAt('foo(); // q1', true)
+ ..isInvokedAt('foo(); // nq', false)
+ ..isInvokedAt('foo(); // q2', true);
+ }
+
test_isInvokedBy_MethodElement_ofNamedExtension_instance() async {
await _indexTestUnit('''
extension E on int {
@@ -351,7 +384,7 @@
assertThat(element).isInvokedAt('foo();', true);
}
- test_isInvokedBy_operator_binary() async {
+ test_isInvokedBy_operator_class_binary() async {
await _indexTestUnit('''
class A {
operator +(other) => this;
@@ -371,7 +404,7 @@
..isInvokedAt('++;', true, length: 2);
}
- test_isInvokedBy_operator_index() async {
+ test_isInvokedBy_operator_class_index() async {
await _indexTestUnit('''
class A {
operator [](i) => null;
@@ -388,7 +421,7 @@
assertThat(writeElement).isInvokedAt('[1]', true, length: 1);
}
- test_isInvokedBy_operator_prefix() async {
+ test_isInvokedBy_operator_class_prefix() async {
await _indexTestUnit('''
class A {
A operator ~() => this;
@@ -401,6 +434,58 @@
assertThat(element).isInvokedAt('~a', true, length: 1);
}
+ test_isInvokedBy_operator_enum_binary() async {
+ await _indexTestUnit('''
+enum E {
+ v;
+ int operator +(other) => 0;
+}
+void f(E e) {
+ e + 1;
+ e += 2;
+ ++e;
+ e++;
+}
+''');
+ assertThat(findElement.method('+'))
+ ..isInvokedAt('+ 1', true, length: 1)
+ ..isInvokedAt('+= 2', true, length: 2)
+ ..isInvokedAt('++e', true, length: 2)
+ ..isInvokedAt('++;', true, length: 2);
+ }
+
+ test_isInvokedBy_operator_enum_index() async {
+ await _indexTestUnit('''
+enum E {
+ v;
+ int operator [](int index) => 0;
+ operator []=(int index, int vlaue) {}
+}
+void f(E e) {
+ e[0];
+ e[1] = 42;
+}
+''');
+ MethodElement readElement = findElement.method('[]');
+ MethodElement writeElement = findElement.method('[]=');
+ assertThat(readElement).isInvokedAt('[0]', true, length: 1);
+ assertThat(writeElement).isInvokedAt('[1]', true, length: 1);
+ }
+
+ test_isInvokedBy_operator_enum_prefix() async {
+ await _indexTestUnit('''
+enum E {
+ e;
+ int operator ~() => 0;
+}
+void f(E e) {
+ ~e;
+}
+''');
+ MethodElement element = findElement.method('~');
+ assertThat(element).isInvokedAt('~e', true, length: 1);
+ }
+
test_isMixedBy_ClassDeclaration_TypeAliasElement() async {
await _indexTestUnit('''
class A<T> {}
@@ -465,6 +550,18 @@
assertThat(elementA).isMixedInAt('A; // 2', false);
}
+ test_isMixedInBy_enum_mixin() async {
+ await _indexTestUnit('''
+mixin M {} // 1
+enum E with M { // 2
+ v
+}
+''');
+ assertThat(findElement.mixin('M'))
+ ..isMixedInAt('M { // 2', false)
+ ..isReferencedAt('M { // 2', false);
+ }
+
test_isReferencedAt_PropertyAccessorElement_field_call() async {
await _indexTestUnit('''
class A {
@@ -659,6 +756,141 @@
// No exception, even though a.dart is a part of b.dart part.
}
+ test_isReferencedBy_ConstructorElement_class_named() async {
+ await _indexTestUnit('''
+/// [new A.foo] 1
+class A {
+ A.foo() {}
+ A.bar() : this.foo(); // 2
+}
+class B extends A {
+ B() : super.foo(); // 3
+ factory B.bar() = A.foo; // 4
+}
+void f() {
+ A.foo(); // 5
+ A.foo; // 6
+}
+''');
+ var element = findElement.constructor('foo');
+ assertThat(element)
+ ..hasRelationCount(6)
+ ..isReferencedAt('.foo] 1', true, length: 4)
+ ..isInvokedAt('.foo(); // 2', true, length: 4)
+ ..isInvokedAt('.foo(); // 3', true, length: 4)
+ ..isReferencedAt('.foo; // 4', true, length: 4)
+ ..isInvokedAt('.foo(); // 5', true, length: 4)
+ ..isReferencedByConstructorTearOffAt('.foo; // 6', length: 4);
+ }
+
+ test_isReferencedBy_ConstructorElement_class_namedOnlyWithDot() async {
+ await _indexTestUnit('''
+class A {
+ A.named() {}
+}
+main() {
+ new A.named();
+}
+''');
+ // has ".named()", but does not have "named()"
+ var constructorName = findNode.constructorName('.named();');
+ var offsetWithoutDot = constructorName.name!.offset;
+ var offsetWithDot = constructorName.period!.offset;
+ expect(index.usedElementOffsets, isNot(contains(offsetWithoutDot)));
+ expect(index.usedElementOffsets, contains(offsetWithDot));
+ }
+
+ test_isReferencedBy_ConstructorElement_class_redirection() async {
+ await _indexTestUnit('''
+class A {
+ A() : this.bar(); // 1
+ A.foo() : this(); // 2
+ A.bar();
+}
+''');
+ var constA = findElement.unnamedConstructor('A');
+ var constA_bar = findElement.constructor('bar');
+ assertThat(constA).isInvokedAt('(); // 2', true, length: 0);
+ assertThat(constA_bar).isInvokedAt('.bar(); // 1', true, length: 4);
+ }
+
+ test_isReferencedBy_ConstructorElement_class_unnamed_declared() async {
+ await _indexTestUnit('''
+/// [new A] 1
+class A {
+ A() {}
+ A.other() : this(); // 2
+}
+class B extends A {
+ B() : super(); // 3
+ factory B.other() = A; // 4
+}
+void f() {
+ A(); // 5
+ A.new; // 6
+}
+''');
+ var element = findElement.unnamedConstructor('A');
+ assertThat(element)
+ ..hasRelationCount(6)
+ ..isReferencedAt('] 1', true, length: 0)
+ ..isInvokedAt('(); // 2', true, length: 0)
+ ..isInvokedAt('(); // 3', true, length: 0)
+ ..isReferencedAt('; // 4', true, length: 0)
+ ..isInvokedAt('(); // 5', true, length: 0)
+ ..isReferencedByConstructorTearOffAt('.new; // 6', length: 4);
+ }
+
+ test_isReferencedBy_ConstructorElement_class_unnamed_declared_new() async {
+ await _indexTestUnit('''
+/// [new A] 1
+class A {
+ A.new() {}
+ A.other() : this(); // 2
+}
+class B extends A {
+ B() : super(); // 3
+ factory B.bar() = A; // 4
+}
+void f() {
+ A(); // 5
+ A.new; // 6
+}
+''');
+ var element = findElement.unnamedConstructor('A');
+ assertThat(element)
+ ..hasRelationCount(6)
+ ..isReferencedAt('] 1', true, length: 0)
+ ..isInvokedAt('(); // 2', true, length: 0)
+ ..isInvokedAt('(); // 3', true, length: 0)
+ ..isReferencedAt('; // 4', true, length: 0)
+ ..isInvokedAt('(); // 5', true, length: 0)
+ ..isReferencedByConstructorTearOffAt('.new; // 6', length: 4);
+ }
+
+ test_isReferencedBy_ConstructorElement_class_unnamed_synthetic() async {
+ await _indexTestUnit('''
+/// [new A] 1
+class A {}
+class B extends A {
+ B() : super(); // 2
+ factory B.bar() = A; // 3
+}
+void f() {
+ A(); // 4
+ A.new; // 5
+}
+''');
+ var element = findElement.unnamedConstructor('A');
+ assertThat(element)
+ ..hasRelationCount(5)
+ ..isReferencedAt('] 1', true, length: 0)
+ ..isInvokedAt('(); // 2', true, length: 0)
+ ..isReferencedAt('; // 3', true, length: 0)
+ ..isInvokedAt('(); // 4', true, length: 0)
+ ..isReferencedByConstructorTearOffAt('.new; // 5', length: 4);
+ }
+
test_isReferencedBy_ConstructorElement_classTypeAlias() async {
await _indexTestUnit('''
class M {}
@@ -698,139 +930,75 @@
// No additional validation, but it should not fail with stack overflow.
}
- test_isReferencedBy_ConstructorElement_named() async {
+ test_isReferencedBy_ConstructorElement_enum_named() async {
await _indexTestUnit('''
-/// [new A.foo] 1
-class A {
- A.foo() {}
- A.bar() : this.foo(); // 2
-}
-class B extends A {
- B() : super.foo(); // 3
- factory B.bar() = A.foo; // 4
-}
-void f() {
- A.foo(); // 5
- A.foo; // 6
+/// [new E.foo] 1
+enum E {
+ v.foo(); // 2
+ E.foo();
+ E.bar() : this.foo(); // 3
}
''');
var element = findElement.constructor('foo');
assertThat(element)
- ..hasRelationCount(6)
+ ..hasRelationCount(3)
..isReferencedAt('.foo] 1', true, length: 4)
..isInvokedAt('.foo(); // 2', true, length: 4)
- ..isInvokedAt('.foo(); // 3', true, length: 4)
- ..isReferencedAt('.foo; // 4', true, length: 4)
- ..isInvokedAt('.foo(); // 5', true, length: 4)
- ..isReferencedByConstructorTearOffAt('.foo; // 6', length: 4);
+ ..isInvokedAt('.foo(); // 3', true, length: 4);
}
- test_isReferencedBy_ConstructorElement_namedOnlyWithDot() async {
+ test_isReferencedBy_ConstructorElement_enum_unnamed_declared() async {
await _indexTestUnit('''
-class A {
- A.named() {}
-}
-main() {
- new A.named();
+/// [new E] 1
+enum E {
+ v1, // 2
+ v2.new(); // 3
+ E();
+ E.other() : this(); // 4
}
''');
- // has ".named()", but does not have "named()"
- var constructorName = findNode.constructorName('.named();');
- var offsetWithoutDot = constructorName.name!.offset;
- var offsetWithDot = constructorName.period!.offset;
- expect(index.usedElementOffsets, isNot(contains(offsetWithoutDot)));
- expect(index.usedElementOffsets, contains(offsetWithDot));
- }
-
- test_isReferencedBy_ConstructorElement_redirection() async {
- await _indexTestUnit('''
-class A {
- A() : this.bar(); // 1
- A.foo() : this(); // 2
- A.bar();
-}
-''');
- var constA = findElement.unnamedConstructor('A');
- var constA_bar = findElement.constructor('bar');
- assertThat(constA).isInvokedAt('(); // 2', true, length: 0);
- assertThat(constA_bar).isInvokedAt('.bar(); // 1', true, length: 4);
- }
-
- test_isReferencedBy_ConstructorElement_unnamed_declared() async {
- await _indexTestUnit('''
-/// [new A] 1
-class A {
- A() {}
- A.other() : this(); // 2
-}
-class B extends A {
- B() : super(); // 3
- factory B.other() = A; // 4
-}
-void f() {
- A(); // 5
- A.new; // 6
-}
-''');
- var element = findElement.unnamedConstructor('A');
+ var element = findElement.unnamedConstructor('E');
assertThat(element)
- ..hasRelationCount(6)
+ ..hasRelationCount(4)
..isReferencedAt('] 1', true, length: 0)
- ..isInvokedAt('(); // 2', true, length: 0)
- ..isInvokedAt('(); // 3', true, length: 0)
- ..isReferencedAt('; // 4', true, length: 0)
- ..isInvokedAt('(); // 5', true, length: 0)
- ..isReferencedByConstructorTearOffAt('.new; // 6', length: 4);
+ ..isInvokedAt(', // 2', true, length: 0)
+ ..isInvokedAt('.new(); // 3', true, length: 4)
+ ..isInvokedAt('(); // 4', true, length: 0);
}
- test_isReferencedBy_ConstructorElement_unnamed_declared_new() async {
+ test_isReferencedBy_ConstructorElement_enum_unnamed_declared_new() async {
await _indexTestUnit('''
-/// [new A] 1
-class A {
- A.new() {}
- A.other() : this(); // 2
-}
-class B extends A {
- B() : super(); // 3
- factory B.bar() = A; // 4
-}
-void f() {
- A(); // 5
- A.new; // 6
+/// [new E] 1
+enum E {
+ v1, // 2
+ v2.new(); // 3
+ E.new() {}
+ E.other() : this(); // 4
}
''');
- var element = findElement.unnamedConstructor('A');
+ var element = findElement.unnamedConstructor('E');
assertThat(element)
- ..hasRelationCount(6)
+ ..hasRelationCount(4)
..isReferencedAt('] 1', true, length: 0)
- ..isInvokedAt('(); // 2', true, length: 0)
- ..isInvokedAt('(); // 3', true, length: 0)
- ..isReferencedAt('; // 4', true, length: 0)
- ..isInvokedAt('(); // 5', true, length: 0)
- ..isReferencedByConstructorTearOffAt('.new; // 6', length: 4);
+ ..isInvokedAt(', // 2', true, length: 0)
+ ..isInvokedAt('.new(); // 3', true, length: 4)
+ ..isInvokedAt('(); // 4', true, length: 0);
}
- test_isReferencedBy_ConstructorElement_unnamed_synthetic() async {
+ test_isReferencedBy_ConstructorElement_enum_unnamed_synthetic() async {
await _indexTestUnit('''
-/// [new A] 1
-class A {}
-class B extends A {
- B() : super(); // 2
- factory B.bar() = A; // 3
-}
-void f() {
- A(); // 4
- A.new; // 5
+/// [new E] 1
+enum E {
+ v1, // 2
+ v2.new(); // 3
}
''');
- var element = findElement.unnamedConstructor('A');
+ var element = findElement.unnamedConstructor('E');
assertThat(element)
- ..hasRelationCount(5)
+ ..hasRelationCount(3)
..isReferencedAt('] 1', true, length: 0)
- ..isInvokedAt('(); // 2', true, length: 0)
- ..isReferencedAt('; // 3', true, length: 0)
- ..isInvokedAt('(); // 4', true, length: 0)
- ..isReferencedByConstructorTearOffAt('.new; // 5', length: 4);
+ ..isInvokedAt(', // 2', true, length: 0)
+ ..isInvokedAt('.new(); // 3', true, length: 4);
}
test_isReferencedBy_DynamicElement() async {
@@ -854,7 +1022,7 @@
assertThat(element)..isReferencedAt('E(0).foo()', false);
}
- test_isReferencedBy_FieldElement() async {
+ test_isReferencedBy_FieldElement_class() async {
await _indexTestUnit('''
class A {
var field;
@@ -884,7 +1052,7 @@
assertThat(field)..isReferencedAt('field: 4', true);
}
- test_isReferencedBy_FieldElement_multiple() async {
+ test_isReferencedBy_FieldElement_class_multiple() async {
await _indexTestUnit('''
class A {
var aaa;
@@ -918,7 +1086,72 @@
}
}
- test_isReferencedBy_FieldElement_ofEnum() async {
+ test_isReferencedBy_FieldElement_class_synthetic_hasGetter() async {
+ await _indexTestUnit('''
+class A {
+ A() : f = 42;
+ int get f => 0;
+}
+''');
+ ClassElement element2 = findElement.class_('A');
+ assertThat(element2.getField('f')!).isWrittenAt('f = 42', true);
+ }
+
+ test_isReferencedBy_FieldElement_class_synthetic_hasGetterSetter() async {
+ await _indexTestUnit('''
+class A {
+ A() : f = 42;
+ int get f => 0;
+ set f(_) {}
+}
+''');
+ ClassElement element2 = findElement.class_('A');
+ assertThat(element2.getField('f')!).isWrittenAt('f = 42', true);
+ }
+
+ test_isReferencedBy_FieldElement_class_synthetic_hasSetter() async {
+ await _indexTestUnit('''
+class A {
+ A() : f = 42;
+ set f(_) {}
+}
+''');
+ ClassElement element2 = findElement.class_('A');
+ assertThat(element2.getField('f')!).isWrittenAt('f = 42', true);
+ }
+
+ test_isReferencedBy_FieldElement_enum() async {
+ await _indexTestUnit('''
+enum E {
+ v;
+ int? field; // a compile-time error
+ E({this.field});
+ void foo() {
+ field = 2; // nq
+ field; // nq
+ }
+}
+void f(E e) {
+ e.field = 3; // q
+ e.field; // q
+ E(field: 4);
+}
+''');
+ FieldElement field = findElement.field('field');
+ PropertyAccessorElement getter = field.getter!;
+ PropertyAccessorElement setter = field.setter!;
+ // E()
+ assertThat(field)..isWrittenAt('field});', true);
+ // foo()
+ assertThat(setter)..isReferencedAt('field = 2; // nq', false);
+ assertThat(getter)..isReferencedAt('field; // nq', false);
+ // f()
+ assertThat(setter)..isReferencedAt('field = 3; // q', true);
+ assertThat(getter)..isReferencedAt('field; // q', true);
+ assertThat(field)..isReferencedAt('field: 4', true);
+ }
+
+ test_isReferencedBy_FieldElement_enum_index() async {
await _indexTestUnit('''
enum MyEnum {
A, B, C
@@ -939,38 +1172,38 @@
assertThat(enumElement.getGetter('B')!)..isReferencedAt('B);', true);
}
- test_isReferencedBy_FieldElement_synthetic_hasGetter() async {
+ test_isReferencedBy_FieldElement_enum_synthetic_hasGetter() async {
await _indexTestUnit('''
-class A {
- A() : f = 42;
+enum E {
+ v;
+ E() : f = 42;
int get f => 0;
}
''');
- ClassElement element2 = findElement.class_('A');
- assertThat(element2.getField('f')!).isWrittenAt('f = 42', true);
+ assertThat(findElement.field('f')).isWrittenAt('f = 42', true);
}
- test_isReferencedBy_FieldElement_synthetic_hasGetterSetter() async {
+ test_isReferencedBy_FieldElement_enum_synthetic_hasGetterSetter() async {
await _indexTestUnit('''
-class A {
- A() : f = 42;
+enum E {
+ v;
+ E() : f = 42;
int get f => 0;
set f(_) {}
}
''');
- ClassElement element2 = findElement.class_('A');
- assertThat(element2.getField('f')!).isWrittenAt('f = 42', true);
+ assertThat(findElement.field('f')).isWrittenAt('f = 42', true);
}
- test_isReferencedBy_FieldElement_synthetic_hasSetter() async {
+ test_isReferencedBy_FieldElement_enum_synthetic_hasSetter() async {
await _indexTestUnit('''
-class A {
- A() : f = 42;
+enum E {
+ v;
+ E() : f = 42;
set f(_) {}
}
''');
- ClassElement element2 = findElement.class_('A');
- assertThat(element2.getField('f')!).isWrittenAt('f = 42', true);
+ assertThat(findElement.field('f')).isWrittenAt('f = 42', true);
}
test_isReferencedBy_FunctionElement() async {
@@ -1031,7 +1264,7 @@
assertThat(element)..isReferencedAt('A] text', false);
}
- test_isReferencedBy_MethodElement() async {
+ test_isReferencedBy_MethodElement_class() async {
await _indexTestUnit('''
class A {
method() {}
@@ -1046,6 +1279,26 @@
..isReferencedAt('method); // nq', false);
}
+ test_isReferencedBy_MethodElement_enum() async {
+ await _indexTestUnit('''
+enum E {
+ v;
+ void foo() {}
+ void bar() {
+ this.foo; // q1
+ foo; // nq
+ }
+}
+void f(E e) {
+ e.foo; // q2
+}
+''');
+ assertThat(findElement.method('foo'))
+ ..isReferencedAt('foo; // q1', true)
+ ..isReferencedAt('foo; // nq', false)
+ ..isReferencedAt('foo; // q2', true);
+ }
+
test_isReferencedBy_MultiplyDefinedElement() async {
newFile('$testPackageLibPath/a1.dart', content: 'class A {}');
newFile('$testPackageLibPath/a2.dart', content: 'class A {}');
diff --git a/pkg/analyzer/test/src/dart/resolution/enum_test.dart b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
index 3381a96..edad25c 100644
--- a/pkg/analyzer/test/src/dart/resolution/enum_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
@@ -2,6 +2,7 @@
// 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:analyzer/src/error/codes.dart';
import 'package:analyzer/src/test_utilities/find_element.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -186,12 +187,14 @@
}
test_constructor_unresolved_named() async {
- await assertNoErrorsInCode(r'''
+ await assertErrorsInCode(r'''
enum E {
v.named(42);
const E(int a);
}
-''');
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_NAMED, 13, 5),
+ ]);
assertEnumConstant(
findNode.enumConstantDeclaration('v'),
@@ -203,12 +206,14 @@
}
test_constructor_unresolved_unnamed() async {
- await assertNoErrorsInCode(r'''
+ await assertErrorsInCode(r'''
enum E {
v(42);
const E.named(int a);
}
-''');
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED, 11, 1),
+ ]);
assertEnumConstant(
findNode.enumConstantDeclaration('v'),
diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_field_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_field_test.dart
index 6cb825d..4bd1277 100644
--- a/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_field_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_field_test.dart
@@ -71,4 +71,34 @@
3),
]);
}
+
+ test_enum_field() async {
+ await assertNoErrorsInCode(r'''
+enum E {
+ v.foo();
+ const E.foo(); // _$foo
+ static int foo = 0;
+}
+''');
+ }
+
+ test_enum_getter() async {
+ await assertNoErrorsInCode(r'''
+enum E {
+ v.foo();
+ const E.foo(); // _$foo
+ static int get foo => 0;
+}
+''');
+ }
+
+ test_enum_setter() async {
+ await assertNoErrorsInCode(r'''
+enum E {
+ v.foo();
+ const E.foo(); // _$foo
+ static void set foo(_) {}
+}
+''');
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_method_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_method_test.dart
index a880ff5..d962c52 100644
--- a/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/conflicting_constructor_and_static_method_test.dart
@@ -16,6 +16,18 @@
@reflectiveTest
class ConflictingConstructorAndStaticMethodTest
extends PubPackageResolutionTest {
+ test_class() async {
+ await assertErrorsInCode(r'''
+class C {
+ C.foo();
+ static void foo() {}
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_AND_STATIC_METHOD, 14,
+ 3),
+ ]);
+ }
+
test_class_OK_notSameClass() async {
await assertNoErrorsInCode(r'''
class A {
@@ -36,15 +48,13 @@
''');
}
- test_error_conflictingConstructorAndStaticMethod() async {
- await assertErrorsInCode(r'''
-class C {
- C.foo();
+ test_enum() async {
+ await assertNoErrorsInCode(r'''
+enum E {
+ v.foo();
+ const E.foo(); // _$foo
static void foo() {}
}
-''', [
- error(CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_AND_STATIC_METHOD, 14,
- 3),
- ]);
+''');
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_field_and_method_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_field_and_method_test.dart
index 2abf55f..62220d0 100644
--- a/pkg/analyzer/test/src/diagnostics/conflicting_field_and_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/conflicting_field_and_method_test.dart
@@ -53,4 +53,49 @@
error(CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, 49, 3),
]);
}
+
+ test_enum_inMixin_field() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ void foo() {}
+}
+
+enum E with M {
+ v;
+ final int foo = 0;
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, 62, 3),
+ ]);
+ }
+
+ test_enum_inMixin_getter() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ void foo() {}
+}
+
+enum E with M {
+ v;
+ int get foo => 0;
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, 60, 3),
+ ]);
+ }
+
+ test_enum_inMixin_setter() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ void foo() {}
+}
+
+enum E with M {
+ v;
+ set foo(int _) {}
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, 56, 3),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_method_and_field_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_method_and_field_test.dart
index 1366e18..903c338 100644
--- a/pkg/analyzer/test/src/diagnostics/conflicting_method_and_field_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/conflicting_method_and_field_test.dart
@@ -53,4 +53,34 @@
error(CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, 50, 3),
]);
}
+
+ test_enum_inMixin_getter() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ int get foo => 0;
+}
+
+enum E with M {
+ v;
+ void foo() {}
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, 61, 3),
+ ]);
+ }
+
+ test_enum_inMixin_setter() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ set foo(int _) {}
+}
+
+enum E with M {
+ v;
+ void foo() {}
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, 61, 3),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_static_and_instance_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_static_and_instance_test.dart
index cd47d2e..61fb991 100644
--- a/pkg/analyzer/test/src/diagnostics/conflicting_static_and_instance_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/conflicting_static_and_instance_test.dart
@@ -712,6 +712,46 @@
@reflectiveTest
class ConflictingStaticAndInstanceMixinTest extends PubPackageResolutionTest {
+ test_dartCoreEnum_index_field() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ static int index = 0;
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, 31, 5),
+ ]);
+ }
+
+ test_dartCoreEnum_index_getter() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ static int get index => 0;
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, 35, 5),
+ ]);
+ }
+
+ test_dartCoreEnum_index_method() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ static int index() => 0;
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, 31, 5),
+ ]);
+ }
+
+ test_dartCoreEnum_index_setter() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ static set index(int _) {}
+}
+''', [
+ error(CompileTimeErrorCode.CONFLICTING_STATIC_AND_INSTANCE, 31, 5),
+ ]);
+ }
+
test_inConstraint_getter_getter() async {
await assertErrorsInCode(r'''
class A {
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_constructor_default_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_constructor_default_test.dart
index d0d1172..5ac5636 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_constructor_default_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_constructor_default_test.dart
@@ -37,6 +37,17 @@
]);
}
+ test_class_new_empty() async {
+ await assertErrorsInCode(r'''
+class C {
+ C.new();
+ C();
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, 23, 1),
+ ]);
+ }
+
test_class_new_new() async {
await assertErrorsInCode(r'''
class C {
@@ -47,4 +58,52 @@
error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, 23, 5),
]);
}
+
+ test_enum_empty_empty() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ const E();
+ const E();
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, 35, 1),
+ ]);
+ }
+
+ test_enum_empty_new() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ const E();
+ const E.new();
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, 35, 5),
+ ]);
+ }
+
+ test_enum_new_empty() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ const E.new();
+ const E();
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, 39, 1),
+ ]);
+ }
+
+ test_enum_new_new() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ const E.new();
+ const E.new();
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, 39, 5),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_constructor_name_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_constructor_name_test.dart
index b99fc99..166ce79 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_constructor_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_constructor_name_test.dart
@@ -25,4 +25,16 @@
error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, 23, 5),
]);
}
+
+ test_enum() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v.foo();
+ const E.foo();
+ const E.foo();
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, 45, 5),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
index 09a546f..517491f 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
@@ -329,6 +329,26 @@
@reflectiveTest
class DuplicateDefinitionEnumTest extends PubPackageResolutionTest {
+ test_constant() async {
+ await assertErrorsInCode(r'''
+enum E {
+ foo, foo
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 16, 3),
+ ]);
+ }
+
+ test_constant_values() async {
+ await assertErrorsInCode(r'''
+enum E {
+ values
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 11, 6),
+ ]);
+ }
+
test_instance_field_field() async {
await assertErrorsInCode(r'''
enum E {
@@ -491,6 +511,48 @@
]);
}
+ test_static_constant_field() async {
+ await assertErrorsInCode(r'''
+enum E {
+ foo;
+ static int foo = 0;
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 29, 3),
+ ]);
+ }
+
+ test_static_constant_getter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ foo;
+ static int get foo => 0;
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 33, 3),
+ ]);
+ }
+
+ test_static_constant_method() async {
+ await assertErrorsInCode(r'''
+enum E {
+ foo;
+ static void foo() {}
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 30, 3),
+ ]);
+ }
+
+ test_static_constant_setter() async {
+ await assertNoErrorsInCode(r'''
+enum E {
+ foo;
+ static set foo(int _) {}
+}
+''');
+ }
+
test_static_field_field() async {
await assertErrorsInCode(r'''
enum E {
@@ -527,6 +589,17 @@
]);
}
+ test_static_field_values() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ static int values = 0;
+}
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 6),
+ ]);
+ }
+
test_static_fieldFinal_getter() async {
await assertErrorsInCode(r'''
enum E {
diff --git a/pkg/analyzer/test/src/diagnostics/enum_with_abstract_member_test.dart b/pkg/analyzer/test/src/diagnostics/enum_with_abstract_member_test.dart
new file mode 100644
index 0000000..3f5d7d3
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/enum_with_abstract_member_test.dart
@@ -0,0 +1,50 @@
+// 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:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(EnumWithAbstractMemberTest);
+ });
+}
+
+@reflectiveTest
+class EnumWithAbstractMemberTest extends PubPackageResolutionTest {
+ test_getter() async {
+ await assertErrorsInCode('''
+enum E {
+ v;
+ int get foo;
+}
+''', [
+ error(CompileTimeErrorCode.ENUM_WITH_ABSTRACT_MEMBER, 16, 12),
+ ]);
+ }
+
+ test_method() async {
+ await assertErrorsInCode('''
+enum E {
+ v;
+ void foo();
+}
+''', [
+ error(CompileTimeErrorCode.ENUM_WITH_ABSTRACT_MEMBER, 16, 11),
+ ]);
+ }
+
+ test_setter() async {
+ await assertErrorsInCode('''
+enum E {
+ v;
+ set foo(int _);
+}
+''', [
+ error(CompileTimeErrorCode.ENUM_WITH_ABSTRACT_MEMBER, 16, 15),
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/illegal_enum_values_declaration_test.dart b/pkg/analyzer/test/src/diagnostics/illegal_enum_values_declaration_test.dart
new file mode 100644
index 0000000..25014ed
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/illegal_enum_values_declaration_test.dart
@@ -0,0 +1,205 @@
+// 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:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(IllegalEnumValuesDeclarationTest);
+ });
+}
+
+@reflectiveTest
+class IllegalEnumValuesDeclarationTest extends PubPackageResolutionTest {
+ test_class_field() async {
+ await assertErrorsInCode(r'''
+abstract class A implements Enum {
+ int values = 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 41, 6),
+ ]);
+ }
+
+ test_class_field_static() async {
+ await assertNoErrorsInCode(r'''
+abstract class A implements Enum {
+ static int values = 0;
+}
+''');
+ }
+
+ test_class_getter() async {
+ await assertErrorsInCode(r'''
+abstract class A implements Enum {
+ int get values => 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 45, 6),
+ ]);
+ }
+
+ test_class_getter_static() async {
+ await assertNoErrorsInCode(r'''
+abstract class A implements Enum {
+ static int get values => 0;
+}
+''');
+ }
+
+ test_class_method() async {
+ await assertErrorsInCode(r'''
+abstract class A implements Enum {
+ void values() {}
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 42, 6),
+ ]);
+ }
+
+ test_class_method_static() async {
+ await assertNoErrorsInCode(r'''
+abstract class A implements Enum {
+ static void values() {}
+}
+''');
+ }
+
+ test_class_setter() async {
+ await assertErrorsInCode(r'''
+abstract class A implements Enum {
+ set values(int _) {}
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 41, 6),
+ ]);
+ }
+
+ test_class_setter_static() async {
+ await assertNoErrorsInCode(r'''
+abstract class A implements Enum {
+ static set values(int _) {}
+}
+''');
+ }
+
+ test_enum_field() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ int values = 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 20, 6),
+ ]);
+ }
+
+ test_enum_getter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ int get values => 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 24, 6),
+ ]);
+ }
+
+ test_enum_method() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void values() {}
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 21, 6),
+ ]);
+ }
+
+ test_enum_setter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ set values(int _) {}
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 20, 6),
+ ]);
+ }
+
+ test_mixin_field() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ int values = 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 24, 6),
+ ]);
+ }
+
+ test_mixin_field_static() async {
+ await assertNoErrorsInCode(r'''
+mixin M on Enum {
+ static int values = 0;
+}
+''');
+ }
+
+ test_mixin_getter() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ int get values => 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 28, 6),
+ ]);
+ }
+
+ test_mixin_getter_static() async {
+ await assertNoErrorsInCode(r'''
+mixin M on Enum {
+ static int get values => 0;
+}
+''');
+ }
+
+ test_mixin_method() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ void values() {}
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 25, 6),
+ ]);
+ }
+
+ test_mixin_method_static() async {
+ await assertNoErrorsInCode(r'''
+mixin M on Enum {
+ static void values() {}
+}
+''');
+ }
+
+ test_mixin_setter() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ set values(int _) {}
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_DECLARATION, 24, 6),
+ ]);
+ }
+
+ test_mixin_setter_static() async {
+ await assertNoErrorsInCode(r'''
+mixin M on Enum {
+ static set values(int _) {}
+}
+''');
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/illegal_enum_values_inheritance_test.dart b/pkg/analyzer/test/src/diagnostics/illegal_enum_values_inheritance_test.dart
new file mode 100644
index 0000000..234df7e
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/illegal_enum_values_inheritance_test.dart
@@ -0,0 +1,151 @@
+// 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:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(IllegalEnumValuesInheritanceTest);
+ });
+}
+
+@reflectiveTest
+class IllegalEnumValuesInheritanceTest extends PubPackageResolutionTest {
+ test_class_field_fromExtends() async {
+ await assertErrorsInCode(r'''
+class A {
+ int values = 0;
+}
+
+abstract class B extends A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 46, 1),
+ ]);
+ }
+
+ test_class_field_fromImplements() async {
+ await assertErrorsInCode(r'''
+class A {
+ int values = 0;
+}
+
+abstract class B implements A, Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 46, 1),
+ ]);
+ }
+
+ test_class_field_fromWith() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ int values = 0;
+}
+
+abstract class B with M implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 46, 1),
+ ]);
+ }
+
+ test_class_getter() async {
+ await assertErrorsInCode(r'''
+class A {
+ int get values => 0;
+}
+
+abstract class B extends A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 51, 1),
+ ]);
+ }
+
+ test_class_method() async {
+ await assertErrorsInCode(r'''
+class A {
+ void values() {}
+}
+
+abstract class B extends A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 47, 1),
+ ]);
+ }
+
+ test_class_setter() async {
+ await assertErrorsInCode(r'''
+class A {
+ set values(int _) {}
+}
+
+abstract class B extends A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 51, 1),
+ ]);
+ }
+
+ test_enum_method() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ int values() => 0;
+}
+
+enum E with M {
+ v
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 39, 1),
+ ]);
+ }
+
+ test_mixin_field() async {
+ await assertErrorsInCode(r'''
+class A {
+ int values = 0;
+}
+
+mixin M on A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 37, 1),
+ ]);
+ }
+
+ test_mixin_getter() async {
+ await assertErrorsInCode(r'''
+class A {
+ int get values => 0;
+}
+
+mixin M on A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 42, 1),
+ ]);
+ }
+
+ test_mixin_method() async {
+ await assertErrorsInCode(r'''
+class A {
+ int values() => 0;
+}
+
+mixin M on A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 40, 1),
+ ]);
+ }
+
+ test_mixin_setter() async {
+ await assertErrorsInCode(r'''
+class A {
+ set values(int _) {}
+}
+
+mixin M on A implements Enum {}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 42, 1),
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/illegal_non_abstract_enum_index_test.dart b/pkg/analyzer/test/src/diagnostics/illegal_non_abstract_enum_index_test.dart
new file mode 100644
index 0000000..a2b7413
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/illegal_non_abstract_enum_index_test.dart
@@ -0,0 +1,129 @@
+// 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:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(IllegalNonAbstractEnumIndexTest);
+ });
+}
+
+@reflectiveTest
+class IllegalNonAbstractEnumIndexTest extends PubPackageResolutionTest {
+ test_class_field() async {
+ await assertErrorsInCode(r'''
+abstract class A implements Enum {
+ int index = 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX, 41, 5),
+ ]);
+ }
+
+ test_class_getter() async {
+ await assertErrorsInCode(r'''
+abstract class A implements Enum {
+ int get index => 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX, 45, 5),
+ ]);
+ }
+
+ test_class_getter_abstract() async {
+ await assertNoErrorsInCode(r'''
+abstract class A implements Enum {
+ int get index;
+}
+''');
+ }
+
+ test_class_setter() async {
+ await assertNoErrorsInCode(r'''
+abstract class A implements Enum {
+ set index(int _) {}
+}
+''');
+ }
+
+ test_enum_field() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ final int index = 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX, 26, 5),
+ ]);
+ }
+
+ test_enum_getter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ int get index => 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX, 24, 5),
+ ]);
+ }
+
+ test_enum_getter_abstract() async {
+ await assertNoErrorsInCode(r'''
+enum E {
+ v;
+ int get index;
+}
+''');
+ }
+
+ test_enum_setter() async {
+ await assertNoErrorsInCode(r'''
+enum E {
+ v;
+ set index(int _) {}
+}
+''');
+ }
+
+ test_mixin_field() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ int index = 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX, 24, 5),
+ ]);
+ }
+
+ test_mixin_getter() async {
+ await assertErrorsInCode(r'''
+mixin M on Enum {
+ int get index => 0;
+}
+''', [
+ error(CompileTimeErrorCode.ILLEGAL_NON_ABSTRACT_ENUM_INDEX, 28, 5),
+ ]);
+ }
+
+ test_mixin_getter_abstract() async {
+ await assertNoErrorsInCode(r'''
+mixin M on Enum {
+ int get index;
+}
+''');
+ }
+
+ test_mixin_setter() async {
+ await assertNoErrorsInCode(r'''
+mixin M on Enum {
+ set index(int _) {}
+}
+''');
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_constructor_name_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_constructor_name_test.dart
index d6692a3..667bf55 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_constructor_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_constructor_name_test.dart
@@ -15,7 +15,7 @@
@reflectiveTest
class InvalidConstructorNameTest extends PubPackageResolutionTest {
- test_notEnclosingClassName_defined() async {
+ test_class_notEnclosingClassName_defined() async {
await assertErrorsInCode(r'''
class A {
B() : super();
@@ -26,7 +26,7 @@
]);
}
- test_notEnclosingClassName_named() async {
+ test_class_notEnclosingClassName_named() async {
await assertErrorsInCode(r'''
class A {}
class B {
@@ -38,7 +38,7 @@
]);
}
- test_notEnclosingClassName_new() async {
+ test_class_notEnclosingClassName_new() async {
await assertErrorsInCode(r'''
class A {}
@@ -51,7 +51,7 @@
]);
}
- test_notEnclosingClassName_undefined() async {
+ test_class_notEnclosingClassName_undefined() async {
await assertErrorsInCode(r'''
class A {
B() : super();
@@ -60,4 +60,18 @@
error(ParserErrorCode.INVALID_CONSTRUCTOR_NAME, 12, 1),
]);
}
+
+ test_enum_named() async {
+ await assertErrorsInCode(r'''
+class A {}
+
+enum E {
+ v.foo();
+ const A.foo();
+ const E.foo();
+}
+''', [
+ error(ParserErrorCode.INVALID_CONSTRUCTOR_NAME, 40, 1),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/member_with_class_name_test.dart b/pkg/analyzer/test/src/diagnostics/member_with_class_name_test.dart
index 9057423..0c2cbc9 100644
--- a/pkg/analyzer/test/src/diagnostics/member_with_class_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/member_with_class_name_test.dart
@@ -80,6 +80,61 @@
]);
}
+ test_enum_field() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ final int E = 0;
+}
+''', [
+ error(ParserErrorCode.MEMBER_WITH_CLASS_NAME, 26, 1),
+ ]);
+ }
+
+ test_enum_getter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ int get E => 0;
+}
+''', [
+ error(ParserErrorCode.MEMBER_WITH_CLASS_NAME, 24, 1),
+ ]);
+ }
+
+ test_enum_getter_static() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ static int get E => 0;
+}
+''', [
+ error(ParserErrorCode.MEMBER_WITH_CLASS_NAME, 31, 1),
+ ]);
+ }
+
+ test_enum_setter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ set E(int _) {}
+}
+''', [
+ error(ParserErrorCode.MEMBER_WITH_CLASS_NAME, 20, 1),
+ ]);
+ }
+
+ test_enum_setter_static() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ static set E(int _) {}
+}
+''', [
+ error(ParserErrorCode.MEMBER_WITH_CLASS_NAME, 27, 1),
+ ]);
+ }
+
test_mixin_getter() async {
await assertErrorsInCode(r'''
mixin M {
diff --git a/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart
index a94e1c1..0d92e85 100644
--- a/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart
@@ -200,11 +200,8 @@
B();
}
''', [
- error(
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT,
- 58,
- 1),
+ error(CompileTimeErrorCode.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS,
+ 58, 1),
]);
}
@@ -239,11 +236,8 @@
B({required super.a});
}
''', [
- error(
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_MISSING_REQUIRED_ARGUMENT,
- 75,
- 1),
+ error(CompileTimeErrorCode.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS,
+ 75, 1),
]);
}
@@ -278,11 +272,8 @@
B();
}
''', [
- error(
- CompileTimeErrorCode
- .IMPLICIT_UNNAMED_SUPER_CONSTRUCTOR_INVOCATION_NOT_ENOUGH_POSITIONAL_ARGUMENTS,
- 42,
- 1),
+ error(CompileTimeErrorCode.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS,
+ 42, 1),
]);
}
diff --git a/pkg/analyzer/test/src/diagnostics/non_abstract_class_inherits_abstract_member_test.dart b/pkg/analyzer/test/src/diagnostics/non_abstract_class_inherits_abstract_member_test.dart
index 92d76ac..5976ffd 100644
--- a/pkg/analyzer/test/src/diagnostics/non_abstract_class_inherits_abstract_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_abstract_class_inherits_abstract_member_test.dart
@@ -702,6 +702,108 @@
]);
}
+ test_enum_getter_fromInterface() async {
+ await assertErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+enum E implements A {
+ v;
+}
+''', [
+ error(
+ CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
+ 38,
+ 1),
+ ]);
+ }
+
+ test_enum_getter_fromMixin() async {
+ await assertErrorsInCode('''
+mixin M {
+ int get foo;
+}
+
+enum E with M {
+ v;
+}
+''', [
+ error(
+ CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
+ 33,
+ 1),
+ ]);
+ }
+
+ test_enum_method_fromInterface() async {
+ await assertErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+enum E implements A {
+ v;
+}
+''', [
+ error(
+ CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
+ 34,
+ 1),
+ ]);
+ }
+
+ test_enum_method_fromMixin() async {
+ await assertErrorsInCode('''
+mixin M {
+ void foo();
+}
+
+enum E with M {
+ v;
+}
+''', [
+ error(
+ CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
+ 32,
+ 1),
+ ]);
+ }
+
+ test_enum_setter_fromInterface() async {
+ await assertErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+enum E implements A {
+ v;
+}
+''', [
+ error(
+ CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
+ 38,
+ 1),
+ ]);
+ }
+
+ test_enum_setter_fromMixin() async {
+ await assertErrorsInCode('''
+mixin M {
+ set foo(int _);
+}
+
+enum E with M {
+ v;
+}
+''', [
+ error(
+ CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
+ 36,
+ 1),
+ ]);
+ }
+
test_external_field_final_implement_getter() async {
await assertNoErrorsInCode('''
class A {
diff --git a/pkg/analyzer/test/src/diagnostics/non_const_generative_enum_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/non_const_generative_enum_constructor_test.dart
index 0494484..5ef58f0 100644
--- a/pkg/analyzer/test/src/diagnostics/non_const_generative_enum_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_const_generative_enum_constructor_test.dart
@@ -36,11 +36,11 @@
test_generative_nonConst_named() async {
await assertErrorsInCode(r'''
enum E {
- v;
+ v.named();
E.named();
}
''', [
- error(CompileTimeErrorCode.NON_CONST_GENERATIVE_ENUM_CONSTRUCTOR, 16, 7),
+ error(CompileTimeErrorCode.NON_CONST_GENERATIVE_ENUM_CONSTRUCTOR, 24, 7),
]);
}
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index 3c0d14a..7534e41 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -158,6 +158,7 @@
as enum_constant_same_name_as_enclosing;
import 'enum_mixin_with_instance_variable_test.dart'
as enum_mixin_with_instance_variable;
+import 'enum_with_abstract_member_test.dart' as enum_with_abstract_member;
import 'equal_elements_in_const_set_test.dart' as equal_elements_in_const_set;
import 'equal_elements_in_set_test.dart' as equal_elements_in_set;
import 'equal_keys_in_const_map_test.dart' as equal_keys_in_const_map;
@@ -252,8 +253,14 @@
import 'illegal_async_generator_return_type_test.dart'
as illegal_async_generator_return_type;
import 'illegal_async_return_type_test.dart' as illegal_async_return_type;
+import 'illegal_enum_values_declaration_test.dart'
+ as illegal_enum_values_declaration;
+import 'illegal_enum_values_inheritance_test.dart'
+ as illegal_enum_values_inheritance;
import 'illegal_language_version_override_test.dart'
as illegal_language_version_override;
+import 'illegal_non_abstract_enum_index_test.dart'
+ as illegal_non_abstract_enum_index;
import 'illegal_sync_generator_return_type_test.dart'
as illegal_sync_generator_return_type;
import 'implements_deferred_class_test.dart' as implements_deferred_class;
@@ -709,6 +716,10 @@
import 'undefined_constructor_in_initializer_test.dart'
as undefined_constructor_in_initializer;
import 'undefined_enum_constant_test.dart' as undefined_enum_constant;
+import 'undefined_enum_constructor_named_test.dart'
+ as undefined_enum_constructor_named;
+import 'undefined_enum_constructor_unnamed_test.dart'
+ as undefined_enum_constructor_unnamed;
import 'undefined_extension_getter_test.dart' as undefined_extension_getter;
import 'undefined_extension_method_test.dart' as undefined_extension_method;
import 'undefined_extension_operator_test.dart' as undefined_extension_operator;
@@ -881,6 +892,7 @@
duplicate_shown_name.main();
enum_constant_same_name_as_enclosing.main();
enum_mixin_with_instance_variable.main();
+ enum_with_abstract_member.main();
equal_elements_in_const_set.main();
equal_elements_in_set.main();
equal_keys_in_const_map.main();
@@ -941,7 +953,10 @@
if_element_condition_from_deferred_library.main();
illegal_async_generator_return_type.main();
illegal_async_return_type.main();
+ illegal_enum_values_declaration.main();
+ illegal_enum_values_inheritance.main();
illegal_language_version_override.main();
+ illegal_non_abstract_enum_index.main();
illegal_sync_generator_return_type.main();
implements_deferred_class.main();
implements_disallowed_class.main();
@@ -1238,6 +1253,8 @@
undefined_constructor_in_initializer_default.main();
undefined_constructor_in_initializer.main();
undefined_enum_constant.main();
+ undefined_enum_constructor_named.main();
+ undefined_enum_constructor_unnamed.main();
undefined_extension_getter.main();
undefined_extension_method.main();
undefined_extension_operator.main();
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_enum_constructor_named_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_enum_constructor_named_test.dart
new file mode 100644
index 0000000..3531158
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/undefined_enum_constructor_named_test.dart
@@ -0,0 +1,27 @@
+// 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:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(UndefinedEnumConstructorNamedTest);
+ });
+}
+
+@reflectiveTest
+class UndefinedEnumConstructorNamedTest extends PubPackageResolutionTest {
+ test_it() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v.named()
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_NAMED, 13, 5),
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_enum_constructor_unnamed_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_enum_constructor_unnamed_test.dart
new file mode 100644
index 0000000..30fac95
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/undefined_enum_constructor_unnamed_test.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:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(UndefinedEnumConstructorUnnamedTest);
+ });
+}
+
+@reflectiveTest
+class UndefinedEnumConstructorUnnamedTest extends PubPackageResolutionTest {
+ test_withArguments() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v();
+ const E.named();
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED, 11, 1),
+ ]);
+ }
+
+ test_withoutArguments() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ const E.named();
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_ENUM_CONSTRUCTOR_UNNAMED, 11, 1),
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_super_getter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_super_getter_test.dart
index d932f3e..c207e73 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_super_getter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_super_getter_test.dart
@@ -27,4 +27,32 @@
error(CompileTimeErrorCode.UNDEFINED_SUPER_GETTER, 58, 1),
]);
}
+
+ test_enum() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void f() {
+ super.foo;
+ }
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_GETTER, 37, 3),
+ ]);
+ }
+
+ test_enum_OK() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ int get foo => 0;
+}
+
+enum E with M {
+ v;
+ void f() {
+ super.foo;
+ }
+}
+''');
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_super_method_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_super_method_test.dart
index 8c77143..bf205ea 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_super_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_super_method_test.dart
@@ -34,6 +34,34 @@
assertTypeDynamic(invocation);
}
+ test_enum() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void f() {
+ super.foo();
+ }
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_METHOD, 37, 3),
+ ]);
+ }
+
+ test_enum_OK() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ void foo() {}
+}
+
+enum E with M {
+ v;
+ void f() {
+ super.foo();
+ }
+}
+''');
+ }
+
test_mixin() async {
await assertErrorsInCode(r'''
class A {}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_super_operator_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_super_operator_test.dart
index 623f271..618613f 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_super_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_super_operator_test.dart
@@ -67,4 +67,88 @@
error(CompileTimeErrorCode.UNDEFINED_SUPER_OPERATOR, 71, 7),
]);
}
+
+ test_enum_binaryExpression() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void f() {
+ super + 0;
+ }
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_OPERATOR, 37, 1),
+ ]);
+ }
+
+ test_enum_binaryExpression_OK() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ int operator +(int a) => 0;
+}
+
+enum E with M {
+ v;
+ void f() {
+ super + 0;
+ }
+}
+''');
+ }
+
+ test_enum_indexBoth() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void f() {
+ super[0]++;
+ }
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_OPERATOR, 36, 3),
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_OPERATOR, 36, 3),
+ ]);
+ }
+
+ test_enum_indexBoth_OK() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ int operator [](int index) => 0;
+ void operator []=(int index, int value) {}
+}
+
+enum E with M {
+ v;
+ void f() {
+ super[0]++;
+ }
+}
+''');
+ }
+
+ test_enum_indexGetter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void f() {
+ super[0];
+ }
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_OPERATOR, 36, 3),
+ ]);
+ }
+
+ test_enum_indexSetter() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void f() {
+ super[0] = 0;
+ }
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_OPERATOR, 36, 3),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_super_setter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_super_setter_test.dart
index 934fbd5..0b29be5 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_super_setter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_super_setter_test.dart
@@ -27,4 +27,32 @@
error(CompileTimeErrorCode.UNDEFINED_SUPER_SETTER, 49, 1),
]);
}
+
+ test_enum() async {
+ await assertErrorsInCode(r'''
+enum E {
+ v;
+ void f() {
+ super.foo = 0;
+ }
+}
+''', [
+ error(CompileTimeErrorCode.UNDEFINED_SUPER_SETTER, 37, 3),
+ ]);
+ }
+
+ test_enum_OK() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ set foo(int _) {}
+}
+
+enum E with M {
+ v;
+ void f() {
+ super.foo = 0;
+ }
+}
+''');
+ }
}
diff --git a/pkg/analyzer/test/src/fasta/ast_builder_test.dart b/pkg/analyzer/test/src/fasta/ast_builder_test.dart
index c31f6e7..fd2f5aa 100644
--- a/pkg/analyzer/test/src/fasta/ast_builder_test.dart
+++ b/pkg/analyzer/test/src/fasta/ast_builder_test.dart
@@ -58,6 +58,24 @@
expect(member.initializers, hasLength(1));
}
+ void test_enum_constant_withTypeArgumentsWithoutArguments() {
+ var parseResult = parseStringWithErrors(r'''
+enum E<T> {
+ v<int>;
+}
+''');
+ parseResult.assertErrors([
+ error(ParserErrorCode.ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS,
+ 15, 5),
+ ]);
+
+ var v = parseResult.findNode.enumConstantDeclaration('v<int>');
+ check(v).name.name.isEqualTo('v');
+ check(v).arguments.isNotNull
+ ..typeArguments.isNotNull
+ ..argumentList.isSynthetic;
+ }
+
void test_getter_sameNameAsClass() {
var parseResult = parseStringWithErrors(r'''
class A {
diff --git a/pkg/analyzer/test/util/ast_check.dart b/pkg/analyzer/test/util/ast_check.dart
index 0cc0ab6..c744058 100644
--- a/pkg/analyzer/test/util/ast_check.dart
+++ b/pkg/analyzer/test/util/ast_check.dart
@@ -6,6 +6,74 @@
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer_utilities/check/check.dart';
+import 'token_check.dart';
+
+extension ArgumentListExtension on CheckTarget<ArgumentList> {
+ CheckTarget<List<Expression>> get arguments {
+ return nest(
+ value.arguments,
+ (selected) => 'has arguments ${valueStr(selected)}',
+ );
+ }
+
+ void get isSynthetic {
+ leftParenthesis
+ ..isOpenParenthesis
+ ..isSynthetic;
+ rightParenthesis
+ ..isCloseParenthesis
+ ..isSynthetic;
+ arguments.isEmpty;
+ }
+
+ CheckTarget<Token> get leftParenthesis {
+ return nest(
+ value.leftParenthesis,
+ (selected) => 'has leftParenthesis ${valueStr(selected)}',
+ );
+ }
+
+ CheckTarget<Token> get rightParenthesis {
+ return nest(
+ value.rightParenthesis,
+ (selected) => 'has rightParenthesis ${valueStr(selected)}',
+ );
+ }
+}
+
+extension EnumConstantArgumentsExtension on CheckTarget<EnumConstantArguments> {
+ CheckTarget<ArgumentList> get argumentList {
+ return nest(
+ value.argumentList,
+ (selected) => 'has argumentList ${valueStr(selected)}',
+ );
+ }
+
+ CheckTarget<TypeArgumentList?> get typeArguments {
+ return nest(
+ value.typeArguments,
+ (selected) => 'has typeArguments ${valueStr(selected)}',
+ );
+ }
+}
+
+extension EnumConstantDeclarationExtension
+ on CheckTarget<EnumConstantDeclaration> {
+ CheckTarget<EnumConstantArguments?> get arguments {
+ return nest(
+ value.arguments,
+ (selected) => 'has arguments ${valueStr(selected)}',
+ );
+ }
+
+ CheckTarget<SimpleIdentifier> get name {
+ return nest(
+ value.name,
+ (selected) => 'has name ${valueStr(selected)}',
+ );
+ }
+}
+
extension FormalParameterExtension on CheckTarget<FormalParameter> {
CheckTarget<SimpleIdentifier?> get identifier {
return nest(
diff --git a/pkg/analyzer/test/util/token_check.dart b/pkg/analyzer/test/util/token_check.dart
index 7d8fc24..d07687b 100644
--- a/pkg/analyzer/test/util/token_check.dart
+++ b/pkg/analyzer/test/util/token_check.dart
@@ -15,7 +15,29 @@
}
}
-extension TokenExtension on CheckTarget<Token?> {
+extension TokenExtension on CheckTarget<Token> {
+ void get isCloseParenthesis {
+ type.isEqualTo(TokenType.CLOSE_PAREN);
+ }
+
+ void get isOpenParenthesis {
+ type.isEqualTo(TokenType.OPEN_PAREN);
+ }
+
+ void get isSynthetic {
+ if (value.isSynthetic) return;
+ fail('Not synthetic');
+ }
+
+ CheckTarget<TokenType> get type {
+ return nest(
+ value.type,
+ (selected) => 'has type ${valueStr(selected)}',
+ );
+ }
+}
+
+extension TokenQuestionExtension on CheckTarget<Token?> {
CheckTarget<KeywordToken> get isKeyword {
return isA<KeywordToken>();
}
diff --git a/pkg/compiler/lib/src/common/elements.dart b/pkg/compiler/lib/src/common/elements.dart
index b33db18..0f88c4e 100644
--- a/pkg/compiler/lib/src/common/elements.dart
+++ b/pkg/compiler/lib/src/common/elements.dart
@@ -851,9 +851,6 @@
FunctionEntity get rawStartupMetrics =>
_rawStartupMetrics ??= _findHelperFunction('rawStartupMetrics');
- FunctionEntity get loadLibraryWrapper =>
- _findHelperFunction("_loadLibraryWrapper");
-
FunctionEntity get loadDeferredLibrary =>
_findHelperFunction("loadDeferredLibrary");
@@ -1594,10 +1591,6 @@
/// superclasses.
void forEachMixin(ClassEntity cls, void f(ClassEntity mixin));
- /// Returns `true` if [member] a the synthetic getter `loadLibrary` injected
- /// on deferred libraries.
- bool isDeferredLoadLibraryGetter(MemberEntity member);
-
/// Returns the imports seen in [library]
Iterable<ImportEntity> getImports(LibraryEntity library);
diff --git a/pkg/compiler/lib/src/compile_time_constants.dart b/pkg/compiler/lib/src/compile_time_constants.dart
deleted file mode 100644
index 20e7219..0000000
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2012, 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.
-
-library dart2js.compile_time_constant_evaluator;
-
-import 'common/tasks.dart' show CompilerTask, Measurer;
-import 'elements/entities.dart';
-
-/// A [ConstantEnvironment] provides access for constants compiled for variable
-/// initializers.
-abstract class ConstantEnvironment {}
-
-/// A [BackendConstantEnvironment] provides access to constants needed for
-/// backend implementation.
-abstract class BackendConstantEnvironment extends ConstantEnvironment {
- /// Register that [element] needs lazy initialization.
- void registerLazyStatic(FieldEntity element);
-}
-
-/// Interface for the task that compiles the constant environments for the
-/// frontend and backend interpretation of compile-time constants.
-abstract class ConstantCompilerTask extends CompilerTask
- implements ConstantEnvironment {
- ConstantCompilerTask(Measurer measurer) : super(measurer);
-}
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index 977d2da..56d4682 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -716,8 +716,6 @@
/// prefix.
BackendImpact get loadLibrary {
return _loadLibrary ??= BackendImpact(globalUses: [
- // TODO(redemption): delete wrapper when we sunset the old frontend.
- _commonElements.loadLibraryWrapper,
_commonElements.loadDeferredLibrary,
]);
}
diff --git a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
index 915c542..8c957ec 100644
--- a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
+++ b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
@@ -7,6 +7,7 @@
import '../common/names.dart' show Identifiers, Selectors;
import '../elements/entities.dart';
import '../inferrer/types.dart';
+import '../kernel/no_such_method_resolver.dart';
import '../serialization/serialization.dart';
/// [NoSuchMethodRegistry] and [NoSuchMethodData] categorizes `noSuchMethod`
@@ -48,63 +49,53 @@
/// Registry for collecting `noSuchMethod` implementations and categorizing them
/// into categories `A`, `B`, `C`, `D`.
-abstract class NoSuchMethodRegistry {
- /// Register [noSuchMethodElement].
- void registerNoSuchMethod(FunctionEntity noSuchMethodElement);
-
- /// Categorizes the registered methods.
- void onQueueEmpty();
-
- /// `true` if a category `B` method has been seen so far.
- bool get hasThrowingNoSuchMethod;
-
- /// `true` if a category `D` method has been seen so far.
- bool get hasComplexNoSuchMethod;
-
- /// Closes the registry and returns data object used during type inference.
- NoSuchMethodData close();
-}
-
-class NoSuchMethodRegistryImpl implements NoSuchMethodRegistry {
+class NoSuchMethodRegistry {
/// The implementations that fall into category A, described above.
- final Set<FunctionEntity> defaultImpls = {};
+ final Set<FunctionEntity> _defaultImpls = {};
/// The implementations that fall into category B, described above.
- final Set<FunctionEntity> throwingImpls = {};
+ final Set<FunctionEntity> _throwingImpls = {};
/// The implementations that fall into category C, described above.
// TODO(johnniwinther): Remove this category when Dart 1 is no longer
// supported.
- final Set<FunctionEntity> notApplicableImpls = {};
+ final Set<FunctionEntity> _notApplicableImpls = {};
/// The implementations that fall into category D, described above.
- final Set<FunctionEntity> otherImpls = {};
+ final Set<FunctionEntity> _otherImpls = {};
/// The implementations that have not yet been categorized.
final Set<FunctionEntity> _uncategorizedImpls = {};
/// The implementations that a forwarding syntax as defined by
/// [NoSuchMethodResolver.hasForwardSyntax].
- final Set<FunctionEntity> forwardingSyntaxImpls = {};
+ final Set<FunctionEntity> _forwardingSyntaxImpls = {};
final CommonElements _commonElements;
final NoSuchMethodResolver _resolver;
- NoSuchMethodRegistryImpl(this._commonElements, this._resolver);
+ NoSuchMethodRegistry(this._commonElements, this._resolver);
NoSuchMethodResolver get internalResolverForTesting => _resolver;
- @override
- bool get hasThrowingNoSuchMethod => throwingImpls.isNotEmpty;
- @override
- bool get hasComplexNoSuchMethod => otherImpls.isNotEmpty;
+ /// `true` if a category `B` method has been seen so far.
+ bool get hasThrowingNoSuchMethod => _throwingImpls.isNotEmpty;
- @override
+ /// `true` if a category `D` method has been seen so far.
+ bool get hasComplexNoSuchMethod => _otherImpls.isNotEmpty;
+
+ Iterable<FunctionEntity> get defaultImpls => _defaultImpls;
+
+ Iterable<FunctionEntity> get throwingImpls => _throwingImpls;
+
+ Iterable<FunctionEntity> get otherImpls => _otherImpls;
+
+ /// Register [noSuchMethodElement].
void registerNoSuchMethod(FunctionEntity noSuchMethodElement) {
_uncategorizedImpls.add(noSuchMethodElement);
}
- @override
+ /// Categorizes the registered methods.
void onQueueEmpty() {
_uncategorizedImpls.forEach(_categorizeImpl);
_uncategorizedImpls.clear();
@@ -113,62 +104,62 @@
NsmCategory _categorizeImpl(FunctionEntity element) {
assert(element.name == Identifiers.noSuchMethod_);
assert(!element.isAbstract);
- if (defaultImpls.contains(element)) {
+ if (_defaultImpls.contains(element)) {
return NsmCategory.DEFAULT;
}
- if (throwingImpls.contains(element)) {
+ if (_throwingImpls.contains(element)) {
return NsmCategory.THROWING;
}
- if (otherImpls.contains(element)) {
+ if (_otherImpls.contains(element)) {
return NsmCategory.OTHER;
}
- if (notApplicableImpls.contains(element)) {
+ if (_notApplicableImpls.contains(element)) {
return NsmCategory.NOT_APPLICABLE;
}
if (!Selectors.noSuchMethod_.signatureApplies(element)) {
- notApplicableImpls.add(element);
+ _notApplicableImpls.add(element);
return NsmCategory.NOT_APPLICABLE;
}
if (_commonElements.isDefaultNoSuchMethodImplementation(element)) {
- defaultImpls.add(element);
+ _defaultImpls.add(element);
return NsmCategory.DEFAULT;
} else if (_resolver.hasForwardingSyntax(element)) {
- forwardingSyntaxImpls.add(element);
+ _forwardingSyntaxImpls.add(element);
// If the implementation is 'noSuchMethod(x) => super.noSuchMethod(x);'
// then it is in the same category as the super call.
FunctionEntity superCall = _resolver.getSuperNoSuchMethod(element);
NsmCategory category = _categorizeImpl(superCall);
switch (category) {
case NsmCategory.DEFAULT:
- defaultImpls.add(element);
+ _defaultImpls.add(element);
break;
case NsmCategory.THROWING:
- throwingImpls.add(element);
+ _throwingImpls.add(element);
break;
case NsmCategory.OTHER:
- otherImpls.add(element);
+ _otherImpls.add(element);
break;
case NsmCategory.NOT_APPLICABLE:
// If the super method is not applicable, the call is redirected to
// `Object.noSuchMethod`.
- defaultImpls.add(element);
+ _defaultImpls.add(element);
category = NsmCategory.DEFAULT;
break;
}
return category;
} else if (_resolver.hasThrowingSyntax(element)) {
- throwingImpls.add(element);
+ _throwingImpls.add(element);
return NsmCategory.THROWING;
} else {
- otherImpls.add(element);
+ _otherImpls.add(element);
return NsmCategory.OTHER;
}
}
- @override
+ /// Closes the registry and returns data object used during type inference.
NoSuchMethodData close() {
- return NoSuchMethodDataImpl(
- throwingImpls, otherImpls, forwardingSyntaxImpls);
+ return NoSuchMethodData(
+ _throwingImpls, _otherImpls, _forwardingSyntaxImpls);
}
}
@@ -176,51 +167,30 @@
///
/// Post inference collected category `D` methods are into subcategories `D1`
/// and `D2`.
-abstract class NoSuchMethodData {
- /// Deserializes a [NoSuchMethodData] object from [source].
- factory NoSuchMethodData.readFromDataSource(DataSource source) =
- NoSuchMethodDataImpl.readFromDataSource;
-
- /// Serializes this [NoSuchMethodData] to [sink].
- void writeToDataSink(DataSink sink);
-
- /// Returns [true] if the given element is a complex [noSuchMethod]
- /// implementation. An implementation is complex if it falls into
- /// category D, as described above.
- bool isComplex(FunctionEntity element);
-
- /// Now that type inference is complete, split category D into two
- /// subcategories: D1, those that have no return type, and D2, those
- /// that have a return type.
- void categorizeComplexImplementations(GlobalTypeInferenceResults results);
-
- /// Emits a diagnostic about methods in categories `B`, `D1` and `D2`.
- void emitDiagnostic(DiagnosticReporter reporter);
-}
-
-class NoSuchMethodDataImpl implements NoSuchMethodData {
+class NoSuchMethodData {
/// Tag used for identifying serialized [NoSuchMethodData] objects in a
/// debugging data stream.
static const String tag = 'no-such-method-data';
/// The implementations that fall into category B, described above.
- final Set<FunctionEntity> throwingImpls;
+ final Set<FunctionEntity> _throwingImpls;
/// The implementations that fall into category D, described above.
- final Set<FunctionEntity> otherImpls;
+ final Set<FunctionEntity> _otherImpls;
/// The implementations that fall into category D1
- final Set<FunctionEntity> complexNoReturnImpls = {};
+ final Set<FunctionEntity> _complexNoReturnImpls = {};
/// The implementations that fall into category D2
- final Set<FunctionEntity> complexReturningImpls = {};
+ final Set<FunctionEntity> _complexReturningImpls = {};
- final Set<FunctionEntity> forwardingSyntaxImpls;
+ final Set<FunctionEntity> _forwardingSyntaxImpls;
- NoSuchMethodDataImpl(
- this.throwingImpls, this.otherImpls, this.forwardingSyntaxImpls);
+ NoSuchMethodData(
+ this._throwingImpls, this._otherImpls, this._forwardingSyntaxImpls);
- factory NoSuchMethodDataImpl.readFromDataSource(DataSource source) {
+ /// Deserializes a [NoSuchMethodData] object from [source].
+ factory NoSuchMethodData.readFromDataSource(DataSource source) {
source.begin(tag);
Set<FunctionEntity> throwingImpls =
source.readMembers<FunctionEntity>().toSet();
@@ -233,57 +203,70 @@
List<FunctionEntity> complexReturningImpls =
source.readMembers<FunctionEntity>();
source.end(tag);
- return NoSuchMethodDataImpl(
- throwingImpls, otherImpls, forwardingSyntaxImpls)
- ..complexNoReturnImpls.addAll(complexNoReturnImpls)
- ..complexReturningImpls.addAll(complexReturningImpls);
+ return NoSuchMethodData(throwingImpls, otherImpls, forwardingSyntaxImpls)
+ .._complexNoReturnImpls.addAll(complexNoReturnImpls)
+ .._complexReturningImpls.addAll(complexReturningImpls);
}
- @override
+ /// Serializes this [NoSuchMethodData] to [sink].
void writeToDataSink(DataSink sink) {
sink.begin(tag);
- sink.writeMembers(throwingImpls);
- sink.writeMembers(otherImpls);
- sink.writeMembers(forwardingSyntaxImpls);
- sink.writeMembers(complexNoReturnImpls);
- sink.writeMembers(complexReturningImpls);
+ sink.writeMembers(_throwingImpls);
+ sink.writeMembers(_otherImpls);
+ sink.writeMembers(_forwardingSyntaxImpls);
+ sink.writeMembers(_complexNoReturnImpls);
+ sink.writeMembers(_complexReturningImpls);
sink.end(tag);
}
- @override
+ Iterable<FunctionEntity> get throwingImpls => _throwingImpls;
+
+ Iterable<FunctionEntity> get otherImpls => _otherImpls;
+
+ Iterable<FunctionEntity> get forwardingSyntaxImpls => _forwardingSyntaxImpls;
+
+ Iterable<FunctionEntity> get complexNoReturnImpls => _complexNoReturnImpls;
+
+ Iterable<FunctionEntity> get complexReturningImpls => _complexReturningImpls;
+
+ /// Now that type inference is complete, split category D into two
+ /// subcategories: D1, those that have no return type, and D2, those
+ /// that have a return type.
void categorizeComplexImplementations(GlobalTypeInferenceResults results) {
- otherImpls.forEach((FunctionEntity element) {
+ _otherImpls.forEach((FunctionEntity element) {
if (results.resultOfMember(element).throwsAlways) {
- complexNoReturnImpls.add(element);
+ _complexNoReturnImpls.add(element);
} else {
- complexReturningImpls.add(element);
+ _complexReturningImpls.add(element);
}
});
}
- @override
+ /// Emits a diagnostic about methods in categories `B`, `D1` and `D2`.
void emitDiagnostic(DiagnosticReporter reporter) {
- throwingImpls.forEach((e) {
- if (!forwardingSyntaxImpls.contains(e)) {
+ _throwingImpls.forEach((e) {
+ if (!_forwardingSyntaxImpls.contains(e)) {
reporter.reportHintMessage(e, MessageKind.DIRECTLY_THROWING_NSM);
}
});
- complexNoReturnImpls.forEach((e) {
- if (!forwardingSyntaxImpls.contains(e)) {
+ _complexNoReturnImpls.forEach((e) {
+ if (!_forwardingSyntaxImpls.contains(e)) {
reporter.reportHintMessage(e, MessageKind.COMPLEX_THROWING_NSM);
}
});
- complexReturningImpls.forEach((e) {
- if (!forwardingSyntaxImpls.contains(e)) {
+ _complexReturningImpls.forEach((e) {
+ if (!_forwardingSyntaxImpls.contains(e)) {
reporter.reportHintMessage(e, MessageKind.COMPLEX_RETURNING_NSM);
}
});
}
- @override
+ /// Returns [true] if the given element is a complex [noSuchMethod]
+ /// implementation. An implementation is complex if it falls into
+ /// category D, as described above.
bool isComplex(FunctionEntity element) {
assert(element.name == Identifiers.noSuchMethod_);
- return otherImpls.contains(element);
+ return _otherImpls.contains(element);
}
}
@@ -293,21 +276,3 @@
NOT_APPLICABLE,
OTHER,
}
-
-/// Interface for determining the form of a `noSuchMethod` implementation.
-abstract class NoSuchMethodResolver {
- /// Computes whether [method] is of the form
- ///
- /// noSuchMethod(i) => super.noSuchMethod(i);
- ///
- bool hasForwardingSyntax(covariant FunctionEntity method);
-
- /// Computes whether [method] is of the form
- ///
- /// noSuchMethod(i) => throw new Error();
- ///
- bool hasThrowingSyntax(covariant FunctionEntity method);
-
- /// Returns the `noSuchMethod` that [method] overrides.
- FunctionEntity getSuperNoSuchMethod(covariant FunctionEntity method);
-}
diff --git a/pkg/compiler/lib/src/js_backend/resolution_listener.dart b/pkg/compiler/lib/src/js_backend/resolution_listener.dart
index 5e63dbe..36f9598 100644
--- a/pkg/compiler/lib/src/js_backend/resolution_listener.dart
+++ b/pkg/compiler/lib/src/js_backend/resolution_listener.dart
@@ -45,9 +45,6 @@
final NativeResolutionEnqueuer _nativeEnqueuer;
final KFieldAnalysis _fieldAnalysis;
- /// True when we enqueue the loadLibrary code.
- bool _isLoadLibraryFunctionResolved = false;
-
ResolutionEnqueuerListener(
this._options,
this._elementEnvironment,
@@ -296,14 +293,6 @@
_registerBackendImpact(worldImpact, _impacts.noSuchMethodSupport);
}
- if (_elementEnvironment.isDeferredLoadLibraryGetter(member)) {
- // TODO(sigurdm): Create a function registerLoadLibraryAccess.
- if (!_isLoadLibraryFunctionResolved) {
- _isLoadLibraryFunctionResolved = true;
- _registerBackendImpact(worldImpact, _impacts.loadLibrary);
- }
- }
-
if (member.isGetter && member.name == Identifiers.runtimeType_) {
// Enable runtime type support if we discover a getter called
// runtimeType. We have to enable runtime type before hitting the
diff --git a/pkg/compiler/lib/src/js_model/js_world_builder.dart b/pkg/compiler/lib/src/js_model/js_world_builder.dart
index a6f2b04..6815146 100644
--- a/pkg/compiler/lib/src/js_model/js_world_builder.dart
+++ b/pkg/compiler/lib/src/js_model/js_world_builder.dart
@@ -187,8 +187,8 @@
BackendUsage backendUsage =
_convertBackendUsage(map, closedWorld.backendUsage);
- NoSuchMethodDataImpl oldNoSuchMethodData = closedWorld.noSuchMethodData;
- NoSuchMethodData noSuchMethodData = NoSuchMethodDataImpl(
+ NoSuchMethodData oldNoSuchMethodData = closedWorld.noSuchMethodData;
+ NoSuchMethodData noSuchMethodData = NoSuchMethodData(
map.toBackendFunctionSet(oldNoSuchMethodData.throwingImpls),
map.toBackendFunctionSet(oldNoSuchMethodData.otherImpls),
map.toBackendFunctionSet(oldNoSuchMethodData.forwardingSyntaxImpls));
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index 7bd67d0..99cc1e2 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.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.
-library dart2js.kernel.element_map;
-
import 'package:front_end/src/api_prototype/constant_evaluator.dart' as ir;
import 'package:front_end/src/api_unstable/dart2js.dart' as ir;
import 'package:js_runtime/shared/embedded_names.dart';
@@ -40,7 +38,6 @@
import '../js_backend/annotations.dart';
import '../js_backend/namer.dart';
import '../js_backend/native_data.dart';
-import '../js_backend/no_such_method_registry.dart';
import '../js_model/locals.dart';
import '../kernel/dart2js_target.dart';
import '../native/behavior.dart';
@@ -56,8 +53,6 @@
import 'kelements.dart';
import 'kernel_impact.dart';
-part 'no_such_method_resolver.dart';
-
/// Implementation of [KernelToElementMap] that only supports world
/// impact computation.
class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
@@ -1450,7 +1445,7 @@
}
/// Returns the kernel [ir.Procedure] node for the [method].
- ir.Procedure _lookupProcedure(KFunction method) {
+ ir.Procedure lookupProcedure(KFunction method) {
return members.getData(method).node;
}
@@ -1867,13 +1862,6 @@
}
@override
- bool isDeferredLoadLibraryGetter(MemberEntity member) {
- // The front-end generates the getter of loadLibrary explicitly as code
- // so there is no implicit representation based on a "loadLibrary" member.
- return false;
- }
-
- @override
Iterable<ImportEntity> getImports(covariant IndexedLibrary library) {
assert(elementMap.checkFamily(library));
KLibraryData libraryData = elementMap.libraries.getData(library);
diff --git a/pkg/compiler/lib/src/kernel/kernel_strategy.dart b/pkg/compiler/lib/src/kernel/kernel_strategy.dart
index bf63a26..8cebfcb 100644
--- a/pkg/compiler/lib/src/kernel/kernel_strategy.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_strategy.dart
@@ -36,6 +36,7 @@
import '../js_backend/resolution_listener.dart';
import '../js_backend/runtime_types_resolution.dart';
import '../kernel/dart2js_target.dart';
+import '../kernel/no_such_method_resolver.dart';
import '../native/enqueue.dart' show NativeResolutionEnqueuer;
import '../native/resolver.dart';
import '../options.dart';
@@ -89,8 +90,8 @@
_elementMap = KernelToElementMapImpl(reporter, environment, this, _options);
_modularStrategy = KernelModularStrategy(_compilerTask, _elementMap);
_backendUsageBuilder = BackendUsageBuilderImpl(this);
- noSuchMethodRegistry = NoSuchMethodRegistryImpl(
- commonElements, KernelNoSuchMethodResolver(_elementMap));
+ noSuchMethodRegistry =
+ NoSuchMethodRegistry(commonElements, NoSuchMethodResolver(_elementMap));
}
NativeResolutionEnqueuer get nativeResolutionEnqueuerForTesting =>
diff --git a/pkg/compiler/lib/src/kernel/no_such_method_resolver.dart b/pkg/compiler/lib/src/kernel/no_such_method_resolver.dart
index 606ea21..2da943b 100644
--- a/pkg/compiler/lib/src/kernel/no_such_method_resolver.dart
+++ b/pkg/compiler/lib/src/kernel/no_such_method_resolver.dart
@@ -2,19 +2,29 @@
// 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.
-part of dart2js.kernel.element_map;
+import 'package:kernel/ast.dart' as ir;
+
+import '../common/elements.dart';
+import '../common/names.dart';
+import '../elements/entities.dart';
+
+import 'element_map_impl.dart';
+import 'kelements.dart';
/// Interface for determining the form of a `noSuchMethod` implementation.
-class KernelNoSuchMethodResolver implements NoSuchMethodResolver {
+class NoSuchMethodResolver {
final KernelToElementMapImpl elementMap;
- KernelNoSuchMethodResolver(this.elementMap);
+ NoSuchMethodResolver(this.elementMap);
CommonElements get _commonElements => elementMap.commonElements;
- @override
+ /// Computes whether [method] is of the form
+ ///
+ /// noSuchMethod(i) => super.noSuchMethod(i);
+ ///
bool hasForwardingSyntax(KFunction method) {
- ir.Procedure node = elementMap._lookupProcedure(method);
+ ir.Procedure node = elementMap.lookupProcedure(method);
if (node.function.positionalParameters.isEmpty) return false;
ir.VariableDeclaration firstParameter =
node.function.positionalParameters.first;
@@ -45,9 +55,12 @@
return false;
}
- @override
+ /// Computes whether [method] is of the form
+ ///
+ /// noSuchMethod(i) => throw new Error();
+ ///
bool hasThrowingSyntax(KFunction method) {
- ir.Procedure node = elementMap._lookupProcedure(method);
+ ir.Procedure node = elementMap.lookupProcedure(method);
ir.Statement body = node.function.body;
if (body is ir.Block && body.statements.isNotEmpty) {
ir.Block block = body;
@@ -62,7 +75,7 @@
return expr is ir.Throw;
}
- @override
+ /// Returns the `noSuchMethod` that [method] overrides.
FunctionEntity getSuperNoSuchMethod(FunctionEntity method) {
return elementMap.getSuperNoSuchMethod(method.enclosingClass);
}
diff --git a/pkg/compiler/test/model/no_such_method_enabled_test.dart b/pkg/compiler/test/model/no_such_method_enabled_test.dart
index ce01c8c..1a24bd8 100644
--- a/pkg/compiler/test/model/no_such_method_enabled_test.dart
+++ b/pkg/compiler/test/model/no_such_method_enabled_test.dart
@@ -257,14 +257,14 @@
checkTest(Compiler compiler, NoSuchMethodTest test) {
ElementEnvironment frontendEnvironment =
compiler.frontendStrategy.elementEnvironment;
- NoSuchMethodRegistryImpl registry =
+ NoSuchMethodRegistry registry =
compiler.frontendStrategy.noSuchMethodRegistry;
- NoSuchMethodResolver resolver = registry.internalResolverForTesting;
+ var resolver = registry.internalResolverForTesting;
FunctionEntity ObjectNSM = frontendEnvironment.lookupClassMember(
compiler.frontendStrategy.commonElements.objectClass, 'noSuchMethod');
JClosedWorld backendClosedWorld = compiler.backendClosedWorldForTesting;
ElementEnvironment backendEnvironment = backendClosedWorld.elementEnvironment;
- NoSuchMethodDataImpl data = backendClosedWorld.noSuchMethodData;
+ NoSuchMethodData data = backendClosedWorld.noSuchMethodData;
// Test [NoSuchMethodResolver] results for each method.
for (NoSuchMethodInfo info in test.methods) {
diff --git a/pkg/dev_compiler/lib/src/compiler/shared_command.dart b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
index 77fc615..f70d35b 100644
--- a/pkg/dev_compiler/lib/src/compiler/shared_command.dart
+++ b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
@@ -238,9 +238,6 @@
// that build systems do not depend on passing windows-style paths here.
return p.toUri(moduleName).toString();
}
-
- // TODO(nshahan) Cleanup when NNBD graduates experimental status.
- bool get enableNullSafety => experiments['non-nullable'] ?? false;
}
/// Finds explicit module names of the form `path=name` in [summaryPaths],
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index e0a610a..605c339 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -276,7 +276,7 @@
additionalDills,
DevCompilerTarget(TargetFlags(
trackWidgetCreation: trackWidgetCreation,
- enableNullSafety: options.enableNullSafety)),
+ enableNullSafety: options.soundNullSafety)),
fileSystem: fileSystem,
explicitExperimentalFlags: explicitExperimentalFlags,
environmentDefines: declaredVariables,
@@ -315,7 +315,7 @@
inputDigests,
DevCompilerTarget(TargetFlags(
trackWidgetCreation: trackWidgetCreation,
- enableNullSafety: options.enableNullSafety)),
+ enableNullSafety: options.soundNullSafety)),
fileSystem: fileSystem,
explicitExperimentalFlags: explicitExperimentalFlags,
environmentDefines: declaredVariables,
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 3255b97..3919691 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -3013,14 +3013,7 @@
// * `class A extends B {...}` where B is the InterfaceType.
// * Emitting non-null constructor calls.
// * The InterfaceType is the Null type.
- // * The types were written in JS context or as part of the dart:_runtime
- // library.
- if (!emitNullability ||
- type == _coreTypes.deprecatedNullType ||
- // TODO(38701) Remove these once the SDK has unforked and is running
- // "opted-in"
- !coreLibrary.isNonNullableByDefault &&
- (_isInForeignJS || isSdkInternalRuntime(currentLibrary))) {
+ if (!emitNullability || type == _coreTypes.deprecatedNullType) {
return typeRep;
}
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index 3e199239..41d58e8 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -508,6 +508,7 @@
Utf8ToWideScope system_path(prefixed_dir);
ExistsResult exists = ExistsHelper(system_path.wide());
if (exists != EXISTS) {
+ SetLastError(ERROR_FILE_NOT_FOUND);
return false;
}
const char* prefixed_new_dir = PrefixLongDirectoryPath(new_path);
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 867dd32..8e6a103 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -39,7 +39,6 @@
# ......dartanalyzer
# ......dartdevc
# ......utils/gen_snapshot or utils/gen_snapshot.exe (if not on ia32)
-# ......pub
# ......snapshots/
# ........analysis_server.dart.snapshot
# ........dart2js.dart.snapshot
@@ -88,16 +87,12 @@
# ......api_readme.md
# Scripts that go under bin/
-_platform_sdk_scripts = [
- "dartanalyzer",
- "pub",
-]
+_platform_sdk_scripts = [ "dartanalyzer" ]
_full_sdk_scripts = [
"dart2js",
"dartanalyzer",
"dartdevc",
- "pub",
]
# Snapshots that go under bin/snapshots
diff --git a/sdk/bin/pub.bat b/sdk/bin/pub.bat
deleted file mode 100644
index 7eb8b0d..0000000
--- a/sdk/bin/pub.bat
+++ /dev/null
@@ -1,56 +0,0 @@
-@echo off
-REM Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-REM for details. All rights reserved. Use of this source code is governed by a
-REM BSD-style license that can be found in the LICENSE file.
-
-rem Run pub.dart on the Dart VM. This script is only used when running pub from
-rem within the Dart source repo. The shipped SDK instead uses "pub_sdk.bat",
-rem which is renamed to "pub.bat" when the SDK is built.
-
-setlocal
-rem Handle the case where dart-sdk/bin has been symlinked to.
-set DIR_NAME_WITH_SLASH=%~dp0
-set DIR_NAME=%DIR_NAME_WITH_SLASH:~0,-1%%
-call :follow_links "%DIR_NAME%", RETURNED_BIN_DIR
-rem Get rid of surrounding quotes.
-for %%i in ("%RETURNED_BIN_DIR%") do set BIN_DIR=%%~fi
-
-rem Get absolute full name for SDK_DIR.
-for %%i in ("%BIN_DIR%\..\") do set SDK_DIR=%%~fi
-
-rem Remove trailing backslash if there is one
-IF %SDK_DIR:~-1%==\ set SDK_DIR=%SDK_DIR:~0,-1%
-
-set VM_OPTIONS=
-
-rem We allow extra vm options to be passed in through an environment variable.
-if not "_%DART_VM_OPTIONS%_" == "__" (
- set VM_OPTIONS=%VM_OPTIONS% %DART_VM_OPTIONS%
-)
-
-rem Use the Dart binary in the built SDK so pub can find the version file next
-rem to it.
-set BUILD_DIR=%SDK_DIR%\..\out\ReleaseX64
-set DART=%BUILD_DIR%\dart-sdk\bin\dart
-
-rem Run pub.
-set PUB="%SDK_DIR%\..\third_party\pkg\pub\bin\pub.dart"
-"%DART%" "--packages=%SDK_DIR%\..\.packages" %VM_OPTIONS% "%PUB%" %*
-
-endlocal
-
-exit /b %errorlevel%
-
-:follow_links
-setlocal
-for %%i in (%1) do set result=%%~fi
-set current=
-for /f "usebackq tokens=2 delims=[]" %%i in (`dir /a:l "%~dp1" 2^>nul ^
- ^| %SystemRoot%\System32\find.exe "> %~n1 [" 2^>nul`) do (
- set current=%%i
-)
-if not "%current%"=="" call :follow_links "%current%", result
-endlocal & set %~2=%result%
-goto :eof
-
-:end
diff --git a/sdk/bin/pub_sdk b/sdk/bin/pub_sdk
deleted file mode 100755
index 17ce14c..0000000
--- a/sdk/bin/pub_sdk
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env bash
-# Copyright (c) 2014, 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.
-
-# Run pub.dart on the Dart VM. This script assumes the Dart SDK's directory
-# structure.
-
-function follow_links() {
- file="$1"
- while [ -h "$file" ]; do
- # On Mac OS, readlink -f doesn't work.
- file="$(readlink "$file")"
- done
- echo "$file"
-}
-
-function array_contains() {
- local needle="$1"
- local element
- shift
- for element; do [ "$element" = "$needle" ] && return 0; done
- return 1
-}
-
-# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
-PROG_NAME="$(follow_links "$BASH_SOURCE")"
-
-# Handle the case where dart-sdk/bin has been symlinked to.
-BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
-DART="$BIN_DIR/dart"
-
-unset VM_OPTIONS
-declare -a VM_OPTIONS
-
-# Allow extra VM options to be passed in through an environment variable.
-if [[ $DART_VM_OPTIONS ]]; then
- read -a OPTIONS <<< "$DART_VM_OPTIONS"
- VM_OPTIONS+=("${OPTIONS[@]}")
-fi
-
-if [ -t 2 ]; then # Only print warning when run in terminal.
- >&2 echo 'The top level `pub` command is deprecated. Use `dart pub` instead.'
-fi
-
-# Forward to the `dart __deprecatedpub` command.
-exec "$DART" "${VM_OPTIONS[@]}" __deprecated_pub "$@"
diff --git a/sdk/bin/pub_sdk.bat b/sdk/bin/pub_sdk.bat
deleted file mode 100644
index e882aac..0000000
--- a/sdk/bin/pub_sdk.bat
+++ /dev/null
@@ -1,50 +0,0 @@
-@echo off
-REM Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-REM for details. All rights reserved. Use of this source code is governed by a
-REM BSD-style license that can be found in the LICENSE file.
-
-setlocal
-rem Handle the case where dart-sdk/bin has been symlinked to.
-set DIR_NAME_WITH_SLASH=%~dp0
-set DIR_NAME=%DIR_NAME_WITH_SLASH:~0,-1%%
-call :follow_links "%DIR_NAME%", RETURNED_BIN_DIR
-rem Get rid of surrounding quotes.
-for %%i in ("%RETURNED_BIN_DIR%") do set BIN_DIR=%%~fi
-
-rem Get absolute full name for SDK_DIR.
-for %%i in ("%BIN_DIR%\..\") do set SDK_DIR=%%~fi
-
-rem Remove trailing backslash if there is one
-IF %SDK_DIR:~-1%==\ set SDK_DIR=%SDK_DIR:~0,-1%
-
-set VM_OPTIONS=
-set USING_DART_1=
-
-rem We allow extra vm options to be passed in through an environment variable.
-if not "_%DART_VM_OPTIONS%_" == "__" (
- set VM_OPTIONS=%VM_OPTIONS% %DART_VM_OPTIONS%
- for %%o in (%DART_VM_OPTIONS%) do (
- if "%%o" equ "--no-preview-dart-2" set USING_DART_1=y
- )
-)
-
-echo "The top level `pub.bat` command is deprecated. Use `dart pub` instead." 1>&2
-"%BIN_DIR%\dart" %VM_OPTIONS% __deprecated_pub %*
-
-endlocal
-
-exit /b %errorlevel%
-
-:follow_links
-setlocal
-for %%i in (%1) do set result=%%~fi
-set current=
-for /f "usebackq tokens=2 delims=[]" %%i in (`dir /a:l "%~dp1" 2^>nul ^
- ^| %SystemRoot%\System32\find.exe "> %~n1 [" 2^>nul`) do (
- set current=%%i
-)
-if not "%current%"=="" call :follow_links "%current%", result
-endlocal & set %~2=%result%
-goto :eof
-
-:end
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index d41e511..f0ecaa5 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -397,7 +397,7 @@
/// In minified mode, uses the unminified names if available, otherwise tags
/// them with 'minified:'.
@pragma('dart2js:noInline')
- static String objectTypeName(Object object) {
+ static String objectTypeName(Object? object) {
return _objectTypeNameNewRti(object);
}
@@ -406,7 +406,7 @@
///
/// In minified mode, uses the unminified names if available, otherwise tags
/// them with 'minified:'.
- static String _objectTypeNameNewRti(Object object) {
+ static String _objectTypeNameNewRti(Object? object) {
var dartObjectConstructor = JS_BUILTIN(
'depends:none;effects:none;', JsBuiltin.dartObjectConstructor);
if (JS('bool', '# instanceof #', object, dartObjectConstructor)) {
@@ -452,7 +452,7 @@
name != null && name != 'Object' && name != '';
/// In minified mode, uses the unminified names if available.
- static String objectToHumanReadableString(Object object) {
+ static String objectToHumanReadableString(Object? object) {
String name = objectTypeName(object);
return "Instance of '$name'";
}
@@ -2666,12 +2666,6 @@
return JS('String', '#(#)', isolateTagGetter, name);
}
-typedef Future<Null> LoadLibraryFunctionType();
-
-LoadLibraryFunctionType _loadLibraryWrapper(String loadId) {
- return () => loadDeferredLibrary(loadId);
-}
-
final Map<String, Future<Null>?> _loadingLibraries = <String, Future<Null>?>{};
final Set<String> _loadedLibraries = new Set<String>();
diff --git a/tests/standalone/io/directory_rename_test.dart b/tests/standalone/io/directory_rename_test.dart
index de14cea..277b5ba 100644
--- a/tests/standalone/io/directory_rename_test.dart
+++ b/tests/standalone/io/directory_rename_test.dart
@@ -141,7 +141,10 @@
} on FileSystemException catch (e) {
Expect.isTrue(
e.message.contains('Rename failed'), 'Unexpected error: $e');
- if (Platform.isLinux || Platform.isMacOS) {
+ if (Platform.isWindows) {
+ Expect.isTrue(e.osError!.message.contains('cannot find the file'),
+ 'Unexpected error: $e');
+ } else if (Platform.isLinux || Platform.isMacOS) {
Expect.isTrue(e.osError!.message.contains('Not a directory'),
'Unexpected error: $e');
}
diff --git a/tests/standalone_2/io/directory_rename_test.dart b/tests/standalone_2/io/directory_rename_test.dart
index 5f47913..18cbba3 100644
--- a/tests/standalone_2/io/directory_rename_test.dart
+++ b/tests/standalone_2/io/directory_rename_test.dart
@@ -143,7 +143,10 @@
} on FileSystemException catch (e) {
Expect.isTrue(
e.message.contains('Rename failed'), 'Unexpected error: $e');
- if (Platform.isLinux || Platform.isMacOS) {
+ if (Platform.isWindows) {
+ Expect.isTrue(e.osError.message.contains('cannot find the file'),
+ 'Unexpected error: $e');
+ } else if (Platform.isLinux || Platform.isMacOS) {
Expect.isTrue(e.osError.message.contains('Not a directory'),
'Unexpected error: $e');
}
diff --git a/tools/VERSION b/tools/VERSION
index ee720e4..19b9b02 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 87
+PRERELEASE 88
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/pub_integration_test.py b/tools/bots/pub_integration_test.py
index f80c554..4f35ae6 100755
--- a/tools/bots/pub_integration_test.py
+++ b/tools/bots/pub_integration_test.py
@@ -35,10 +35,10 @@
mode = ('Debug' if options.mode == 'debug' else 'Release')
out_dir = 'xcodebuild' if sys.platform == 'darwin' else 'out'
- extension = '' if not sys.platform == 'win32' else '.bat'
- pub = os.path.abspath('%s/%s%s/dart-sdk/bin/pub%s' %
- (out_dir, mode, arch, extension))
- print(pub)
+ extension = '' if not sys.platform == 'win32' else '.exe'
+ dart = os.path.abspath('%s/%s%s/dart-sdk/bin/dart%s' %
+ (out_dir, mode, arch, extension))
+ print(dart)
working_dir = tempfile.mkdtemp()
try:
@@ -49,11 +49,15 @@
with open(working_dir + '/pubspec.yaml', 'w') as pubspec_yaml:
pubspec_yaml.write(PUBSPEC)
- exit_code = subprocess.call([pub, 'get'], cwd=working_dir, env=env)
+ exit_code = subprocess.call([dart, 'pub', 'get'],
+ cwd=working_dir,
+ env=env)
if exit_code != 0:
return exit_code
- exit_code = subprocess.call([pub, 'upgrade'], cwd=working_dir, env=env)
+ exit_code = subprocess.call([dart, 'pub', 'upgrade'],
+ cwd=working_dir,
+ env=env)
if exit_code != 0:
return exit_code
finally:
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index f1dcf06..37803b4 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -235,22 +235,7 @@
],
"fuzzer": [
"runtime/tools/dartfuzz/",
- "out/DebugIA32/",
- "out/DebugSIMARM/",
- "out/DebugSIMARM64/",
- "out/DebugSIMARM64C/",
- "out/DebugSIMRISCV32/",
- "out/DebugSIMRISCV64/",
- "out/DebugX64/",
- "out/DebugX64C/",
- "out/ReleaseIA32/",
- "out/ReleaseSIMARM/",
- "out/ReleaseSIMARM64/",
- "out/ReleaseSIMARM64C/",
- "out/ReleaseSIMRISCV32/",
- "out/ReleaseSIMRISCV64/",
- "out/ReleaseX64/",
- "out/ReleaseX64C/",
+ "out/",
"third_party/pkg/",
"third_party/pkg_tested/",
"tools/sdks/dart-sdk/",
@@ -271,70 +256,8 @@
],
"vm-kernel": [
"benchmarks/",
- "out/DebugIA32/",
- "out/DebugX64/",
- "out/DebugX64C/",
- "out/DebugSIMARM/",
- "out/DebugSIMARM64/",
- "out/DebugSIMARM64C/",
- "out/DebugSIMARM_X64/",
- "out/DebugSIMRISCV32/",
- "out/DebugSIMRISCV64/",
- "out/DebugAndroidARM/",
- "out/DebugAndroidARM_X64/",
- "out/DebugAndroidARM64/",
- "out/DebugAndroidARM64C/",
- "out/ReleaseIA32/",
- "out/ReleaseX64/",
- "out/ReleaseX64C/",
- "out/ReleaseSIMARM/",
- "out/ReleaseSIMARM64/",
- "out/ReleaseSIMARM64C/",
- "out/ReleaseSIMARM_X64/",
- "out/ReleaseSIMRISCV32/",
- "out/ReleaseSIMRISCV64/",
- "out/ReleaseAndroidARM/",
- "out/ReleaseAndroidARM_X64/",
- "out/ReleaseAndroidARM64/",
- "out/ReleaseAndroidARM64C/",
- "out/ReleaseASANX64/",
- "out/ReleaseLSANX64/",
- "out/ReleaseMSANX64/",
- "out/ReleaseTSANX64/",
- "out/ReleaseUBSANX64/",
- "out/ReleaseXARM64/",
- "out/ProductIA32/",
- "out/ProductX64/",
- "out/ProductX64C/",
- "out/ProductSIMARM/",
- "out/ProductSIMARM64/",
- "out/ProductSIMARM64C/",
- "out/ProductSIMARM_X64/",
- "out/ProductSIMRISCV32/",
- "out/ProductSIMRISCV64/",
- "out/ProductAndroidARM/",
- "out/ProductAndroidARM64/",
- "out/ProductAndroidARM64C/",
- "xcodebuild/DebugIA32/",
- "xcodebuild/DebugSIMARM/",
- "xcodebuild/DebugSIMARM64/",
- "xcodebuild/DebugSIMARM64C/",
- "xcodebuild/DebugX64/",
- "xcodebuild/DebugX64C/",
- "xcodebuild/DebugXARM64/",
- "xcodebuild/DebugARM64/",
- "xcodebuild/ProductX64/",
- "xcodebuild/ProductX64C/",
- "xcodebuild/ProductXARM64/",
- "xcodebuild/ProductARM64/",
- "xcodebuild/ReleaseIA32/",
- "xcodebuild/ReleaseSIMARM/",
- "xcodebuild/ReleaseSIMARM64/",
- "xcodebuild/ReleaseSIMARM64C/",
- "xcodebuild/ReleaseX64/",
- "xcodebuild/ReleaseX64C/",
- "xcodebuild/ReleaseXARM64/",
- "xcodebuild/ReleaseARM64/",
+ "out/",
+ "xcodebuild/",
"pkg/",
"samples/",
"samples_2/",
diff --git a/tools/linux_dist_support/linux_distribution_support.py b/tools/linux_dist_support/linux_distribution_support.py
index 35b7b07..cb739d4 100644
--- a/tools/linux_dist_support/linux_distribution_support.py
+++ b/tools/linux_dist_support/linux_distribution_support.py
@@ -123,9 +123,6 @@
Run(['/usr/lib/dart/bin/dart', 'analyze', test_file])
Run(['/usr/lib/dart/bin/dart', test_file])
- # Sanity check that pub can start up and print the version
- Run(['/usr/lib/dart/bin/pub', '--version'])
-
UninstallDart()
TestInstallation(assume_installed=False)