Version 2.10.0-10.0.dev
Merge commit 'e224540b1c9793025edca4ecc2a4ef2275b3f10c' into 'dev'
diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index 706d694..58a930c 100644
--- a/.dart_tool/package_config.json
+++ b/.dart_tool/package_config.json
@@ -172,7 +172,7 @@
"name": "crypto",
"rootUri": "../third_party/pkg/crypto",
"packageUri": "lib/",
- "languageVersion": "2.3"
+ "languageVersion": "2.10"
},
{
"name": "csslib",
diff --git a/DEPS b/DEPS
index 54f5bb7..f9e1d9a 100644
--- a/DEPS
+++ b/DEPS
@@ -78,7 +78,7 @@
"cli_util_tag" : "0.2.0",
"collection_rev": "583693680fc067e34ca5b72503df25e8b80579f9",
"convert_rev": "c1b01f832835d3d8a06b0b246a361c0eaab35d3c",
- "crypto_rev": "7422fb2f6584fe1839eb30bc4ca56e9f9760b801",
+ "crypto_rev": "f7c48b334b1386bc5ab0f706fbcd6df8496a87fc",
"csslib_rev": "451448a9ac03f87a8d0377fc0b411d8c388a6cb4",
"dart2js_info_tag" : "0.6.0",
diff --git a/README.md b/README.md
index 4b4ee5b..924e4c3 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@
## Using Dart
-Visit the [dart.dev][website] to learn more about the
+Visit [dart.dev][website] to learn more about the
[language][lang], [tools][tools],
[getting started][codelab], and more.
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
index 7ee3d3f..e2285a0 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
@@ -89,6 +89,7 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageAbstractLateField = const MessageCode(
"AbstractLateField",
+ index: 108,
message: r"""Abstract fields cannot be late.""",
tip: r"""Try removing the 'abstract' or 'late' keyword.""");
@@ -134,6 +135,7 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageAbstractStaticField = const MessageCode(
"AbstractStaticField",
+ index: 107,
message: r"""Static fields can't be declared 'abstract'.""",
tip: r"""Try removing the 'abstract' or 'static' keyword.""");
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
index 3d4a474..e69016d 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
@@ -476,6 +476,8 @@
void visitFieldDeclaration(FieldDeclaration node) {
computer._addRegion_token(
node.abstractKeyword, HighlightRegionType.BUILT_IN);
+ computer._addRegion_token(
+ node.externalKeyword, HighlightRegionType.BUILT_IN);
computer._addRegion_token(node.staticKeyword, HighlightRegionType.BUILT_IN);
super.visitFieldDeclaration(node);
}
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights2.dart b/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
index ada8fc5..6b72a3e 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
@@ -567,6 +567,8 @@
void visitFieldDeclaration(FieldDeclaration node) {
computer._addRegion_token(
node.abstractKeyword, HighlightRegionType.BUILT_IN);
+ computer._addRegion_token(
+ node.externalKeyword, HighlightRegionType.BUILT_IN);
computer._addRegion_token(node.staticKeyword, HighlightRegionType.BUILT_IN);
super.visitFieldDeclaration(node);
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
index 0e66786..e71a230 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
@@ -312,6 +312,9 @@
if (node.covariantKeyword == null) {
_addSuggestion(Keyword.COVARIANT);
}
+ if (node.externalKeyword == null) {
+ _addSuggestion(Keyword.EXTERNAL);
+ }
if (node.fields.lateKeyword == null &&
request.featureSet.isEnabled(Feature.non_nullable)) {
_addSuggestion(Keyword.LATE);
diff --git a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
index b651d8a..9f3adc4 100644
--- a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
@@ -389,6 +389,7 @@
Keyword.ABSTRACT,
Keyword.CONST,
Keyword.COVARIANT,
+ Keyword.EXTERNAL,
Keyword.FINAL
];
if (isEnabled(ExperimentalFeatures.non_nullable)) {
diff --git a/pkg/analysis_server/tool/completion_metrics/code_metrics.dart b/pkg/analysis_server/tool/completion_metrics/code_metrics.dart
index d0baded..ec01128 100644
--- a/pkg/analysis_server/tool/completion_metrics/code_metrics.dart
+++ b/pkg/analysis_server/tool/completion_metrics/code_metrics.dart
@@ -565,6 +565,7 @@
'metadata': node.metadata,
'abstractKeyword': node.abstractKeyword,
'covariantKeyword': node.covariantKeyword,
+ 'externalKeyword': node.externalKeyword,
'staticKeyword': node.staticKeyword,
'fields': node.fields,
});
diff --git a/pkg/analysis_server/tool/completion_metrics/visitors.dart b/pkg/analysis_server/tool/completion_metrics/visitors.dart
index cc8d5ff..eab5c66 100644
--- a/pkg/analysis_server/tool/completion_metrics/visitors.dart
+++ b/pkg/analysis_server/tool/completion_metrics/visitors.dart
@@ -349,6 +349,7 @@
void visitFieldDeclaration(FieldDeclaration node) {
safelyRecordKeywordCompletion(node.abstractKeyword);
safelyRecordKeywordCompletion(node.covariantKeyword);
+ safelyRecordKeywordCompletion(node.externalKeyword);
safelyRecordKeywordCompletion(node.staticKeyword);
return super.visitFieldDeclaration(node);
}
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index 0ecf87a..a566079 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -2138,6 +2138,8 @@
/// | 'covariant' 'late'? <varOrType> <initializedIdentifierList>
/// | 'late'? 'final' <type>? <initializedIdentifierList>
/// | 'late'? <varOrType> <initializedIdentifierList>
+/// | 'external' ('static'? <finalVarOrType> | 'covariant' <varOrType>)
+/// <identifierList>
/// | 'abstract' (<finalVarOrType> | 'covariant' <varOrType>)
/// <identifierList>
///
@@ -2160,6 +2162,9 @@
/// Set the token for the 'covariant' keyword to the given [token].
set covariantKeyword(Token token);
+ /// The `external` keyword, or `null` if the keyword was not used.
+ Token get externalKeyword;
+
/// Return the fields being declared.
VariableDeclarationList get fields;
diff --git a/pkg/analyzer/lib/dart/ast/ast_factory.dart b/pkg/analyzer/lib/dart/ast/ast_factory.dart
index 231ad4c..e58279d 100644
--- a/pkg/analyzer/lib/dart/ast/ast_factory.dart
+++ b/pkg/analyzer/lib/dart/ast/ast_factory.dart
@@ -365,6 +365,7 @@
List<Annotation> metadata,
Token abstractKeyword,
Token covariantKeyword,
+ Token externalKeyword,
Token staticKeyword,
@required VariableDeclarationList fieldList,
@required Token semicolon});
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 34e6cd6..efce469 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -1120,6 +1120,9 @@
/// Return `true` if this element is an enum constant.
bool get isEnumConstant;
+ /// Return `true` if this field was explicitly marked as being external.
+ bool get isExternal;
+
/// Return `true` if this element is a static element. A static element is an
/// element that is not associated with a particular instance, but rather with
/// an entire library or class.
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index cdcfeb7..6c61866 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -570,6 +570,8 @@
ManifestWarningCode.UNSUPPORTED_CHROME_OS_HARDWARE,
ParserErrorCode.ABSTRACT_CLASS_MEMBER,
ParserErrorCode.ABSTRACT_ENUM,
+ ParserErrorCode.ABSTRACT_LATE_FIELD,
+ ParserErrorCode.ABSTRACT_STATIC_FIELD,
ParserErrorCode.ABSTRACT_STATIC_METHOD,
ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION,
ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE,
diff --git a/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart b/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
index 6fea185..c971b074 100644
--- a/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
@@ -8,6 +8,7 @@
import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
+import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/context_builder.dart';
import 'package:cli_util/cli_util.dart';
import 'package:meta/meta.dart';
@@ -23,6 +24,7 @@
/// Initialize a newly created analysis context manager.
AnalysisContextCollectionImpl({
+ ByteStore byteStore,
Map<String, String> declaredVariables,
bool enableIndex = false,
@required List<String> includedPaths,
@@ -50,6 +52,7 @@
resourceProvider: this.resourceProvider,
);
var context = contextBuilder.createContext(
+ byteStore: byteStore,
contextRoot: root,
declaredVariables: DeclaredVariables.fromMap(declaredVariables ?? {}),
enableIndex: enableIndex,
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index beba8d7..f6634b6 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -12,7 +12,7 @@
show ContextBuilder, ContextBuilderOptions;
import 'package:analyzer/src/context/context_root.dart' as old;
import 'package:analyzer/src/dart/analysis/byte_store.dart'
- show MemoryByteStore;
+ show ByteStore, MemoryByteStore;
import 'package:analyzer/src/dart/analysis/driver.dart'
show AnalysisDriver, AnalysisDriverScheduler;
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
@@ -39,7 +39,8 @@
@override
AnalysisContext createContext(
- {@required ContextRoot contextRoot,
+ {ByteStore byteStore,
+ @required ContextRoot contextRoot,
DeclaredVariables declaredVariables,
bool enableIndex = false,
List<String> librarySummaryPaths,
@@ -51,7 +52,7 @@
sdkPath ??= getSdkPath();
ArgumentError.checkNotNull(sdkPath, 'sdkPath');
- var byteStore = MemoryByteStore();
+ byteStore ??= MemoryByteStore();
var fileContentOverlay = FileContentOverlay();
performanceLog ??= PerformanceLog(StringBuffer());
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index bfbf152..7307fca 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -3927,6 +3927,9 @@
@override
Token covariantKeyword;
+ @override
+ Token externalKeyword;
+
/// The token representing the 'static' keyword, or `null` if the fields are
/// not static.
@override
@@ -3948,6 +3951,7 @@
List<Annotation> metadata,
this.abstractKeyword,
this.covariantKeyword,
+ this.externalKeyword,
this.staticKeyword,
VariableDeclarationListImpl fieldList,
this.semicolon)
@@ -3977,6 +3981,8 @@
Token get firstTokenAfterCommentAndMetadata {
if (abstractKeyword != null) {
return abstractKeyword;
+ } else if (externalKeyword != null) {
+ return externalKeyword;
} else if (covariantKeyword != null) {
return covariantKeyword;
} else if (staticKeyword != null) {
diff --git a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
index ad2b6d8..aca1cb1 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
@@ -393,8 +393,8 @@
Token staticKeyword,
VariableDeclarationList fieldList,
Token semicolon) =>
- FieldDeclarationImpl(
- comment, metadata, null, null, staticKeyword, fieldList, semicolon);
+ FieldDeclarationImpl(comment, metadata, null, null, null, staticKeyword,
+ fieldList, semicolon);
@override
FieldDeclaration fieldDeclaration2(
@@ -402,11 +402,12 @@
List<Annotation> metadata,
Token abstractKeyword,
Token covariantKeyword,
+ Token externalKeyword,
Token staticKeyword,
@required VariableDeclarationList fieldList,
@required Token semicolon}) =>
FieldDeclarationImpl(comment, metadata, abstractKeyword, covariantKeyword,
- staticKeyword, fieldList, semicolon);
+ externalKeyword, staticKeyword, fieldList, semicolon);
@override
FieldFormalParameter fieldFormalParameter(
diff --git a/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart b/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
index eba0b8c..7261b61 100644
--- a/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
@@ -496,6 +496,7 @@
void visitFieldDeclaration(FieldDeclaration node) {
safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " ");
safelyVisitTokenWithSuffix(node.abstractKeyword, " ");
+ safelyVisitTokenWithSuffix(node.externalKeyword, " ");
safelyVisitTokenWithSuffix(node.staticKeyword, " ");
safelyVisitNode(node.fields);
sink.write(";");
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index 7d27356..e4f39b1 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -449,6 +449,7 @@
metadata: cloneNodeList(node.metadata),
abstractKeyword: cloneToken(node.abstractKeyword),
covariantKeyword: cloneToken(node.covariantKeyword),
+ externalKeyword: cloneToken(node.externalKeyword),
staticKeyword: cloneToken(node.staticKeyword),
fieldList: cloneNode(node.fields),
semicolon: cloneToken(node.semicolon));
@@ -1577,6 +1578,7 @@
return isEqualTokens(node.abstractKeyword, other.abstractKeyword) &&
isEqualTokens(node.covariantKeyword, other.covariantKeyword) &&
isEqualNodes(node.documentationComment, other.documentationComment) &&
+ isEqualTokens(node.externalKeyword, other.externalKeyword) &&
_isEqualNodeLists(node.metadata, other.metadata) &&
isEqualTokens(node.staticKeyword, other.staticKeyword) &&
isEqualNodes(node.fields, other.fields) &&
@@ -4466,6 +4468,7 @@
return _and(
_isEqualTokens(node.abstractKeyword, toNode.abstractKeyword),
_isEqualNodes(node.documentationComment, toNode.documentationComment),
+ _isEqualTokens(node.externalKeyword, toNode.externalKeyword),
_isEqualNodeLists(node.metadata, toNode.metadata),
_isEqualTokens(node.staticKeyword, toNode.staticKeyword),
_isEqualNodes(node.fields, toNode.fields),
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index a102215..0c7c239 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -4297,6 +4297,14 @@
!isSynthetic;
@override
+ bool get isExternal {
+ if (linkedNode != null) {
+ return enclosingUnit.linkedContext.isExternal(linkedNode);
+ }
+ return hasModifier(Modifier.EXTERNAL);
+ }
+
+ @override
bool get isStatic {
if (linkedNode != null) {
return enclosingUnit.linkedContext.isStatic(linkedNode);
diff --git a/pkg/analyzer/lib/src/dart/element/member.dart b/pkg/analyzer/lib/src/dart/element/member.dart
index 8385169..b62f341 100644
--- a/pkg/analyzer/lib/src/dart/element/member.dart
+++ b/pkg/analyzer/lib/src/dart/element/member.dart
@@ -343,6 +343,9 @@
bool get isEnumConstant => declaration.isEnumConstant;
@override
+ bool get isExternal => declaration.isExternal;
+
+ @override
PropertyAccessorElement get setter {
var baseSetter = declaration.setter;
if (baseSetter == null) {
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
index 8d03c94..d2b2e0e 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
@@ -29,6 +29,10 @@
'ABSTRACT_ENUM', "Enums can't be declared to be 'abstract'.",
correction: "Try removing the keyword 'abstract'.");
+ static const ParserErrorCode ABSTRACT_LATE_FIELD = _ABSTRACT_LATE_FIELD;
+
+ static const ParserErrorCode ABSTRACT_STATIC_FIELD = _ABSTRACT_STATIC_FIELD;
+
static const ParserErrorCode ABSTRACT_STATIC_METHOD = ParserErrorCode(
'ABSTRACT_STATIC_METHOD',
"Static methods can't be declared to be 'abstract'.",
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 ad33ec7..748f18c 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
@@ -114,6 +114,8 @@
_SETTER_CONSTRUCTOR,
_MEMBER_WITH_CLASS_NAME,
_EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER,
+ _ABSTRACT_STATIC_FIELD,
+ _ABSTRACT_LATE_FIELD,
];
const ParserErrorCode _ABSTRACT_CLASS_MEMBER = ParserErrorCode(
@@ -122,6 +124,14 @@
correction:
"Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration.");
+const ParserErrorCode _ABSTRACT_LATE_FIELD = ParserErrorCode(
+ 'ABSTRACT_LATE_FIELD', r"Abstract fields cannot be late.",
+ correction: "Try removing the 'abstract' or 'late' keyword.");
+
+const ParserErrorCode _ABSTRACT_STATIC_FIELD = ParserErrorCode(
+ 'ABSTRACT_STATIC_FIELD', r"Static fields can't be declared 'abstract'.",
+ correction: "Try removing the 'abstract' or 'static' keyword.");
+
const ParserErrorCode _ANNOTATION_WITH_TYPE_ARGUMENTS = ParserErrorCode(
'ANNOTATION_WITH_TYPE_ARGUMENTS',
r"An annotation (metadata) can't use type arguments.");
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index b4f23ee..abe9434 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -1588,23 +1588,18 @@
"In constant expressions, operands of this operator must be of type "
"'Type'.");
/**
- * 7.6.1 Generative Constructors: In checked mode, it is a dynamic type error
- * if o is not <b>null</b> and the interface of the class of <i>o</i> is not a
- * subtype of the static type of the field <i>v</i>.
- *
- * 16.12.2 Const: It is a compile-time error if evaluation of a constant
- * object results in an uncaught exception being thrown.
- *
* Parameters:
* 0: the name of the type of the initializer expression
* 1: the name of the type of the field
*/
static const CompileTimeErrorCode CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE =
- CompileTimeErrorCode(
+ CompileTimeErrorCodeWithUniqueName(
+ 'FIELD_INITIALIZER_NOT_ASSIGNABLE',
'CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE',
"The initializer type '{0}' can't be assigned to the field type "
"'{1}' in a const constructor.",
- correction: "Try using a subtype, or removing the 'const' keyword");
+ correction: "Try using a subtype, or removing the 'const' keyword",
+ hasPublishedDocs: true);
/**
* 6.2 Formal Parameters: It is a compile-time error if a formal parameter is
@@ -9638,19 +9633,19 @@
hasPublishedDocs: true);
/**
- * 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
- * a static type warning if <i>T</i> does not have a getter named <i>m</i>.
- *
* Parameters:
* 0: the name of the getter
* 1: the name of the enclosing type where the getter is being looked for
*/
static const CompileTimeErrorCode UNDEFINED_SUPER_GETTER =
- CompileTimeErrorCode('UNDEFINED_SUPER_GETTER',
+ CompileTimeErrorCodeWithUniqueName(
+ 'UNDEFINED_SUPER_MEMBER',
+ 'UNDEFINED_SUPER_GETTER',
"The getter '{0}' isn't defined in a superclass of '{1}'.",
correction:
"Try correcting the name to the name of an existing getter, or "
- "defining a getter or field named '{0}' in a superclass.");
+ "defining a getter or field named '{0}' in a superclass.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -9659,14 +9654,14 @@
*/
// #### Description
//
- // The analyzer produces this diagnostic when an inherited method is
- // referenced using `super`, but there’s no method with that name in the
+ // The analyzer produces this diagnostic when an inherited member is
+ // referenced using `super`, but there’s no member with that name in the
// superclass chain.
//
// #### Examples
//
// The following code produces this diagnostic because `Object` doesn't define
- // a member named `n`:
+ // a method named `n`:
//
// ```dart
// class C {
@@ -9676,18 +9671,31 @@
// }
// ```
//
+ // The following code produces this diagnostic because `Object` doesn't define
+ // a getter named `g`:
+ //
+ // ```dart
+ // class C {
+ // void m() {
+ // super.[!g!];
+ // }
+ // }
+ // ```
+ //
// #### Common fixes
//
- // If the inherited method you intend to invoke has a different name, then
- // make the name of the invoked method match the inherited method.
+ // If the inherited member you intend to invoke has a different name, then
+ // make the name of the invoked member match the inherited member.
//
- // If the method you intend to invoke is defined in the same class, then
+ // If the member you intend to invoke is defined in the same class, then
// remove the `super.`.
//
- // If not, then either add the method to one of the superclasses or remove the
+ // If not, then either add the member to one of the superclasses or remove the
// invocation.
static const CompileTimeErrorCode UNDEFINED_SUPER_METHOD =
- CompileTimeErrorCode('UNDEFINED_SUPER_METHOD',
+ CompileTimeErrorCodeWithUniqueName(
+ 'UNDEFINED_SUPER_MEMBER',
+ 'UNDEFINED_SUPER_METHOD',
"The method '{0}' isn't defined in a superclass of '{1}'.",
correction:
"Try correcting the name to the name of an existing method, or "
@@ -9695,45 +9703,32 @@
hasPublishedDocs: true);
/**
- * 12.18 Assignment: Evaluation of an assignment of the form
- * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is
- * equivalent to the evaluation of the expression (a, i, e){a.[]=(i, e);
- * return e;} (<i>e<sub>1</sub></i>, <i>e<sub>2</sub></i>,
- * <i>e<sub>2</sub></i>).
- *
- * 12.29 Assignable Expressions: An assignable expression of the form
- * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method
- * invocation of the operator method [] on <i>e<sub>1</sub></i> with argument
- * <i>e<sub>2</sub></i>.
- *
- * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
- * It is a static type warning if <i>T</i> does not have an accessible
- * instance member named <i>m</i>.
- *
* Parameters:
* 0: the name of the operator
* 1: the name of the enclosing type where the operator is being looked for
*/
static const CompileTimeErrorCode UNDEFINED_SUPER_OPERATOR =
- CompileTimeErrorCode('UNDEFINED_SUPER_OPERATOR',
+ CompileTimeErrorCodeWithUniqueName(
+ 'UNDEFINED_SUPER_MEMBER',
+ 'UNDEFINED_SUPER_OPERATOR',
"The operator '{0}' isn't defined in a superclass of '{1}'.",
- correction: "Try defining the operator '{0}' in a superclass.");
+ correction: "Try defining the operator '{0}' in a superclass.",
+ hasPublishedDocs: true);
/**
- * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
- * It is a static type warning if <i>T</i> does not have an accessible
- * instance setter named <i>v=</i>.
- *
* Parameters:
* 0: the name of the setter
* 1: the name of the enclosing type where the setter is being looked for
*/
static const CompileTimeErrorCode UNDEFINED_SUPER_SETTER =
- CompileTimeErrorCode('UNDEFINED_SUPER_SETTER',
+ CompileTimeErrorCodeWithUniqueName(
+ 'UNDEFINED_SUPER_MEMBER',
+ 'UNDEFINED_SUPER_SETTER',
"The setter '{0}' isn't defined in a superclass of '{1}'.",
correction:
"Try correcting the name to the name of an existing setter, or "
- "defining a setter or field named '{0}' in a superclass.");
+ "defining a setter or field named '{0}' in a superclass.",
+ hasPublishedDocs: true);
/**
* 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index 42141c5..1f2383c 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -8,6 +8,8 @@
Message,
MessageCode,
messageAbstractClassMember,
+ messageAbstractLateField,
+ messageAbstractStaticField,
messageConstConstructorWithBody,
messageConstructorWithTypeParameters,
messageDirectiveAfterDeclaration,
@@ -849,11 +851,22 @@
assert(optional(';', semicolon));
debugEvent("Fields");
- if (!enableNonNullable && abstractToken != null) {
- handleRecoverableError(
- messageAbstractClassMember, abstractToken, abstractToken);
+ if (abstractToken != null) {
+ if (!enableNonNullable) {
+ handleRecoverableError(
+ messageAbstractClassMember, abstractToken, abstractToken);
+ } else {
+ if (staticToken != null) {
+ handleRecoverableError(
+ messageAbstractStaticField, abstractToken, abstractToken);
+ }
+ if (lateToken != null) {
+ handleRecoverableError(
+ messageAbstractLateField, abstractToken, abstractToken);
+ }
+ }
}
- if (externalToken != null) {
+ if (externalToken != null && !enableNonNullable) {
handleRecoverableError(
messageExternalField, externalToken, externalToken);
}
@@ -874,6 +887,7 @@
metadata: metadata,
abstractKeyword: abstractToken,
covariantKeyword: covariantKeyword,
+ externalKeyword: externalToken,
staticKeyword: staticToken,
fieldList: variableList,
semicolon: semicolon));
diff --git a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
index 662d1d3..fc24212 100644
--- a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
@@ -517,11 +517,14 @@
static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword,
TypeAnnotation type, List<VariableDeclaration> variables,
- {bool isAbstract = false}) =>
+ {bool isAbstract = false, bool isExternal = false}) =>
astFactory.fieldDeclaration2(
abstractKeyword: isAbstract
? TokenFactory.tokenFromKeyword(Keyword.ABSTRACT)
: null,
+ externalKeyword: isExternal
+ ? TokenFactory.tokenFromKeyword(Keyword.EXTERNAL)
+ : null,
staticKeyword:
isStatic ? TokenFactory.tokenFromKeyword(Keyword.STATIC) : null,
fieldList: variableDeclarationList(keyword, type, variables),
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
index 8a64bc2..d77bb19 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
@@ -653,6 +653,8 @@
AstBinaryFlags.isAbstract(data.flags) ? _Tokens.ABSTRACT : null,
covariantKeyword:
AstBinaryFlags.isCovariant(data.flags) ? _Tokens.COVARIANT : null,
+ externalKeyword:
+ AstBinaryFlags.isExternal(data.flags) ? _Tokens.EXTERNAL : null,
fieldList: _readNode(data.fieldDeclaration_fields),
metadata: _readNodeListLazy(data.annotatedNode_metadata),
semicolon: _Tokens.SEMICOLON,
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
index 1e8276a..e1401dd 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
@@ -556,6 +556,7 @@
builder.flags = AstBinaryFlags.encode(
isAbstract: node.abstractKeyword != null,
isCovariant: node.covariantKeyword != null,
+ isExternal: node.externalKeyword != null,
isStatic: node.staticKeyword != null,
);
_storeClassMember(builder, node);
diff --git a/pkg/analyzer/lib/src/summary2/ast_text_printer.dart b/pkg/analyzer/lib/src/summary2/ast_text_printer.dart
index 9276295..ca115cc 100644
--- a/pkg/analyzer/lib/src/summary2/ast_text_printer.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_text_printer.dart
@@ -356,8 +356,9 @@
@override
void visitFieldDeclaration(FieldDeclaration node) {
_classMember(node);
- _token(node.staticKeyword);
_token(node.abstractKeyword);
+ _token(node.externalKeyword);
+ _token(node.staticKeyword);
_token(node.covariantKeyword);
node.fields.accept(this);
_token(node.semicolon);
diff --git a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
index b7bae75..740d4ff 100644
--- a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
@@ -835,6 +835,20 @@
return node.externalKeyword != null;
} else if (node is MethodDeclaration) {
return node.externalKeyword != null || node.body is NativeFunctionBody;
+ } else if (node is VariableDeclaration) {
+ var parent = node.parent;
+ if (parent is VariableDeclarationList) {
+ var grandParent = parent.parent;
+ if (grandParent is FieldDeclaration) {
+ return grandParent.externalKeyword != null;
+ } else {
+ throw UnimplementedError('${grandParent.runtimeType}');
+ }
+ } else {
+ throw UnimplementedError('${parent.runtimeType}');
+ }
+ } else if (node is EnumConstantDeclaration) {
+ return false;
} else {
throw UnimplementedError('${node.runtimeType}');
}
diff --git a/pkg/analyzer/test/generated/parser_fasta_test.dart b/pkg/analyzer/test/generated/parser_fasta_test.dart
index f124938..d56a21e 100644
--- a/pkg/analyzer/test/generated/parser_fasta_test.dart
+++ b/pkg/analyzer/test/generated/parser_fasta_test.dart
@@ -182,6 +182,42 @@
expect(field.abstractKeyword, isNotNull);
}
+ void test_parseField_abstract_late() {
+ createParser('abstract late int? i;', featureSet: nonNullable);
+ ClassMember member = parser.parseClassMember('C');
+ expect(member, isNotNull);
+ assertErrors(errors: [
+ expectedError(ParserErrorCode.ABSTRACT_LATE_FIELD, 0, 8),
+ ]);
+ expect(member, isFieldDeclaration);
+ FieldDeclaration field = member;
+ expect(field.abstractKeyword, isNotNull);
+ }
+
+ void test_parseField_abstract_late_final() {
+ createParser('abstract late final int? i;', featureSet: nonNullable);
+ ClassMember member = parser.parseClassMember('C');
+ expect(member, isNotNull);
+ assertErrors(errors: [
+ expectedError(ParserErrorCode.ABSTRACT_LATE_FIELD, 0, 8),
+ ]);
+ expect(member, isFieldDeclaration);
+ FieldDeclaration field = member;
+ expect(field.abstractKeyword, isNotNull);
+ }
+
+ void test_parseField_abstract_static() {
+ createParser('abstract static int? i;', featureSet: nonNullable);
+ ClassMember member = parser.parseClassMember('C');
+ expect(member, isNotNull);
+ assertErrors(errors: [
+ expectedError(ParserErrorCode.ABSTRACT_STATIC_FIELD, 0, 8),
+ ]);
+ expect(member, isFieldDeclaration);
+ FieldDeclaration field = member;
+ expect(field.abstractKeyword, isNotNull);
+ }
+
void test_parseField_const_late() {
createParser('const late T f = 0;', featureSet: nonNullable);
ClassMember member = parser.parseClassMember('C');
@@ -208,6 +244,16 @@
expect(variable.name, isNotNull);
}
+ void test_parseField_external() {
+ createParser('external int i;', featureSet: nonNullable);
+ ClassMember member = parser.parseClassMember('C');
+ expect(member, isNotNull);
+ assertNoErrors();
+ expect(member, isFieldDeclaration);
+ FieldDeclaration field = member;
+ expect(field.externalKeyword, isNotNull);
+ }
+
void test_parseField_final_late() {
createParser('final late T f;', featureSet: nonNullable);
ClassMember member = parser.parseClassMember('C');
@@ -341,6 +387,16 @@
expect(field.abstractKeyword, isNull);
}
+ void test_parseField_non_external() {
+ createParser('int i;', featureSet: nonNullable);
+ ClassMember member = parser.parseClassMember('C');
+ expect(member, isNotNull);
+ assertNoErrors();
+ expect(member, isFieldDeclaration);
+ FieldDeclaration field = member;
+ expect(field.externalKeyword, isNull);
+ }
+
void test_parseField_var_late() {
createParser('var late f;', featureSet: nonNullable);
ClassMember member = parser.parseClassMember('C');
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
index 0faaff9..779b01d 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
@@ -4,13 +4,10 @@
import 'package:analyzer/error/error.dart';
import 'package:analyzer/src/dart/error/lint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/lint/registry.dart';
-import 'package:linter/src/rules.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../resolution/driver_resolution.dart';
+import '../resolution/context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
@@ -19,55 +16,47 @@
}
@reflectiveTest
-class AnalysisDriverCachingTest extends DriverResolutionTest {
+class AnalysisDriverCachingTest extends PubPackageResolutionTest {
List<Set<String>> get _linkedCycles {
+ var driver = driverFor(testFilePath);
return driver.test.libraryContext.linkedCycles;
}
- @override
- void setUp() {
- super.setUp();
- registerLintRules();
- }
-
test_lints() async {
- var path = convertPath('/test/lib/test.dart');
-
- newFile(path, content: r'''
+ newFile(testFilePath, content: r'''
void f() {
![0].isEmpty;
}
''');
// We don't have any lints configured, so no errors.
- assertErrorsInList(
- (await driver.getErrors(path)).errors,
- [],
- );
+ await resolveTestFile();
+ assertErrorsInResult([]);
// The summary for the library was linked.
- _assertHasLinkedCycle({path}, andClear: true);
+ _assertContainsLinkedCycle({testFilePath}, andClear: true);
+
+ // We will recreate it with new analysis options.
+ // But we will reuse the byte store, so can reuse summaries.
+ disposeAnalysisContextCollection();
// Configure to run a lint.
- driver.configure(
- analysisOptions: AnalysisOptionsImpl()
- ..lint = true
- ..lintRules = [
- Registry.ruleRegistry.getRule('prefer_is_not_empty'),
- ],
+ writeTestPackageAnalysisOptionsFile(
+ AnalysisOptionsFileConfig(
+ lints: ['prefer_is_not_empty'],
+ ),
);
// Check that the lint was run, and reported.
- _assertHasLintReported(
- (await driver.getErrors(path)).errors,
- 'prefer_is_not_empty',
- );
+ await resolveTestFile();
+ _assertHasLintReported(result.errors, 'prefer_is_not_empty');
// Lints don't affect summaries, nothing should be linked.
_assertNoLinkedCycles();
}
- void _assertHasLinkedCycle(Set<String> expected, {bool andClear = false}) {
+ void _assertContainsLinkedCycle(Set<String> expected,
+ {bool andClear = false}) {
expect(_linkedCycles, contains(unorderedEquals(expected)));
if (andClear) {
_linkedCycles.clear();
diff --git a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
index f93f0ce..6218912 100644
--- a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
@@ -906,6 +906,14 @@
isAbstract: true));
}
+ void test_visitFieldDeclaration_external() {
+ _assertSource(
+ "external var a;",
+ AstTestFactory.fieldDeclaration(
+ false, Keyword.VAR, null, [AstTestFactory.variableDeclaration("a")],
+ isExternal: true));
+ }
+
void test_visitFieldDeclaration_instance() {
_assertSource(
"var a;",
diff --git a/pkg/analyzer/test/src/dart/ast/utilities_test.dart b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
index 06798f1..f08bb30 100644
--- a/pkg/analyzer/test/src/dart/ast/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
@@ -320,6 +320,26 @@
expect(toNode2.fields.variables[0].declaredElement, isNull);
}
+ void test_visitFieldDeclaration_external() {
+ FieldDeclaration fromNode = AstTestFactory.fieldDeclaration(
+ false, Keyword.VAR, null, [AstTestFactory.variableDeclaration('x')],
+ isExternal: false);
+ FieldElement element = FieldElementImpl('x', -1);
+ fromNode.fields.variables[0].name.staticElement = element;
+ FieldDeclaration toNode1 = AstTestFactory.fieldDeclaration(
+ false, Keyword.VAR, null, [AstTestFactory.variableDeclaration('x')],
+ isExternal: false);
+ ResolutionCopier.copyResolutionData(fromNode, toNode1);
+ // Nodes matched so resolution data should have been copied.
+ expect(toNode1.fields.variables[0].declaredElement, same(element));
+ FieldDeclaration toNode2 = AstTestFactory.fieldDeclaration(
+ false, Keyword.VAR, null, [AstTestFactory.variableDeclaration('x')],
+ isExternal: true);
+ ResolutionCopier.copyResolutionData(fromNode, toNode1);
+ // Nodes didn't match so resolution data should not have been copied.
+ expect(toNode2.fields.variables[0].declaredElement, isNull);
+ }
+
void test_visitForEachPartsWithDeclaration() {
ForEachPartsWithDeclaration createNode() =>
astFactory.forEachPartsWithDeclaration(
diff --git a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
index ea9f880..2dc2b41 100644
--- a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
@@ -9,6 +9,7 @@
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
+import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
@@ -120,6 +121,8 @@
with ResourceProviderMixin, ResolutionTest {
static bool _lintRulesAreRegistered = false;
+ final ByteStore _byteStore = MemoryByteStore();
+
Map<String, String> _declaredVariables = {};
AnalysisContextCollection _analysisContextCollection;
@@ -167,6 +170,12 @@
return _analysisContextCollection.contextFor(path);
}
+ void disposeAnalysisContextCollection() {
+ if (_analysisContextCollection != null) {
+ _analysisContextCollection = null;
+ }
+ }
+
/// TODO(scheglov) Replace this with a method that changes a file in
/// [AnalysisContextCollectionImpl].
AnalysisDriver driverFor(String path) {
@@ -212,6 +221,7 @@
}
_analysisContextCollection = AnalysisContextCollectionImpl(
+ byteStore: _byteStore,
declaredVariables: _declaredVariables,
enableIndex: true,
includedPaths: collectionIncludedPaths.map(convertPath).toList(),
@@ -247,12 +257,10 @@
writeTestPackageConfig({});
}
- void writeTestPackageAnalysisOptionsFile(
- AnalysisOptionsFileConfig builder,
- ) {
+ void writeTestPackageAnalysisOptionsFile(AnalysisOptionsFileConfig config) {
newFile(
'$testPackageRootPath/analysis_options.yaml',
- content: builder.toContent(),
+ content: config.toContent(),
);
}
@@ -290,6 +298,30 @@
void writeTestPackageConfigWithMeta() {
writeTestPackageConfigWith({}, meta: true);
}
+
+ void writeTestPackagePubspecYamlFile(PubspecYamlFileConfig config) {
+ newFile(
+ '$testPackageRootPath/pubspec.yaml',
+ content: config.toContent(),
+ );
+ }
+}
+
+class PubspecYamlFileConfig {
+ final String sdkVersion;
+
+ PubspecYamlFileConfig({this.sdkVersion});
+
+ String toContent() {
+ var buffer = StringBuffer();
+
+ if (sdkVersion != null) {
+ buffer.writeln('environment:');
+ buffer.writeln(" sdk: '$sdkVersion'");
+ }
+
+ return buffer.toString();
+ }
}
mixin WithNullSafetyMixin on PubPackageResolutionTest {
diff --git a/pkg/analyzer/test/src/dart/resolution/driver_resolution.dart b/pkg/analyzer/test/src/dart/resolution/driver_resolution.dart
deleted file mode 100644
index 45021c6..0000000
--- a/pkg/analyzer/test/src/dart/resolution/driver_resolution.dart
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) 2018, 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 'dart:async';
-
-import 'package:analyzer/dart/analysis/context_locator.dart' as api;
-import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/context/context_root.dart';
-import 'package:analyzer/src/context/packages.dart';
-import 'package:analyzer/src/dart/analysis/byte_store.dart';
-import 'package:analyzer/src/dart/analysis/driver.dart';
-import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart'
- as api;
-import 'package:analyzer/src/dart/analysis/file_state.dart';
-import 'package:analyzer/src/dart/analysis/performance_logger.dart';
-import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
-import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/source/package_map_resolver.dart';
-import 'package:analyzer/src/test_utilities/mock_sdk.dart';
-import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
-import 'package:meta/meta.dart';
-
-import 'resolution.dart';
-
-/// [AnalysisDriver] based implementation of [ResolutionTest].
-class DriverResolutionTest with ResourceProviderMixin, ResolutionTest {
- final ByteStore byteStore = MemoryByteStore();
-
- final StringBuffer logBuffer = StringBuffer();
- PerformanceLog logger;
-
- DartSdk sdk;
- Map<String, List<Folder>> packageMap;
- AnalysisDriverScheduler scheduler;
- AnalysisDriver driver;
-
- List<MockSdkLibrary> get additionalMockSdkLibraries => [];
-
- /// Override this to change the analysis options for a given set of tests.
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl();
-
- bool get enableIndex => false;
-
- void configureWorkspace({@required String root}) {
- newFolder(root);
-
- var apiContextRoots = api.ContextLocator(
- resourceProvider: resourceProvider,
- ).locateRoots(
- includedPaths: [convertPath(root)],
- excludedPaths: [],
- );
-
- driver.configure(
- analysisContext: api.DriverBasedAnalysisContext(
- resourceProvider,
- apiContextRoots.first,
- driver,
- ),
- );
- }
-
- @override
- Future<ResolvedUnitResult> resolveFile(String path) async {
- return await driver.getResult(path);
- }
-
- void setUp() {
- sdk = MockSdk(
- resourceProvider: resourceProvider,
- additionalLibraries: additionalMockSdkLibraries,
- );
- logger = PerformanceLog(logBuffer);
- scheduler = AnalysisDriverScheduler(logger);
-
- // TODO(brianwilkerson) Create an empty package map by default and only add
- // packages in the tests that need them.
- packageMap = <String, List<Folder>>{
- 'test': [getFolder('/test/lib')],
- 'aaa': [getFolder('/aaa/lib')],
- 'bbb': [getFolder('/bbb/lib')],
- 'meta': [getFolder('/.pub-cache/meta/lib')],
- };
-
- driver = AnalysisDriver(
- scheduler,
- logger,
- resourceProvider,
- byteStore,
- FileContentOverlay(),
- ContextRoot(
- convertPath('/test'),
- [],
- pathContext: resourceProvider.pathContext,
- ),
- SourceFactory([
- DartUriResolver(sdk),
- PackageMapUriResolver(resourceProvider, packageMap),
- ResourceUriResolver(resourceProvider)
- ]),
- analysisOptions,
- enableIndex: enableIndex,
- packages: Packages.empty);
-
- configureWorkspace(root: '/test');
-
- scheduler.start();
- }
-}
diff --git a/pkg/analyzer/test/src/dart/resolution/language_version_test.dart b/pkg/analyzer/test/src/dart/resolution/language_version_test.dart
index 2391856..d200a01 100644
--- a/pkg/analyzer/test/src/dart/resolution/language_version_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/language_version_test.dart
@@ -2,16 +2,12 @@
// 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/context/packages.dart';
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/test_utilities/find_element.dart';
-import 'package:analyzer/src/test_utilities/find_node.dart';
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'driver_resolution.dart';
-import 'with_null_safety_mixin.dart';
+import 'context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
@@ -37,14 +33,14 @@
},
{
"name": "aaa",
- "rootUri": "${toUriStr('/aaa')}",
+ "rootUri": "${toUriStr('$workspaceRootPath/aaa')}",
"packageUri": "lib/"
}
]
}
''');
- newFile('/aaa/lib/a.dart', content: r'''
+ newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
int a = 0;
''');
@@ -73,7 +69,7 @@
},
{
"name": "aaa",
- "rootUri": "${toUriStr('/aaa')}",
+ "rootUri": "${toUriStr('$workspaceRootPath/aaa')}",
"packageUri": "lib/",
"languageVersion": "2.7"
}
@@ -81,7 +77,7 @@
}
''');
- newFile('/aaa/lib/a.dart', content: r'''
+ newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
int a = 0;
''');
@@ -124,16 +120,17 @@
}
''');
- var path = convertPath('/test/bin/a.dart');
- await _resolveFile(path, r'''
+ var path = '$testPackageRootPath/bin/a.dart';
+
+ await resolveFileCode(path, r'''
var x = 0;
''');
- assertErrorsInList(result.errors, []);
+ assertErrorsInResult([]);
assertType(findElement.topVar('x').type, 'int*');
- // Upgrade the language version to `2.10`, so enabled Null Safety.
- driver.changeFile(path);
- await _resolveFile(path, r'''
+ // Upgrade the language version to `2.10`, so enable Null Safety.
+ _changeFile(path);
+ await resolveFileCode(path, r'''
// @dart = 2.10
var x = 0;
''');
@@ -157,13 +154,16 @@
}
''');
- await assertNoErrorsInCode('''
+ var path = testFilePath;
+
+ await resolveFileCode(path, '''
var x = 0;
''');
+ assertErrorsInResult([]);
assertType(findElement.topVar('x').type, 'int*');
- // Upgrade the language version to `2.10`, so enabled Null Safety.
- _changeTestFile();
+ // Upgrade the language version to `2.10`, so enable Null Safety.
+ _changeFile(path);
await assertNoErrorsInCode('''
// @dart = 2.10
var x = 0;
@@ -187,16 +187,17 @@
}
''');
- var path = convertPath('/test/bin/a.dart');
- await _resolveFile(path, r'''
+ var path = '$testPackageRootPath/bin/a.dart';
+
+ await resolveFileCode(path, r'''
var x = 0;
''');
assertErrorsInList(result.errors, []);
assertType(findElement.topVar('x').type, 'int');
// Downgrade the version to `2.8`, so disable Null Safety.
- driver.changeFile(path);
- await _resolveFile(path, r'''
+ _changeFile(path);
+ await resolveFileCode(path, r'''
// @dart = 2.8
var x = 0;
''');
@@ -219,13 +220,16 @@
}
''');
- await assertNoErrorsInCode('''
+ var path = testFilePath;
+
+ await resolveFileCode(path, '''
var x = 0;
''');
+ assertErrorsInResult([]);
assertType(findElement.topVar('x').type, 'int');
// Downgrade the version to `2.8`, so disable Null Safety.
- _changeTestFile();
+ _changeFile(path);
await assertNoErrorsInCode('''
// @dart = 2.8
var x = 0;
@@ -233,11 +237,6 @@
assertType(findElement.topVar('x').type, 'int*');
}
- void _changeTestFile() {
- var path = convertPath('/test/lib/test.dart');
- driver.changeFile(path);
- }
-
void _configureAllowedExperimentsTestNullSafety() {
_newSdkExperimentsFile(r'''
{
@@ -265,14 +264,6 @@
content: content,
);
}
-
- Future<void> _resolveFile(String path, String content) async {
- newFile(path, content: content);
- result = await resolveFile(path);
-
- findNode = FindNode(result.content, result.unit);
- findElement = FindElement(result.unit);
- }
}
@reflectiveTest
@@ -324,15 +315,20 @@
}
}
-class _FeaturesTest extends DriverResolutionTest {
- void _configureTestWithJsonConfig(String content) {
- newFile('/test/.dart_tool/package_config.json', content: content);
+class _FeaturesTest extends PubPackageResolutionTest {
+ /// Do necessary work to ensure that the file with the [path] is considered
+ /// changed for the purpose of following analysis.
+ ///
+ /// Currently we just dispose the whole analysis context collection, so when
+ /// we ask to analyze anything again, we will pick up the new file content.
+ void _changeFile(String path) {
+ disposeAnalysisContextCollection();
+ }
- driver.configure(
- packages: findPackagesFrom(
- resourceProvider,
- getFolder('/test'),
- ),
+ void _configureTestWithJsonConfig(String content) {
+ newFile(
+ '$testPackageRootPath/.dart_tool/package_config.json',
+ content: content,
);
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/with_null_safety_mixin.dart b/pkg/analyzer/test/src/dart/resolution/with_null_safety_mixin.dart
deleted file mode 100644
index 300f0a6..0000000
--- a/pkg/analyzer/test/src/dart/resolution/with_null_safety_mixin.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2020, 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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
-import 'package:analyzer/src/generated/engine.dart';
-
-import 'driver_resolution.dart';
-
-mixin WithNullSafetyMixin on DriverResolutionTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.non_nullable],
- );
-
- @override
- bool get typeToStringWithNullability => true;
-}
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_constraint_verifier_support.dart b/pkg/analyzer/test/src/diagnostics/sdk_constraint_verifier_support.dart
index ee4c362..b196ff0 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_constraint_verifier_support.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_constraint_verifier_support.dart
@@ -2,21 +2,22 @@
// 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:pub_semver/pub_semver.dart';
-
import '../../generated/test_support.dart';
-import '../dart/resolution/driver_resolution.dart';
+import '../dart/resolution/context_collection_resolution.dart';
/// A base class designed to be used by tests of the hints produced by the
/// SdkConstraintVerifier.
-class SdkConstraintVerifierTest extends DriverResolutionTest {
- /// Verify that the [errorCodes] are produced if the [source] is analyzed in
- /// a context that specifies the minimum SDK version to be [version].
+class SdkConstraintVerifierTest extends PubPackageResolutionTest {
+ /// Verify that the [expectedErrors] are produced if the [source] is analyzed
+ /// in a context that specifies the minimum SDK version to be [version].
Future<void> verifyVersion(String version, String source,
{List<ExpectedError> expectedErrors}) async {
- driver.configure(
- analysisOptions: analysisOptions
- ..sdkVersionConstraint = VersionConstraint.parse(version));
+ writeTestPackagePubspecYamlFile(
+ PubspecYamlFileConfig(
+ sdkVersion: '>=$version',
+ ),
+ );
+
await assertErrorsInCode(source, expectedErrors ?? []);
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_as_expression_in_const_context_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_as_expression_in_const_context_test.dart
index 6d05350..33be628 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_as_expression_in_const_context_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_as_expression_in_const_context_test.dart
@@ -2,10 +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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'sdk_constraint_verifier_support.dart';
@@ -19,12 +16,6 @@
@reflectiveTest
class SdkVersionAsExpressionInConstContextTest
extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.constant_update_2018],
- );
-
test_equals() async {
await verifyVersion('2.5.0', '''
const dynamic a = 2;
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart
index 2a296e2..47c4e1a 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart
@@ -32,7 +32,7 @@
}
test_equals_explicitImportOfExportingLibrary() async {
- newFile('/test/lib/exporter.dart', content: '''
+ newFile('$testPackageLibPath/exporter.dart', content: '''
export 'dart:async';
''');
await verifyVersion('2.1.0', '''
@@ -78,7 +78,7 @@
}
test_lessThan_explicitImportOfExportingLibrary() async {
- newFile('/test/lib/exporter.dart', content: '''
+ newFile('$testPackageLibPath/exporter.dart', content: '''
export 'dart:async';
''');
await verifyVersion('2.0.0', '''
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_bool_operator_in_const_context_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_bool_operator_in_const_context_test.dart
index fe94669..8397452 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_bool_operator_in_const_context_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_bool_operator_in_const_context_test.dart
@@ -2,10 +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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'sdk_constraint_verifier_support.dart';
@@ -19,12 +16,6 @@
@reflectiveTest
class SdkVersionBoolOperatorInConstContextTest
extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.constant_update_2018],
- );
-
test_and_const_equals() async {
await verifyVersion('2.5.0', '''
const c = true & false;
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_eq_eq_operator_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_eq_eq_operator_test.dart
index b7b64d8..dc8a974 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_eq_eq_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_eq_eq_operator_test.dart
@@ -2,10 +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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'sdk_constraint_verifier_support.dart';
@@ -18,12 +15,6 @@
@reflectiveTest
class SdkVersionEqEqOperatorTest extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.constant_update_2018],
- );
-
test_left_equals() async {
await verifyVersion('2.5.0', '''
class A {
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_extension_methods_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_extension_methods_test.dart
index 5e6393c..506bd86 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_extension_methods_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_extension_methods_test.dart
@@ -2,10 +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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'sdk_constraint_verifier_support.dart';
@@ -18,12 +15,6 @@
@reflectiveTest
class SdkVersionExtensionMethodsTest extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.extension_methods],
- );
-
test_extension_equals() async {
await verifyVersion('2.6.0', '''
extension E on int {}
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_gt_gt_gt_operator_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_gt_gt_gt_operator_test.dart
index f535a32..bcdd907 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_gt_gt_gt_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_gt_gt_gt_operator_test.dart
@@ -2,12 +2,11 @@
// 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/dart/analysis/features.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import '../dart/resolution/context_collection_resolution.dart';
import 'sdk_constraint_verifier_support.dart';
main() {
@@ -19,10 +18,14 @@
@reflectiveTest
class SdkVersionGtGtGtOperatorTest extends SdkConstraintVerifierTest {
@override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.triple_shift],
+ void setUp() {
+ super.setUp();
+ writeTestPackageAnalysisOptionsFile(
+ AnalysisOptionsFileConfig(
+ experiments: [EnableString.triple_shift],
+ ),
);
+ }
test_const_equals() async {
// TODO(brianwilkerson) Add '>>>' to MockSdk and remove the code
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_is_expression_in_const_context_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_is_expression_in_const_context_test.dart
index 4bceff1..c9b3cea 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_is_expression_in_const_context_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_is_expression_in_const_context_test.dart
@@ -2,10 +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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'sdk_constraint_verifier_support.dart';
@@ -19,12 +16,6 @@
@reflectiveTest
class SdkVersionIsExpressionInConstContextTest
extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.constant_update_2018],
- );
-
test_equals() async {
await verifyVersion('2.5.0', '''
const dynamic a = 2;
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
index 25f3ed0..6601e17 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
@@ -2,12 +2,10 @@
// 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/dart/analysis/features.dart';
import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../dart/resolution/with_null_safety_mixin.dart';
+import '../dart/resolution/context_collection_resolution.dart';
import 'sdk_constraint_verifier_support.dart';
main() {
@@ -19,10 +17,6 @@
@reflectiveTest
class SdkVersionNeverTest extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.forTesting(sdkVersion: '2.7.0');
-
test_languageVersionBeforeNullSafety() async {
await verifyVersion('2.7.0', r'''
Never foo;
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_ui_as_code_in_const_context_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_ui_as_code_in_const_context_test.dart
index 3ada64c..72871b6 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_ui_as_code_in_const_context_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_ui_as_code_in_const_context_test.dart
@@ -2,10 +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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'sdk_constraint_verifier_support.dart';
@@ -18,12 +15,6 @@
@reflectiveTest
class SdkVersionUiAsCodeInConstContextTest extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = FeatureSet.fromEnableFlags(
- [EnableString.constant_update_2018],
- );
-
test_equals() async {
await verifyVersion('2.5.0', '''
const zero = [...const [0]];
diff --git a/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart b/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart
index 1ac4382..2f784fb 100644
--- a/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart
@@ -2,13 +2,10 @@
// 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/file_system/file_system.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/test_utilities/package_mixin.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../generated/test_support.dart';
-import '../dart/resolution/driver_resolution.dart';
+import '../dart/resolution/context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
@@ -17,116 +14,125 @@
}
@reflectiveTest
-class SubtypeOfSealedClassTest extends DriverResolutionTest with PackageMixin {
+class SubtypeOfSealedClassTest extends PubPackageResolutionTest {
+ @override
+ void setUp() {
+ super.setUp();
+ writeTestPackageConfigWithMeta();
+ }
+
test_extendingSealedClass() async {
- addMetaPackage();
- _addPackage('foo', r'''
+ writeTestPackageConfigWith({
+ 'foo': '$workspaceRootPath/foo',
+ }, meta: true);
+
+ await newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
import 'package:meta/meta.dart';
@sealed class Foo {}
''');
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await assertErrorsInCode(r'''
import 'package:foo/foo.dart';
class Bar extends Foo {}
-''');
- await _resolveFile('/pkg1/lib/lib1.dart', [
+''', [
error(HintCode.SUBTYPE_OF_SEALED_CLASS, 31, 24),
]);
}
test_implementingSealedClass() async {
- addMetaPackage();
- _addPackage('foo', r'''
+ writeTestPackageConfigWith({
+ 'foo': '$workspaceRootPath/foo',
+ }, meta: true);
+
+ newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
import 'package:meta/meta.dart';
@sealed class Foo {}
''');
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await assertErrorsInCode(r'''
import 'package:foo/foo.dart';
class Bar implements Foo {}
-''');
- await _resolveFile('/pkg1/lib/lib1.dart', [
+''', [
error(HintCode.SUBTYPE_OF_SEALED_CLASS, 31, 27),
]);
}
test_mixinApplicationOfSealedClass() async {
- addMetaPackage();
- _addPackage('foo', r'''
+ writeTestPackageConfigWith({
+ 'foo': '$workspaceRootPath/foo',
+ }, meta: true);
+
+ newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
import 'package:meta/meta.dart';
@sealed class Foo {}
''');
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await assertErrorsInCode(r'''
import 'package:foo/foo.dart';
class Bar1 {}
class Bar2 = Bar1 with Foo;
-''');
- await _resolveFile('/pkg1/lib/lib1.dart', [
+''', [
error(HintCode.SUBTYPE_OF_SEALED_CLASS, 45, 27),
]);
}
test_mixinApplicationOfSealedMixin() async {
- addMetaPackage();
- _addPackage('foo', r'''
+ writeTestPackageConfigWith({
+ 'foo': '$workspaceRootPath/foo',
+ }, meta: true);
+
+ newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
import 'package:meta/meta.dart';
@sealed mixin Foo {}
''');
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await assertErrorsInCode(r'''
import 'package:foo/foo.dart';
class Bar1 {}
class Bar2 = Bar1 with Foo;
-''');
- await _resolveFile('/pkg1/lib/lib1.dart', [
+''', [
error(HintCode.SUBTYPE_OF_SEALED_CLASS, 45, 27),
]);
}
test_mixingInWithSealedMixin() async {
- addMetaPackage();
- _addPackage('foo', r'''
+ writeTestPackageConfigWith({
+ 'foo': '$workspaceRootPath/foo',
+ }, meta: true);
+
+ newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
import 'package:meta/meta.dart';
@sealed mixin Foo {}
''');
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await assertErrorsInCode(r'''
import 'package:foo/foo.dart';
class Bar extends Object with Foo {}
-''');
- await _resolveFile('/pkg1/lib/lib1.dart', [
+''', [
error(HintCode.SUBTYPE_OF_SEALED_CLASS, 31, 36),
]);
}
test_mixinImplementsSealedClass() async {
- addMetaPackage();
- _addPackage('foo', r'''
+ writeTestPackageConfigWith({
+ 'foo': '$workspaceRootPath/foo',
+ }, meta: true);
+
+ newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
import 'package:meta/meta.dart';
@sealed class Foo {}
''');
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await assertErrorsInCode(r'''
import 'package:foo/foo.dart';
mixin Bar implements Foo {}
-''');
- await _resolveFile('/pkg1/lib/lib1.dart', [
+''', [
error(HintCode.SUBTYPE_OF_SEALED_CLASS, 31, 27),
]);
}
test_withinLibrary_OK() async {
- addMetaPackage();
-
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await assertNoErrorsInCode(r'''
import 'package:meta/meta.dart';
@sealed class Foo {}
@@ -135,88 +141,63 @@
class Bar4 = Bar1 with Foo;
mixin Bar5 implements Foo {}
''');
- await _resolveFile('/pkg1/lib/lib1.dart');
}
test_withinPackageLibDirectory_OK() async {
- addMetaPackage();
-
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await newFile('$testPackageLibPath/a.dart', content: r'''
import 'package:meta/meta.dart';
@sealed class Foo {}
''');
- newFile('/pkg1/lib/src/lib2.dart', content: r'''
-import '../lib1.dart';
+
+ await resolveFileCode('$testPackageLibPath/src/b.dart', r'''
+import '../a.dart';
class Bar1 extends Foo {}
class Bar2 implements Foo {}
class Bar4 = Bar1 with Foo;
mixin Bar5 implements Foo {}
''');
- await _resolveFile('/pkg1/lib/lib1.dart');
- await _resolveFile('/pkg1/lib/src/lib2.dart');
+ assertNoErrorsInResult();
}
test_withinPackageTestDirectory_OK() async {
- addMetaPackage();
-
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ await newFile('$testPackageLibPath/a.dart', content: r'''
import 'package:meta/meta.dart';
@sealed class Foo {}
''');
- newFile('/pkg1/test/test.dart', content: r'''
-import '../lib/lib1.dart';
+
+ await resolveFileCode('$testPackageRootPath/test/test.dart', r'''
+import 'package:test/a.dart';
+
class Bar1 extends Foo {}
class Bar2 implements Foo {}
class Bar4 = Bar1 with Foo;
mixin Bar5 implements Foo {}
''');
- await _resolveFile('/pkg1/lib/lib1.dart');
- await _resolveFile('/pkg1/test/test.dart');
+ assertNoErrorsInResult();
}
test_withinPart_OK() async {
- addMetaPackage();
+ var libPath = '$testPackageLibPath/a.dart';
+ var partPath = '$testPackageLibPath/b.dart';
- _newPubPackageRoot('/pkg1');
- newFile('/pkg1/lib/lib1.dart', content: r'''
+ newFile(libPath, content: r'''
import 'package:meta/meta.dart';
-part 'part1.dart';
+part 'b.dart';
@sealed class Foo {}
''');
- newFile('/pkg1/lib/part1.dart', content: r'''
-part of 'lib1.dart';
+
+ await newFile(partPath, content: r'''
+part of 'a.dart';
class Bar1 extends Foo {}
class Bar2 implements Foo {}
class Bar4 = Bar1 with Foo;
mixin Bar5 implements Foo {}
''');
- await _resolveFile('/pkg1/lib/lib1.dart');
- }
- /// Add a package named [name], and one library file, with content
- /// [libraryContent].
- void _addPackage(String name, String libraryContent) {
- Folder lib = addPubPackage(name);
- newFile(join(lib.path, '$name.dart'), content: libraryContent);
- }
+ await resolveFile2(libPath);
+ assertNoErrorsInResult();
- /// Write a pubspec file at [root], so that BestPracticesVerifier can see
- /// that [root] is the root of a PubWorkspace, and a PubWorkspacePackage.
- void _newPubPackageRoot(String root) {
- newFile('$root/pubspec.yaml');
- configureWorkspace(root: root);
- }
-
- /// Resolve the file with the given [path].
- ///
- /// Similar to ResolutionTest.resolveTestFile, but a custom path is supported.
- Future<void> _resolveFile(
- String path, [
- List<ExpectedError> expectedErrors = const [],
- ]) async {
- result = await resolveFile(convertPath(path));
- assertErrorsInResolvedUnit(result, expectedErrors);
+ await resolveFile2(partPath);
+ assertNoErrorsInResult();
}
}
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index b630645..cfdb167 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -967,6 +967,7 @@
writeIf(e.isStatic, 'static ');
writeIf(e is FieldElementImpl && e.isAbstract, 'abstract ');
writeIf(e is FieldElementImpl && e.isCovariant, 'covariant ');
+ writeIf(e is FieldElementImpl && e.isExternal, 'external ');
} else {
writeDocumentation(e);
writeMetadata(e, '', '\n');
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index 70960ee..ae2c9b6 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -498,6 +498,7 @@
_withIndent(() {
var properties = _Properties();
properties.addToken('abstractKeyword', node.abstractKeyword);
+ properties.addToken('externalKeyword', node.externalKeyword);
properties.addToken('covariantKeyword', node.covariantKeyword);
properties.addNode('fields', node.fields);
properties.addToken('semicolon', node.semicolon);
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 5c26d58..e3ee762 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -6106,6 +6106,20 @@
''');
}
+ test_field_external() async {
+ featureSet = enableNnbd;
+ var library = await checkLibrary('''
+abstract class C {
+ external int i;
+}
+''');
+ checkElementText(library, '''
+abstract class C {
+ external int i;
+}
+''');
+ }
+
test_field_final_hasInitializer_hasConstConstructor() async {
var library = await checkLibrary('''
class C {
diff --git a/pkg/analyzer/tool/diagnostics/diagnostics.md b/pkg/analyzer/tool/diagnostics/diagnostics.md
index c6ef942..8d007fc 100644
--- a/pkg/analyzer/tool/diagnostics/diagnostics.md
+++ b/pkg/analyzer/tool/diagnostics/diagnostics.md
@@ -2510,6 +2510,9 @@
### field_initializer_not_assignable
+_The initializer type '{0}' can't be assigned to the field type '{1}' in a const
+constructor._
+
_The initializer type '{0}' can't be assigned to the field type '{1}'._
#### Description
@@ -7805,20 +7808,26 @@
var x = min(0, 1);
{% endprettify %}
-### undefined_super_method
+### undefined_super_member
+
+_The getter '{0}' isn't defined in a superclass of '{1}'._
_The method '{0}' isn't defined in a superclass of '{1}'._
+_The operator '{0}' isn't defined in a superclass of '{1}'._
+
+_The setter '{0}' isn't defined in a superclass of '{1}'._
+
#### Description
-The analyzer produces this diagnostic when an inherited method is
-referenced using `super`, but there’s no method with that name in the
+The analyzer produces this diagnostic when an inherited member is
+referenced using `super`, but there’s no member with that name in the
superclass chain.
#### Examples
The following code produces this diagnostic because `Object` doesn't define
-a member named `n`:
+a method named `n`:
{% prettify dart tag=pre+code %}
class C {
@@ -7828,15 +7837,26 @@
}
{% endprettify %}
+The following code produces this diagnostic because `Object` doesn't define
+a getter named `g`:
+
+{% prettify dart tag=pre+code %}
+class C {
+ void m() {
+ super.[!g!];
+ }
+}
+{% endprettify %}
+
#### Common fixes
-If the inherited method you intend to invoke has a different name, then
-make the name of the invoked method match the inherited method.
+If the inherited member you intend to invoke has a different name, then
+make the name of the invoked member match the inherited member.
-If the method you intend to invoke is defined in the same class, then
+If the member you intend to invoke is defined in the same class, then
remove the `super.`.
-If not, then either add the method to one of the superclasses or remove the
+If not, then either add the member to one of the superclasses or remove the
invocation.
### unnecessary_cast
@@ -8522,3 +8542,7 @@
void f(C<int> x) {}
{% endprettify %}
+
+### undefined_super_method
+
+See [undefined_super_member](#undefined-super-member).
diff --git a/pkg/analyzer/tool/diagnostics/generate.dart b/pkg/analyzer/tool/diagnostics/generate.dart
index bc4fb24..59b6c0e 100644
--- a/pkg/analyzer/tool/diagnostics/generate.dart
+++ b/pkg/analyzer/tool/diagnostics/generate.dart
@@ -161,6 +161,7 @@
_writeHeader(sink);
_writeGlossary(sink);
_writeDiagnostics(sink);
+ _writeForwards(sink);
}
/// Extract documentation from all of the files containing the definitions of
@@ -382,6 +383,17 @@
}
}
+ /// Write the forwarding documentation for all of the diagnostics that have
+ /// been renamed.
+ void _writeForwards(StringSink sink) {
+ sink.write('''
+
+### undefined_super_method
+
+See [undefined_super_member](#undefined-super-member).
+''');
+ }
+
/// Write the glossary.
void _writeGlossary(StringSink sink) {
sink.write('''
diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart
index 301068b..d4685fe 100644
--- a/pkg/dartdev/lib/src/commands/run.dart
+++ b/pkg/dartdev/lib/src/commands/run.dart
@@ -29,6 +29,7 @@
final ArgParser argParser = ArgParser(
// Don't parse flags after script name.
allowTrailingOptions: false,
+ usageLineLength: kMaxLogCharWidth,
);
@override
diff --git a/pkg/dartdev/lib/src/core.dart b/pkg/dartdev/lib/src/core.dart
index da4b3d3..d173da0 100644
--- a/pkg/dartdev/lib/src/core.dart
+++ b/pkg/dartdev/lib/src/core.dart
@@ -15,6 +15,8 @@
Logger log;
bool isDiagnostics = false;
+const kMaxLogCharWidth = 120;
+
abstract class DartdevCommand<int> extends Command {
final String _name;
final String _description;
diff --git a/pkg/dartdev/test/commands/flag_test.dart b/pkg/dartdev/test/commands/flag_test.dart
index 90a9040..f4fa75e 100644
--- a/pkg/dartdev/test/commands/flag_test.dart
+++ b/pkg/dartdev/test/commands/flag_test.dart
@@ -34,7 +34,11 @@
.commands
.forEach((String commandKey, Command command) {
if (command.argParser != null) {
- expect(command.argParser.usageLineLength, isNull);
+ if (command.name == 'run') {
+ expect(command.argParser.usageLineLength, 120);
+ } else {
+ expect(command.argParser.usageLineLength, isNull);
+ }
}
});
});
diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status
index e375f71..affbc2f 100644
--- a/pkg/front_end/messages.status
+++ b/pkg/front_end/messages.status
@@ -11,10 +11,8 @@
AbstractExtensionField/analyzerCode: Fail
AbstractExtensionField/example: Fail
AbstractExternalField/analyzerCode: Fail
-AbstractLateField/analyzerCode: Fail
AbstractNotSync/example: Fail
AbstractRedirectedClassInstantiation/example: Fail
-AbstractStaticField/analyzerCode: Fail
AccessError/analyzerCode: Fail
AccessError/example: Fail
AmbiguousExtensionMethod/analyzerCode: Fail
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index f317340..084b7c1 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -563,7 +563,9 @@
- "abstract class C {external abstract var f;}"
AbstractStaticField:
+ index: 107
template: "Static fields can't be declared 'abstract'."
+ analyzerCode: ParserErrorCode.ABSTRACT_STATIC_FIELD
tip: "Try removing the 'abstract' or 'static' keyword."
configuration: nnbd-strong
script:
@@ -593,7 +595,9 @@
- "abstract class C {abstract var f; C() : this.f = 0;}"
AbstractLateField:
+ index: 108
template: "Abstract fields cannot be late."
+ analyzerCode: ParserErrorCode.ABSTRACT_LATE_FIELD
tip: "Try removing the 'abstract' or 'late' keyword."
configuration: nnbd-strong
script:
diff --git a/runtime/bin/dartdev_isolate.cc b/runtime/bin/dartdev_isolate.cc
index 1f91437..bf3a311 100644
--- a/runtime/bin/dartdev_isolate.cc
+++ b/runtime/bin/dartdev_isolate.cc
@@ -62,7 +62,7 @@
// First assume we're in dart-sdk/bin.
char* snapshot_path =
- Utils::SCreate("%ssnapshots/dartdev.dart.snapshot", dir_prefix.get());
+ Utils::SCreate("%s../lib/_internal/dartdev.dill", dir_prefix.get());
if (File::Exists(nullptr, snapshot_path)) {
return Utils::CreateCStringUniquePtr(snapshot_path);
}
@@ -70,7 +70,7 @@
// If we're not in dart-sdk/bin, we might be in one of the $SDK/out/*
// directories. Try to use a snapshot rom a previously built SDK.
- snapshot_path = Utils::SCreate("%sdartdev.dart.snapshot", dir_prefix.get());
+ snapshot_path = Utils::SCreate("%sdartdev.dill", dir_prefix.get());
if (File::Exists(nullptr, snapshot_path)) {
return Utils::CreateCStringUniquePtr(snapshot_path);
}
diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h
index 8b3cc81..92bc408 100644
--- a/runtime/vm/compiler/backend/il.h
+++ b/runtime/vm/compiler/backend/il.h
@@ -5528,6 +5528,7 @@
DECLARE_INSTRUCTION(LoadIndexed)
virtual CompileType ComputeType() const;
+ virtual bool RecomputeType();
virtual Representation RequiredInputRepresentation(intptr_t idx) const {
ASSERT(idx == 0 || idx == 1);
diff --git a/runtime/vm/compiler/backend/type_propagator.cc b/runtime/vm/compiler/backend/type_propagator.cc
index f3fcd25..ba9529b 100644
--- a/runtime/vm/compiler/backend/type_propagator.cc
+++ b/runtime/vm/compiler/backend/type_propagator.cc
@@ -1701,6 +1701,61 @@
return CompileType::FromCid(definition_cid_);
}
+static AbstractTypePtr ExtractElementTypeFromArrayType(
+ const AbstractType& array_type) {
+ if (array_type.IsTypeParameter()) {
+ return ExtractElementTypeFromArrayType(
+ AbstractType::Handle(TypeParameter::Cast(array_type).bound()));
+ }
+ if (!array_type.IsType()) {
+ return Object::dynamic_type().raw();
+ }
+ const intptr_t cid = array_type.type_class_id();
+ if (cid == kGrowableObjectArrayCid || cid == kArrayCid ||
+ cid == kImmutableArrayCid ||
+ array_type.type_class() ==
+ Isolate::Current()->object_store()->list_class()) {
+ const auto& type_args = TypeArguments::Handle(array_type.arguments());
+ return type_args.TypeAtNullSafe(Array::kElementTypeTypeArgPos);
+ }
+ return Object::dynamic_type().raw();
+}
+
+static AbstractTypePtr GetElementTypeFromArray(Value* array) {
+ return ExtractElementTypeFromArrayType(*(array->Type()->ToAbstractType()));
+}
+
+static CompileType ComputeArrayElementType(Value* array) {
+ // 1. Try to extract element type from array value.
+ auto& elem_type = AbstractType::Handle(GetElementTypeFromArray(array));
+ if (!elem_type.IsDynamicType()) {
+ return CompileType::FromAbstractType(elem_type);
+ }
+
+ // 2. Array value may be loaded from GrowableObjectArray.data.
+ // Unwrap and try again.
+ if (auto* load_field = array->definition()->AsLoadField()) {
+ if (load_field->slot().IsIdentical(Slot::GrowableObjectArray_data())) {
+ array = load_field->instance();
+ elem_type = GetElementTypeFromArray(array);
+ if (!elem_type.IsDynamicType()) {
+ return CompileType::FromAbstractType(elem_type);
+ }
+ }
+ }
+
+ // 3. If array was loaded from a Dart field, use field's static type.
+ // Unlike propagated type (which could be cid), static type may contain
+ // type arguments which can be used to figure out element type.
+ if (auto* load_field = array->definition()->AsLoadField()) {
+ if (load_field->slot().IsDartField()) {
+ elem_type =
+ ExtractElementTypeFromArrayType(load_field->slot().static_type());
+ }
+ }
+ return CompileType::FromAbstractType(elem_type);
+}
+
CompileType LoadIndexedInstr::ComputeType() const {
switch (class_id_) {
case kArrayCid:
@@ -1709,7 +1764,7 @@
// The original call knew something.
return *result_type_;
}
- return CompileType::Dynamic();
+ return ComputeArrayElementType(array());
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
@@ -1751,4 +1806,13 @@
}
}
+bool LoadIndexedInstr::RecomputeType() {
+ if ((class_id_ == kArrayCid) || (class_id_ == kImmutableArrayCid)) {
+ // Array element type computation depends on computed
+ // types of other instructions and may change over time.
+ return UpdateType(ComputeType());
+ }
+ return false;
+}
+
} // namespace dart
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 2824547..cd1e1f0 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -9566,6 +9566,9 @@
bool IsImmutable() const { return raw()->GetClassId() == kImmutableArrayCid; }
+ // Position of element type in type arguments.
+ static const intptr_t kElementTypeTypeArgPos = 0;
+
virtual TypeArgumentsPtr GetTypeArguments() const {
return raw_ptr()->type_arguments_;
}
diff --git a/runtime/vm/object_store.cc b/runtime/vm/object_store.cc
index 9683d81..26a5c3a 100644
--- a/runtime/vm/object_store.cc
+++ b/runtime/vm/object_store.cc
@@ -335,13 +335,15 @@
}
void ObjectStore::LazyInitCoreTypes() {
- if (non_nullable_list_rare_type_ == Type::null()) {
+ if (list_class_ == Type::null()) {
+ ASSERT(non_nullable_list_rare_type_ == Type::null());
ASSERT(non_nullable_map_rare_type_ == Type::null());
Thread* thread = Thread::Current();
Zone* zone = thread->zone();
const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
Class& cls = Class::Handle(zone, core_lib.LookupClass(Symbols::List()));
ASSERT(!cls.IsNull());
+ set_list_class(cls);
Type& type = Type::Handle(zone);
type ^= cls.RareType();
set_non_nullable_list_rare_type(type);
diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h
index 5d7a535..7be73a4 100644
--- a/runtime/vm/object_store.h
+++ b/runtime/vm/object_store.h
@@ -82,6 +82,7 @@
RW(Type, string_type) \
RW(Type, legacy_string_type) \
RW(Type, non_nullable_string_type) \
+ CW(Class, list_class) /* maybe be null, lazily built */ \
CW(Type, non_nullable_list_rare_type) /* maybe be null, lazily built */ \
CW(Type, non_nullable_map_rare_type) /* maybe be null, lazily built */ \
FW(Type, non_nullable_future_rare_type) /* maybe be null, lazily built */ \
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 4e327d9..bbd4a7a 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -48,7 +48,6 @@
# ........dart2js.dart.snapshot
# ........dartanalyzer.dart.snapshot
# ........dds.dart.snapshot
-# ........dartdev.dart.snapshot
# ........dartdoc.dart.snapshot
# ........dartfmt.dart.snapshot
# ........dartdevc.dart.snapshot
@@ -79,6 +78,7 @@
# ........dart2js_server_platform.dill
# ........dart2js_platform_strong.dill
# ........dart2js_server_platform_strong.dill
+# ........dartdev.dill
# ........vm_platform_strong.dill
# ........dev_compiler/
# ......async/
@@ -123,10 +123,6 @@
"../utils/dartanalyzer:generate_dartanalyzer_snapshot",
],
[
- "dartdev",
- "../utils/dartdev:dartdev",
- ],
- [
"dartdoc",
"../utils/dartdoc",
],
@@ -172,10 +168,6 @@
"../utils/dartanalyzer:generate_dartanalyzer_snapshot",
],
[
- "dartdev",
- "../utils/dartdev:dartdev",
- ],
- [
"dartdevc",
"../utils/dartdevc",
],
@@ -616,6 +608,16 @@
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
}
+copy("copy_dartdev_dill_files") {
+ visibility = [ ":create_common_sdk" ]
+ deps = [
+ ":copy_libraries",
+ "../utils/dartdev:dartdev",
+ ]
+ sources = [ "$root_out_dir/dartdev.dill" ]
+ outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
+}
+
copy("copy_dart2js_dill_files") {
visibility = [ ":create_full_sdk" ]
deps = [
@@ -890,6 +892,7 @@
":copy_analysis_summaries",
":copy_api_readme",
":copy_dart",
+ ":copy_dartdev_dill_files",
":copy_dartdoc_files",
":copy_headers",
":copy_libraries_dart",
diff --git a/tests/language/compile_time_constant/static2_test.dart b/tests/language/compile_time_constant/static2_test.dart
index 73b9dc5..70ae5c5 100644
--- a/tests/language/compile_time_constant/static2_test.dart
+++ b/tests/language/compile_time_constant/static2_test.dart
@@ -6,7 +6,7 @@
final int x;
const A.a1() : x = 'foo';
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
@@ -22,7 +22,7 @@
// [cfe] The type of parameter 'x', 'String' is not a subtype of the corresponding field's type, 'int'.
const A.a5(String x) : this.x = x;
// ^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
diff --git a/tests/language/compile_time_constant/static3_test.dart b/tests/language/compile_time_constant/static3_test.dart
index fff2773..eb101ac 100644
--- a/tests/language/compile_time_constant/static3_test.dart
+++ b/tests/language/compile_time_constant/static3_test.dart
@@ -6,7 +6,7 @@
final int x;
const A.a1() : x = 'foo';
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
@@ -22,7 +22,7 @@
// [cfe] The type of parameter 'x', 'String' is not a subtype of the corresponding field's type, 'int'.
const A.a5(String x) : this.x = x;
// ^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
diff --git a/tests/language/deferred/super_dependency_test.dart b/tests/language/deferred/super_dependency_test.dart
index 5879e56..cf5e811 100644
--- a/tests/language/deferred/super_dependency_test.dart
+++ b/tests/language/deferred/super_dependency_test.dart
@@ -8,7 +8,7 @@
import "package:expect/expect.dart";
// ^^^
-// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'foo'.
import "super_dependency_lib.dart" deferred as lib;
diff --git a/tests/language/mixin/illegal_super_use_test.dart b/tests/language/mixin/illegal_super_use_test.dart
index ca47645..17e4fad 100644
--- a/tests/language/mixin/illegal_super_use_test.dart
+++ b/tests/language/mixin/illegal_super_use_test.dart
@@ -11,22 +11,22 @@
super.toString();
super.foo();
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no method named 'foo'.
super.bar = 100;
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'bar'.
void inner() {
super.toString();
super.foo();
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no method named 'foo'.
super.bar = 100;
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'bar'.
}
inner();
@@ -35,11 +35,11 @@
super.toString();
super.foo();
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no method named 'foo'.
super.bar = 100;
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'bar'.
})();
diff --git a/tests/language/unsorted/external_test.dart b/tests/language/unsorted/external_test.dart
index 4cddabc..8418280 100644
--- a/tests/language/unsorted/external_test.dart
+++ b/tests/language/unsorted/external_test.dart
@@ -18,13 +18,8 @@
//^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD
- // fields can't be declared external
external var x01;
-//^^^^^^^^
-// [analyzer] SYNTACTIC_ERROR.EXTERNAL_FIELD
external int x02;
-//^^^^^^^^
-// [analyzer] SYNTACTIC_ERROR.EXTERNAL_FIELD
external f11() { }
// ^
@@ -74,13 +69,13 @@
}
external int t06(int i) { return 1; }
-// [error line 76, column 1, length 8]
+// [error line 71, column 1, length 8]
// [analyzer] SYNTACTIC_ERROR.EXTERNAL_METHOD_WITH_BODY
// [cfe] An external or native method can't have a body.
// ^
// [cfe] An external or native method can't have a body.
external int t07(int i) => i + 1;
-// [error line 82, column 1, length 8]
+// [error line 77, column 1, length 8]
// [analyzer] SYNTACTIC_ERROR.EXTERNAL_METHOD_WITH_BODY
// [cfe] An external or native method can't have a body.
// ^
diff --git a/tests/language_2/compile_time_constant/static2_test.dart b/tests/language_2/compile_time_constant/static2_test.dart
index 73b9dc5..70ae5c5 100644
--- a/tests/language_2/compile_time_constant/static2_test.dart
+++ b/tests/language_2/compile_time_constant/static2_test.dart
@@ -6,7 +6,7 @@
final int x;
const A.a1() : x = 'foo';
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
@@ -22,7 +22,7 @@
// [cfe] The type of parameter 'x', 'String' is not a subtype of the corresponding field's type, 'int'.
const A.a5(String x) : this.x = x;
// ^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
diff --git a/tests/language_2/compile_time_constant/static3_test.dart b/tests/language_2/compile_time_constant/static3_test.dart
index fff2773..eb101ac 100644
--- a/tests/language_2/compile_time_constant/static3_test.dart
+++ b/tests/language_2/compile_time_constant/static3_test.dart
@@ -6,7 +6,7 @@
final int x;
const A.a1() : x = 'foo';
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
@@ -22,7 +22,7 @@
// [cfe] The type of parameter 'x', 'String' is not a subtype of the corresponding field's type, 'int'.
const A.a5(String x) : this.x = x;
// ^
- // [analyzer] COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
// ^
// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
diff --git a/tests/language_2/deferred/super_dependency_test.dart b/tests/language_2/deferred/super_dependency_test.dart
index 5879e56..cf5e811 100644
--- a/tests/language_2/deferred/super_dependency_test.dart
+++ b/tests/language_2/deferred/super_dependency_test.dart
@@ -8,7 +8,7 @@
import "package:expect/expect.dart";
// ^^^
-// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'foo'.
import "super_dependency_lib.dart" deferred as lib;
diff --git a/tests/language_2/mixin/illegal_super_use_test.dart b/tests/language_2/mixin/illegal_super_use_test.dart
index ca47645..17e4fad 100644
--- a/tests/language_2/mixin/illegal_super_use_test.dart
+++ b/tests/language_2/mixin/illegal_super_use_test.dart
@@ -11,22 +11,22 @@
super.toString();
super.foo();
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no method named 'foo'.
super.bar = 100;
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'bar'.
void inner() {
super.toString();
super.foo();
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no method named 'foo'.
super.bar = 100;
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'bar'.
}
inner();
@@ -35,11 +35,11 @@
super.toString();
super.foo();
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no method named 'foo'.
super.bar = 100;
// ^^^
- // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
// [cfe] Superclass has no setter named 'bar'.
})();
diff --git a/tools/VERSION b/tools/VERSION
index 2322d9d..e885501 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 10
PATCH 0
-PRERELEASE 9
-PRERELEASE_PATCH 0
+PRERELEASE 10
+PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/utils/application_snapshot.gni b/utils/application_snapshot.gni
index 81ec5ee..372e74e 100644
--- a/utils/application_snapshot.gni
+++ b/utils/application_snapshot.gni
@@ -48,6 +48,9 @@
template("_application_snapshot") {
assert(defined(invoker.main_dart), "Must specify 'main_dart'")
assert(defined(invoker.training_args), "Must specify 'training_args'")
+ if (defined(invoker.dart_snapshot_kind)) {
+ dart_snapshot_kind = invoker.dart_snapshot_kind
+ }
snapshot_vm_args = []
if (defined(invoker.vm_args)) {
snapshot_vm_args = invoker.vm_args
diff --git a/utils/dartdev/BUILD.gn b/utils/dartdev/BUILD.gn
index b7ed0c2..13885c3 100644
--- a/utils/dartdev/BUILD.gn
+++ b/utils/dartdev/BUILD.gn
@@ -18,20 +18,21 @@
],
"list lines")
group("dartdev") {
- public_deps = [ ":copy_dartdev_snapshot" ]
+ public_deps = [ ":copy_dartdev_kernel" ]
}
-copy("copy_dartdev_snapshot") {
+copy("copy_dartdev_kernel") {
visibility = [ ":dartdev" ]
- public_deps = [ ":generate_dartdev_snapshot" ]
- sources = [ "$root_gen_dir/dartdev.dart.snapshot" ]
- outputs = [ "$root_out_dir/dartdev.dart.snapshot" ]
+ public_deps = [ ":generate_dartdev_kernel" ]
+ sources = [ "$root_gen_dir/dartdev.dill" ]
+ outputs = [ "$root_out_dir/dartdev.dill" ]
}
-application_snapshot("generate_dartdev_snapshot") {
+application_snapshot("generate_dartdev_kernel") {
+ dart_snapshot_kind = "kernel"
main_dart = "../../pkg/dartdev/bin/dartdev.dart"
- training_args = [ "--help" ]
+ training_args = []
deps = [ "../dds:dds" ]
inputs = dartdev_files + dartfix_files
- output = "$root_gen_dir/dartdev.dart.snapshot"
+ output = "$root_gen_dir/dartdev.dill"
}