Version 1.22.0-dev.7.0
Merge 45c3ecdf9c11296a0074416ed53b2e5434b45ab4 into dev
diff --git a/BUILD.gn b/BUILD.gn
index 67a6b43..7b7946c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -49,6 +49,7 @@
deps = [
"runtime/bin:dart_bootstrap($host_toolchain)",
"runtime/bin:dart_precompiled_runtime",
+ "runtime/bin:process_test",
"runtime/vm:patched_sdk",
]
}
diff --git a/DEPS b/DEPS
index 70e1d42..c896280 100644
--- a/DEPS
+++ b/DEPS
@@ -59,7 +59,7 @@
"csslib_tag" : "@0.13.2",
"dart2js_info_tag" : "@0.5.0",
"dart_services_rev" : "@7aea2574e6f3924bf409a80afb8ad52aa2be4f97",
- "dart_style_tag": "@0.2.13",
+ "dart_style_tag": "@0.2.14",
"dartdoc_tag" : "@v0.9.8+1",
"fixnum_tag": "@0.10.5",
"func_tag": "@0.1.0",
@@ -75,7 +75,7 @@
"isolate_tag": "@0.2.3",
"jinja2_rev": "@2222b31554f03e62600cd7e383376a7c187967a1",
"json_rpc_2_tag": "@2.0.2",
- "linter_rev": "@bde08fddf7a24e73d788e62b1725e4db95533269",
+ "linter_rev": "@393695e77bf95213130935e969e86140cb322667",
"logging_tag": "@0.11.3+1",
"markdown_tag": "@0.11.0",
"matcher_tag": "@0.12.0+2",
@@ -96,7 +96,7 @@
"pub_semver_tag": "@1.3.0",
"quiver_tag": "@0.22.0",
"resource_rev":"@a49101ba2deb29c728acba6fb86000a8f730f4b1",
- "root_certificates_rev": "@aed07942ce98507d2be28cbd29e879525410c7fc",
+ "root_certificates_rev": "@0068d8911140e591ebb750af296e81940a9906f5",
"scheduled_test_tag": "@0.12.6",
"shelf_static_tag": "@0.2.4",
"shelf_packages_handler_tag": "@1.0.0",
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 52043c8..1f513f4 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -745,7 +745,7 @@
ldflags = common_optimize_on_ldflags
} else {
cflags = [
- "-O1",
+ "-O2",
"-fdata-sections",
"-ffunction-sections",
]
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 771f9f1..869bd81 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -242,7 +242,7 @@
/**
* The controller that is notified when analysis is started.
*/
- StreamController<AnalysisContext> _onAnalysisStartedController;
+ StreamController<bool> _onAnalysisStartedController;
/**
* The controller that is notified when a single file has been analyzed.
@@ -492,9 +492,9 @@
}
/**
- * The stream that is notified when analysis of a context is started.
+ * The stream that is notified with `true` when analysis is started.
*/
- Stream<AnalysisContext> get onAnalysisStarted {
+ Stream<bool> get onAnalysisStarted {
return _onAnalysisStartedController.stream;
}
@@ -1084,7 +1084,7 @@
* Schedules analysis of the given context.
*/
void schedulePerformAnalysisOperation(AnalysisContext context) {
- _onAnalysisStartedController.add(context);
+ _onAnalysisStartedController.add(true);
scheduleOperation(new PerformAnalysisOperation(context, false));
}
@@ -1168,6 +1168,9 @@
* the [status] information.
*/
void sendStatusNotificationNew(nd.AnalysisStatus status) {
+ if (status.isAnalyzing) {
+ _onAnalysisStartedController.add(true);
+ }
if (_onAnalysisCompleteCompleter != null && !status.isAnalyzing) {
_onAnalysisCompleteCompleter.complete();
_onAnalysisCompleteCompleter = null;
@@ -1832,7 +1835,7 @@
analysisServer.fileContentOverlay,
sourceFactory,
analysisOptions);
- analysisDriver.name = folder.shortName;
+ analysisDriver.name = folder.path;
analysisDriver.status.listen((status) {
// TODO(scheglov) send server status
});
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
index 1214ea4..5768a88 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
@@ -500,6 +500,19 @@
}
@override
+ Object visitGenericFunctionType(GenericFunctionType node) {
+ computer._addRegion_token(
+ node.functionKeyword, HighlightRegionType.KEYWORD);
+ return super.visitGenericFunctionType(node);
+ }
+
+ @override
+ Object visitGenericTypeAlias(GenericTypeAlias node) {
+ computer._addRegion_token(node.typedefKeyword, HighlightRegionType.KEYWORD);
+ return super.visitGenericTypeAlias(node);
+ }
+
+ @override
Object visitHideCombinator(HideCombinator node) {
computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN);
return super.visitHideCombinator(node);
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights2.dart b/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
index 630b41f..184c35d 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
@@ -591,6 +591,19 @@
}
@override
+ Object visitGenericFunctionType(GenericFunctionType node) {
+ computer._addRegion_token(
+ node.functionKeyword, HighlightRegionType.KEYWORD);
+ return super.visitGenericFunctionType(node);
+ }
+
+ @override
+ Object visitGenericTypeAlias(GenericTypeAlias node) {
+ computer._addRegion_token(node.typedefKeyword, HighlightRegionType.KEYWORD);
+ return super.visitGenericTypeAlias(node);
+ }
+
+ @override
Object visitHideCombinator(HideCombinator node) {
computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN);
return super.visitHideCombinator(node);
diff --git a/pkg/analysis_server/lib/src/computer/computer_outline.dart b/pkg/analysis_server/lib/src/computer/computer_outline.dart
index a89ff02..f72cbe9 100644
--- a/pkg/analysis_server/lib/src/computer/computer_outline.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_outline.dart
@@ -40,7 +40,7 @@
FieldDeclaration fieldDeclaration = classMember;
VariableDeclarationList fields = fieldDeclaration.fields;
if (fields != null) {
- TypeName fieldType = fields.type;
+ TypeAnnotation fieldType = fields.type;
String fieldTypeName = _safeToSource(fieldType);
for (VariableDeclaration field in fields.variables) {
classContents.add(_newVariableOutline(fieldTypeName,
@@ -67,7 +67,7 @@
TopLevelVariableDeclaration fieldDeclaration = unitMember;
VariableDeclarationList fields = fieldDeclaration.variables;
if (fields != null) {
- TypeName fieldType = fields.type;
+ TypeAnnotation fieldType = fields.type;
String fieldTypeName = _safeToSource(fieldType);
for (VariableDeclaration field in fields.variables) {
unitContents.add(_newVariableOutline(
@@ -251,7 +251,7 @@
}
Outline _newFunctionOutline(FunctionDeclaration function, bool isStatic) {
- TypeName returnType = function.returnType;
+ TypeAnnotation returnType = function.returnType;
SimpleIdentifier nameNode = function.name;
String name = nameNode.name;
FunctionExpression functionExpression = function.functionExpression;
@@ -285,7 +285,7 @@
}
Outline _newFunctionTypeAliasOutline(FunctionTypeAlias node) {
- TypeName returnType = node.returnType;
+ TypeAnnotation returnType = node.returnType;
SimpleIdentifier nameNode = node.name;
String name = nameNode.name;
_SourceRegion sourceRegion = _getSourceRegion(node);
@@ -306,7 +306,7 @@
}
Outline _newMethodOutline(MethodDeclaration method) {
- TypeName returnType = method.returnType;
+ TypeAnnotation returnType = method.returnType;
SimpleIdentifier nameNode = method.name;
String name = nameNode.name;
FormalParameterList parameters = method.parameters;
diff --git a/pkg/analysis_server/lib/src/domain_diagnostic.dart b/pkg/analysis_server/lib/src/domain_diagnostic.dart
index 1f2609c..d91aacf 100644
--- a/pkg/analysis_server/lib/src/domain_diagnostic.dart
+++ b/pkg/analysis_server/lib/src/domain_diagnostic.dart
@@ -11,6 +11,7 @@
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analyzer/src/context/cache.dart';
import 'package:analyzer/src/context/context.dart';
+import 'package:analyzer/src/dart/analysis/driver.dart' as nd;
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_collection.dart';
@@ -38,15 +39,19 @@
/// Answer the `diagnostic.diagnostics` request.
Response computeDiagnostics(Request request) {
- List<ContextData> infos = <ContextData>[];
- for (AnalysisContext context in server.analysisContexts) {
- infos.add(extractData(context));
+ List<ContextData> contexts = <ContextData>[];
+ if (server.options.enableNewAnalysisDriver) {
+ contexts = server.driverMap.values.map(extractDataFromDriver).toList();
+ } else {
+ for (AnalysisContext context in server.analysisContexts) {
+ contexts.add(extractDataFromContext(context));
+ }
}
- return new DiagnosticGetDiagnosticsResult(infos).toResponse(request.id);
+ return new DiagnosticGetDiagnosticsResult(contexts).toResponse(request.id);
}
/// Extract context data from the given [context].
- ContextData extractData(AnalysisContext context) {
+ ContextData extractDataFromContext(AnalysisContext context) {
int explicitFiles = 0;
int implicitFiles = 0;
int workItems = 0;
@@ -84,6 +89,14 @@
workItems, exceptions.toList());
}
+ /// Extract context data from the given [driver].
+ ContextData extractDataFromDriver(nd.AnalysisDriver driver) {
+ int explicitFileCount = driver.addedFiles.length;
+ int knownFileCount = driver.knownFiles.length;
+ return new ContextData(driver.name, explicitFileCount,
+ knownFileCount - explicitFileCount, driver.numberOfFilesToAnalyze, []);
+ }
+
@override
Response handleRequest(Request request) {
try {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart
index 0db3193..774727d 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/label_contributor.dart
@@ -103,7 +103,7 @@
}
@override
- void declaredLocalVar(SimpleIdentifier name, TypeName type) {
+ void declaredLocalVar(SimpleIdentifier name, TypeAnnotation type) {
// ignored
}
@@ -113,7 +113,7 @@
}
@override
- void declaredParam(SimpleIdentifier name, TypeName type) {
+ void declaredParam(SimpleIdentifier name, TypeAnnotation type) {
// ignored
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart
index e2b3a46..7b908a8 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart
@@ -95,13 +95,13 @@
void declaredLabel(Label label, bool isCaseLabel) {}
@override
- void declaredLocalVar(SimpleIdentifier name, TypeName type) {}
+ void declaredLocalVar(SimpleIdentifier name, TypeAnnotation type) {}
@override
void declaredMethod(MethodDeclaration declaration) {}
@override
- void declaredParam(SimpleIdentifier name, TypeName type) {}
+ void declaredParam(SimpleIdentifier name, TypeAnnotation type) {}
@override
void declaredTopLevelVar(
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart
index adf26c7..e290304 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart
@@ -39,11 +39,11 @@
void declaredLabel(Label label, bool isCaseLabel);
- void declaredLocalVar(SimpleIdentifier name, TypeName type);
+ void declaredLocalVar(SimpleIdentifier name, TypeAnnotation type);
void declaredMethod(MethodDeclaration declaration);
- void declaredParam(SimpleIdentifier name, TypeName type);
+ void declaredParam(SimpleIdentifier name, TypeAnnotation type);
void declaredTopLevelVar(
VariableDeclarationList varList, VariableDeclaration varDecl);
@@ -128,7 +128,7 @@
@override
void visitForEachStatement(ForEachStatement node) {
SimpleIdentifier id;
- TypeName type;
+ TypeAnnotation type;
DeclaredIdentifier loopVar = node.loopVariable;
if (loopVar != null) {
id = loopVar.identifier;
@@ -233,7 +233,7 @@
} else if (param is NormalFormalParameter) {
normalParam = param;
}
- TypeName type = null;
+ TypeAnnotation type = null;
if (normalParam is FieldFormalParameter) {
type = normalParam.type;
} else if (normalParam is FunctionTypedFormalParameter) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
index 41e50c5..ae66900 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
@@ -166,7 +166,7 @@
if (optype.includeReturnValueSuggestions &&
(!optype.inStaticMethodBody || fieldDecl.isStatic)) {
bool deprecated = isDeprecated(fieldDecl) || isDeprecated(varDecl);
- TypeName typeName = fieldDecl.fields.type;
+ TypeAnnotation typeName = fieldDecl.fields.type;
_addLocalSuggestion_includeReturnValueSuggestions(
fieldDecl.documentationComment,
varDecl.name,
@@ -182,7 +182,7 @@
void declaredFunction(FunctionDeclaration declaration) {
if (optype.includeReturnValueSuggestions ||
optype.includeVoidReturnSuggestions) {
- TypeName typeName = declaration.returnType;
+ TypeAnnotation typeName = declaration.returnType;
protocol.ElementKind elemKind;
int relevance = DART_RELEVANCE_DEFAULT;
if (declaration.isGetter) {
@@ -233,7 +233,7 @@
}
@override
- void declaredLocalVar(SimpleIdentifier id, TypeName typeName) {
+ void declaredLocalVar(SimpleIdentifier id, TypeAnnotation typeName) {
if (optype.includeReturnValueSuggestions) {
_addLocalSuggestion_includeReturnValueSuggestions(
null, id, typeName, protocol.ElementKind.LOCAL_VARIABLE,
@@ -248,7 +248,7 @@
(!optype.inStaticMethodBody || declaration.isStatic)) {
protocol.ElementKind elemKind;
FormalParameterList param;
- TypeName typeName = declaration.returnType;
+ TypeAnnotation typeName = declaration.returnType;
int relevance = DART_RELEVANCE_DEFAULT;
if (declaration.isGetter) {
elemKind = protocol.ElementKind.GETTER;
@@ -283,7 +283,7 @@
}
@override
- void declaredParam(SimpleIdentifier id, TypeName typeName) {
+ void declaredParam(SimpleIdentifier id, TypeAnnotation typeName) {
if (optype.includeReturnValueSuggestions) {
_addLocalSuggestion_includeReturnValueSuggestions(
null, id, typeName, protocol.ElementKind.PARAMETER,
@@ -306,7 +306,7 @@
}
void _addLocalSuggestion(Comment documentationComment, SimpleIdentifier id,
- TypeName typeName, protocol.ElementKind elemKind,
+ TypeAnnotation typeName, protocol.ElementKind elemKind,
{bool isAbstract: false,
bool isDeprecated: false,
ClassDeclaration classDecl,
@@ -377,7 +377,7 @@
void _addLocalSuggestion_includeReturnValueSuggestions(
Comment documentationComment,
SimpleIdentifier id,
- TypeName typeName,
+ TypeAnnotation typeName,
protocol.ElementKind elemKind,
{bool isAbstract: false,
bool isDeprecated: false,
@@ -417,7 +417,7 @@
void _addLocalSuggestion_includeTypeNameSuggestions(
Comment documentationComment,
SimpleIdentifier id,
- TypeName typeName,
+ TypeAnnotation typeName,
protocol.ElementKind elemKind,
{bool isAbstract: false,
bool isDeprecated: false,
@@ -443,7 +443,7 @@
.map((FormalParameter param) => param.identifier.name)
.toList();
suggestion.parameterTypes = paramList.map((FormalParameter param) {
- TypeName type = null;
+ TypeAnnotation type = null;
if (param is DefaultFormalParameter) {
NormalFormalParameter child = param.parameter;
if (child is SimpleFormalParameter) {
@@ -460,11 +460,15 @@
if (type == null) {
return 'dynamic';
}
- Identifier typeId = type.name;
- if (typeId == null) {
- return 'dynamic';
+ if (type is TypeName) {
+ Identifier typeId = type.name;
+ if (typeId == null) {
+ return 'dynamic';
+ }
+ return typeId.name;
}
- return typeId.name;
+ // TODO(brianwilkerson) Support function types.
+ return 'dynamic';
}).toList();
suggestion.requiredParameterCount = paramList
.where((FormalParameter param) => param is! DefaultFormalParameter)
@@ -473,8 +477,8 @@
.any((FormalParameter param) => param.kind == ParameterKind.NAMED);
}
- bool _isVoid(TypeName returnType) {
- if (returnType != null) {
+ bool _isVoid(TypeAnnotation returnType) {
+ if (returnType is TypeName) {
Identifier id = returnType.name;
if (id != null && id.name == 'void') {
return true;
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
index da0e6a0..c9954d5 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
@@ -126,15 +126,6 @@
OpType._();
/**
- * Indicate whether only type names should be suggested
- */
- bool get includeOnlyNamedArgumentSuggestions =>
- includeNamedArgumentSuggestions &&
- !includeTypeNameSuggestions &&
- !includeReturnValueSuggestions &&
- !includeVoidReturnSuggestions;
-
- /**
* Return `true` if free standing identifiers should be suggested
*/
bool get includeIdentifiers {
@@ -148,6 +139,15 @@
/**
* Indicate whether only type names should be suggested
*/
+ bool get includeOnlyNamedArgumentSuggestions =>
+ includeNamedArgumentSuggestions &&
+ !includeTypeNameSuggestions &&
+ !includeReturnValueSuggestions &&
+ !includeVoidReturnSuggestions;
+
+ /**
+ * Indicate whether only type names should be suggested
+ */
bool get includeOnlyTypeNameSuggestions =>
includeTypeNameSuggestions &&
!includeNamedArgumentSuggestions &&
@@ -845,9 +845,9 @@
@override
void visitTypeArgumentList(TypeArgumentList node) {
- NodeList<TypeName> arguments = node.arguments;
- for (TypeName typeName in arguments) {
- if (identical(entity, typeName)) {
+ NodeList<TypeAnnotation> arguments = node.arguments;
+ for (TypeAnnotation type in arguments) {
+ if (identical(entity, type)) {
optype.includeTypeNameSuggestions = true;
break;
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
index d535ef4..1921bfa 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
@@ -161,7 +161,7 @@
@override
void declaredFunction(FunctionDeclaration declaration) {
if (declaration.name.name == targetName) {
- TypeName typeName = declaration.returnType;
+ TypeAnnotation typeName = declaration.returnType;
if (typeName != null) {
typeFound = typeName.type;
}
@@ -172,7 +172,7 @@
@override
void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {
if (declaration.name.name == targetName) {
- TypeName typeName = declaration.returnType;
+ TypeAnnotation typeName = declaration.returnType;
if (typeName != null) {
typeFound = typeName.type;
}
@@ -189,7 +189,7 @@
}
@override
- void declaredLocalVar(SimpleIdentifier name, TypeName type) {
+ void declaredLocalVar(SimpleIdentifier name, TypeAnnotation type) {
if (name.name == targetName) {
typeFound = name.bestType;
finished();
@@ -199,7 +199,7 @@
@override
void declaredMethod(MethodDeclaration declaration) {
if (declaration.name.name == targetName) {
- TypeName typeName = declaration.returnType;
+ TypeAnnotation typeName = declaration.returnType;
if (typeName != null) {
typeFound = typeName.type;
}
@@ -208,7 +208,7 @@
}
@override
- void declaredParam(SimpleIdentifier name, TypeName type) {
+ void declaredParam(SimpleIdentifier name, TypeAnnotation type) {
if (name.name == targetName) {
// Type provided by the element in computeFull above
finished();
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart b/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
index 0cba871..a3ec936 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
@@ -34,7 +34,7 @@
protocol.Element createLocalElement(
Source source, protocol.ElementKind kind, SimpleIdentifier id,
{String parameters,
- TypeName returnType,
+ TypeAnnotation returnType,
bool isAbstract: false,
bool isDeprecated: false}) {
String name;
@@ -64,7 +64,7 @@
CompletionSuggestion createLocalFieldSuggestion(
Source source, FieldDeclaration fieldDecl, VariableDeclaration varDecl) {
bool deprecated = isDeprecated(fieldDecl) || isDeprecated(varDecl);
- TypeName type = fieldDecl.fields.type;
+ TypeAnnotation type = fieldDecl.fields.type;
return createLocalSuggestion(
varDecl.name, deprecated, DART_RELEVANCE_LOCAL_FIELD, type,
classDecl: fieldDecl.parent,
@@ -78,7 +78,7 @@
* suggestion or `null` if it could not be created.
*/
CompletionSuggestion createLocalSuggestion(SimpleIdentifier id,
- bool isDeprecated, int defaultRelevance, TypeName returnType,
+ bool isDeprecated, int defaultRelevance, TypeAnnotation returnType,
{ClassDeclaration classDecl,
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
protocol.Element element}) {
@@ -129,24 +129,29 @@
/**
* Return the name for the given [type].
*/
-String nameForType(TypeName type) {
+String nameForType(TypeAnnotation type) {
if (type == NO_RETURN_TYPE) {
return null;
}
if (type == null) {
return DYNAMIC;
}
- Identifier id = type.name;
- if (id == null) {
- return DYNAMIC;
+ if (type is TypeName) {
+ Identifier id = type.name;
+ if (id == null) {
+ return DYNAMIC;
+ }
+ String name = id.name;
+ if (name == null || name.length <= 0) {
+ return DYNAMIC;
+ }
+ TypeArgumentList typeArgs = type.typeArguments;
+ if (typeArgs != null) {
+ //TODO (danrubel) include type arguments
+ }
+ return name;
+ } else if (type is GenericFunctionType) {
+ // TODO(brianwilkerson) Implement this.
}
- String name = id.name;
- if (name == null || name.length <= 0) {
- return DYNAMIC;
- }
- TypeArgumentList typeArgs = type.typeArguments;
- if (typeArgs != null) {
- //TODO (danrubel) include type arguments
- }
- return name;
+ return DYNAMIC;
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart
index 2c4d913..98b7f4b 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart
@@ -56,7 +56,10 @@
strName = _getStringName(node.expression as Identifier);
}
} else if (node is VariableDeclarationList) {
- strName = _getStringName(node.type.name);
+ TypeAnnotation typeAnnotation = node.type;
+ if (typeAnnotation is TypeName) {
+ strName = _getStringName(typeAnnotation.name);
+ }
} else if (node is TopLevelVariableDeclaration) {
// The parser parses 'Foo ' and 'Foo ;' differently, resulting in the
// following.
@@ -64,8 +67,11 @@
// 'Foo ;': TopLevelVariableDeclaration with type null, and a first
// variable of 'Foo'
VariableDeclarationList varDeclarationList = node.variables;
- if (varDeclarationList.type != null) {
- strName = _getStringName(varDeclarationList.type.name);
+ TypeAnnotation typeAnnotation = varDeclarationList.type;
+ if (typeAnnotation != null) {
+ if (typeAnnotation is TypeName) {
+ strName = _getStringName(typeAnnotation.name);
+ }
} else {
NodeList<VariableDeclaration> varDeclarations =
varDeclarationList.variables;
diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
index ebd7ca3..27cc2cf 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -505,7 +505,9 @@
getter = n;
break;
}
- if (n is SimpleIdentifier || n is TypeName || n is TypeArgumentList) {
+ if (n is SimpleIdentifier ||
+ n is TypeAnnotation ||
+ n is TypeArgumentList) {
continue;
}
break;
@@ -571,7 +573,7 @@
if (n is SimpleIdentifier ||
n is VariableDeclaration ||
n is VariableDeclarationList ||
- n is TypeName ||
+ n is TypeAnnotation ||
n is TypeArgumentList) {
continue;
}
@@ -1564,7 +1566,7 @@
return;
}
// we need a type
- TypeName typeNode = declarationList.type;
+ TypeAnnotation typeNode = declarationList.type;
if (typeNode == null) {
_coverageMarker();
return;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index c96165d..325f723 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -570,7 +570,7 @@
AstNode variableList = declaration.parent;
if (variableList is VariableDeclarationList &&
variableList.variables.length == 1) {
- TypeName typeNode = variableList.type;
+ TypeAnnotation typeNode = variableList.type;
if (typeNode != null) {
Expression initializer = coveredNode;
DartType newType = initializer.bestType;
@@ -1436,7 +1436,7 @@
void _addFix_illegalAsyncReturnType() {
// prepare the existing type
- TypeName typeName = node.getAncestor((n) => n is TypeName);
+ TypeAnnotation typeName = node.getAncestor((n) => n is TypeAnnotation);
_replaceTypeWithFuture(typeName);
// add proposal
_addFix(DartFixKind.REPLACE_RETURN_TYPE_FUTURE, []);
@@ -2825,7 +2825,7 @@
}
}
- void _replaceTypeWithFuture(TypeName typeName) {
+ void _replaceTypeWithFuture(TypeAnnotation typeName) {
InterfaceType futureType = context.typeProvider.futureType;
// validate the type
DartType type = typeName?.type;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
index e904e14..6e3c2cb 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
@@ -859,6 +859,15 @@
}
@override
+ Object visitGenericFunctionType(GenericFunctionType node) {
+ super.visitGenericFunctionType(node);
+ if (_isFirstSelectedNode(node)) {
+ invalidSelection('Cannot extract a single type reference.');
+ }
+ return null;
+ }
+
+ @override
Object visitSimpleIdentifier(SimpleIdentifier node) {
super.visitSimpleIdentifier(node);
if (_isFirstSelectedNode(node)) {
diff --git a/pkg/analysis_server/lib/src/status/ast_writer.dart b/pkg/analysis_server/lib/src/status/ast_writer.dart
index 1b292d6..b32886d 100644
--- a/pkg/analysis_server/lib/src/status/ast_writer.dart
+++ b/pkg/analysis_server/lib/src/status/ast_writer.dart
@@ -141,7 +141,7 @@
properties['value'] = node.value;
} else if (node is SuperConstructorInvocation) {
properties['static element'] = node.staticElement;
- } else if (node is TypeName) {
+ } else if (node is TypeAnnotation) {
properties['type'] = node.type;
} else if (node is VariableDeclarationList) {
properties['keyword'] = node.keyword;
@@ -195,7 +195,7 @@
return node.name.name;
} else if (node is TopLevelVariableDeclaration) {
return _getNames(node.variables);
- } else if (node is TypeName) {
+ } else if (node is TypeAnnotation) {
return node.toSource();
} else if (node is TypeParameter) {
return node.name.name;
diff --git a/pkg/analysis_server/test/domain_diagnostic_test.dart b/pkg/analysis_server/test/domain_diagnostic_test.dart
index 1842045..fcaf755 100644
--- a/pkg/analysis_server/test/domain_diagnostic_test.dart
+++ b/pkg/analysis_server/test/domain_diagnostic_test.dart
@@ -5,86 +5,72 @@
library test.domain.diagnostic;
import 'package:analysis_server/plugin/protocol/protocol.dart';
-import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/domain_diagnostic.dart';
-import 'package:analysis_server/src/plugin/server_plugin.dart';
-import 'package:analyzer/file_system/memory_file_system.dart';
-import 'package:analyzer/instrumentation/instrumentation.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/sdk.dart';
-import 'package:plugin/manager.dart';
-import 'package:plugin/plugin.dart';
import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'mock_sdk.dart';
-import 'mocks.dart';
+import 'analysis_abstract.dart';
main() {
- AnalysisServer server;
- DiagnosticDomainHandler handler;
- MemoryResourceProvider resourceProvider;
+ defineReflectiveSuite(() {
+ defineReflectiveTests(DiagnosticDomainTest);
+ defineReflectiveTests(DiagnosticDomainTest_Driver);
+ });
+}
- void processRequiredPlugins(ServerPlugin serverPlugin) {
- List<Plugin> plugins = <Plugin>[];
- plugins.addAll(AnalysisEngine.instance.requiredPlugins);
- plugins.add(serverPlugin);
-
- ExtensionManager manager = new ExtensionManager();
- manager.processPlugins(plugins);
+@reflectiveTest
+class DiagnosticDomainTest extends AbstractAnalysisTest {
+ @override
+ void setUp() {
+ super.setUp();
+ handler = new DiagnosticDomainHandler(server);
+ server.handlers = [handler];
}
- setUp(() {
- ServerPlugin serverPlugin = new ServerPlugin();
- processRequiredPlugins(serverPlugin);
- //
- // Create the server
- //
- var serverChannel = new MockServerChannel();
- resourceProvider = new MemoryResourceProvider();
- // Create an SDK in the mock file system.
- new MockSdk(resourceProvider: resourceProvider);
- server = new AnalysisServer(
- serverChannel,
- resourceProvider,
- new MockPackageMapProvider(),
- null,
- serverPlugin,
- new AnalysisServerOptions(),
- new DartSdkManager('/', false),
- InstrumentationService.NULL_SERVICE);
- handler = new DiagnosticDomainHandler(server);
- });
+ test_getDiagnostics() async {
+ String file = '/project/bin/test.dart';
+ resourceProvider.newFile('/project/pubspec.yaml', 'name: project');
+ resourceProvider.newFile(file, 'main() {}');
- group('DiagnosticDomainHandler', () {
- test('getDiagnostics', () async {
- String file = '/project/bin/test.dart';
- resourceProvider.newFile('/project/pubspec.yaml', 'name: project');
- resourceProvider.newFile(file, 'main() {}');
+ server.setAnalysisRoots('0', ['/project/'], [], {});
- server.setAnalysisRoots('0', ['/project/'], [], {});
+ await server.onAnalysisComplete;
- await server.onAnalysisComplete;
+ var request = new DiagnosticGetDiagnosticsParams().toRequest('0');
+ var response = handler.handleRequest(request);
+ var result = new DiagnosticGetDiagnosticsResult.fromResponse(response);
- var request = new DiagnosticGetDiagnosticsParams().toRequest('0');
- var response = handler.handleRequest(request);
+ expect(result.contexts, hasLength(1));
- int fileCount = 1 /* test.dart */;
+ ContextData context = result.contexts[0];
+ expect(context.name, '/project');
+ expect(context.explicitFileCount, 1); /* test.dart */
- Map json = response.toJson()[Response.RESULT];
- expect(json['contexts'], hasLength(1));
- var context = json['contexts'][0];
- expect(context['name'], '/project');
- expect(context['explicitFileCount'], fileCount);
+ if (enableNewAnalysisDriver) {
+ // dart:core (although it should not be here)
+ expect(context.implicitFileCount, 1);
+ } else {
// dart:core dart:async dart:math dart:_internal
- expect(context['implicitFileCount'], 4);
- expect(context['workItemQueueLength'], isNotNull);
- });
+ expect(context.implicitFileCount, 4);
+ }
- test('getDiagnostics - (no root)', () async {
- var request = new DiagnosticGetDiagnosticsParams().toRequest('0');
- var response = handler.handleRequest(request);
- Map json = response.toJson()[Response.RESULT];
- expect(json['contexts'], hasLength(0));
- });
- });
+ expect(context.workItemQueueLength, isNotNull);
+ }
+
+ test_getDiagnostics_noRoot() async {
+ var request = new DiagnosticGetDiagnosticsParams().toRequest('0');
+ var response = handler.handleRequest(request);
+ var result = new DiagnosticGetDiagnosticsResult.fromResponse(response);
+ expect(result.contexts, isEmpty);
+ }
+}
+
+@reflectiveTest
+class DiagnosticDomainTest_Driver extends DiagnosticDomainTest {
+ @override
+ void setUp() {
+ enableNewAnalysisDriver = true;
+ generateSummaryFiles = true;
+ super.setUp();
+ }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/local_declaration_visitor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_declaration_visitor_test.dart
index fe3456d..4e4e727 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_declaration_visitor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_declaration_visitor_test.dart
@@ -73,7 +73,7 @@
void declaredLabel(Label label, bool isCaseLabel) {}
@override
- void declaredLocalVar(SimpleIdentifier name, TypeName type) {
+ void declaredLocalVar(SimpleIdentifier name, TypeAnnotation type) {
expect(name, isNotNull);
}
@@ -81,7 +81,7 @@
void declaredMethod(MethodDeclaration declaration) {}
@override
- void declaredParam(SimpleIdentifier name, TypeName type) {}
+ void declaredParam(SimpleIdentifier name, TypeAnnotation type) {}
@override
void declaredTopLevelVar(
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index 78b3c06..ba966a3 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -254,7 +254,7 @@
* An as expression.
*
* asExpression ::=
- * [Expression] 'as' [TypeName]
+ * [Expression] 'as' [TypeAnnotation]
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -281,14 +281,14 @@
void set expression(Expression expression);
/**
- * Return the name of the type being cast to.
+ * Return the type being cast to.
*/
- TypeName get type;
+ TypeAnnotation get type;
/**
- * Set the name of the type being cast to to the given [name].
+ * Set the type being cast to to the given [type].
*/
- void set type(TypeName name);
+ void set type(TypeAnnotation type);
}
/**
@@ -556,7 +556,14 @@
/**
* An object that can be used to visit an AST structure.
*
- * Clients may extend or implement this class.
+ * Clients may not extend, implement or mix-in this class. There are classes
+ * that implement this interface that provide useful default behaviors in
+ * `package:analyzer/dart/ast/visitor.dart`. A couple of the most useful include
+ * * SimpleAstVisitor which implements every visit method by doing nothing,
+ * * RecursiveAstVisitor which will cause every node in a structure to be
+ * visited, and
+ * * ThrowingAstVisitor which implements every visit method by throwing an
+ * exception.
*/
abstract class AstVisitor<R> {
R visitAdjacentStrings(AdjacentStrings node);
@@ -659,6 +666,10 @@
R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node);
+ R visitGenericFunctionType(GenericFunctionType node);
+
+ R visitGenericTypeAlias(GenericTypeAlias node);
+
R visitHideCombinator(HideCombinator node);
R visitIfStatement(IfStatement node);
@@ -1097,13 +1108,13 @@
* Return the type of exceptions caught by this catch clause, or `null` if
* this catch clause catches every type of exception.
*/
- TypeName get exceptionType;
+ TypeAnnotation get exceptionType;
/**
* Set the type of exceptions caught by this catch clause to the given
* [exceptionType].
*/
- void set exceptionType(TypeName exceptionType);
+ void set exceptionType(TypeAnnotation exceptionType);
/**
* Return the left parenthesis, or `null` if there is no 'catch' keyword.
@@ -2187,12 +2198,12 @@
* Return the name of the declared type of the parameter, or `null` if the
* parameter does not have a declared type.
*/
- TypeName get type;
+ TypeAnnotation get type;
/**
- * Set the name of the declared type of the parameter to the given [typeName].
+ * Set the declared type of the parameter to the given [type].
*/
- void set type(TypeName typeName);
+ void set type(TypeAnnotation type);
}
/**
@@ -2789,7 +2800,7 @@
* A field formal parameter.
*
* fieldFormalParameter ::=
- * ('final' [TypeName] | 'const' [TypeName] | 'var' | [TypeName])?
+ * ('final' [TypeAnnotation] | 'const' [TypeAnnotation] | 'var' | [TypeAnnotation])?
* 'this' '.' [SimpleIdentifier] ([TypeParameterList]? [FormalParameterList])?
*
* Clients may not extend, implement or mix-in this class.
@@ -2840,17 +2851,16 @@
void set thisKeyword(Token token);
/**
- * Return the name of the declared type of the parameter, or `null` if the
- * parameter does not have a declared type. Note that if this is a
- * function-typed field formal parameter this is the return type of the
- * function.
+ * Return the declared type of the parameter, or `null` if the parameter does
+ * not have a declared type. Note that if this is a function-typed field
+ * formal parameter this is the return type of the function.
*/
- TypeName get type;
+ TypeAnnotation get type;
/**
- * Set the name of the declared type of the parameter to the given [typeName].
+ * Set the declared type of the parameter to the given [type].
*/
- void set type(TypeName typeName);
+ void set type(TypeAnnotation type);
/**
* Return the type parameters associated with this method, or `null` if this
@@ -3348,12 +3358,12 @@
* Return the return type of the function, or `null` if no return type was
* declared.
*/
- TypeName get returnType;
+ TypeAnnotation get returnType;
/**
- * Set the return type of the function to the given [returnType].
+ * Set the return type of the function to the given [type].
*/
- void set returnType(TypeName returnType);
+ void set returnType(TypeAnnotation type);
}
/**
@@ -3506,7 +3516,7 @@
* functionPrefix [TypeParameterList]? [FormalParameterList] ';'
*
* functionPrefix ::=
- * [TypeName]? [SimpleIdentifier]
+ * [TypeAnnotation]? [SimpleIdentifier]
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -3523,16 +3533,15 @@
void set parameters(FormalParameterList parameters);
/**
- * Return the name of the return type of the function type being defined, or
- * `null` if no return type was given.
+ * Return the return type of the function type being defined, or `null` if no
+ * return type was given.
*/
- TypeName get returnType;
+ TypeAnnotation get returnType;
/**
- * Set the name of the return type of the function type being defined to the
- * given [typeName].
+ * Set the return type of the function type being defined to the given [type].
*/
- void set returnType(TypeName typeName);
+ void set returnType(TypeAnnotation type);
/**
* Return the type parameters for the function type, or `null` if the function
@@ -3551,7 +3560,7 @@
* A function-typed formal parameter.
*
* functionSignature ::=
- * [TypeName]? [SimpleIdentifier] [TypeParameterList]? [FormalParameterList]
+ * [TypeAnnotation]? [SimpleIdentifier] [TypeParameterList]? [FormalParameterList]
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -3583,12 +3592,12 @@
* Return the return type of the function, or `null` if the function does not
* have a return type.
*/
- TypeName get returnType;
+ TypeAnnotation get returnType;
/**
* Set the return type of the function to the given [type].
*/
- void set returnType(TypeName type);
+ void set returnType(TypeAnnotation type);
/**
* Return the type parameters associated with this function, or `null` if
@@ -3604,6 +3613,128 @@
}
/**
+ * An anonymous function type.
+ *
+ * functionType ::=
+ * [TypeAnnotation]? 'Function' [TypeParameterList]? [FormalParameterList]
+ *
+ * where the FormalParameterList is being used to represent the following
+ * grammar, despite the fact that FormalParameterList can represent a much
+ * larger grammar than the one below. This is done in order to simplify the
+ * implementation.
+ *
+ * parameterTypeList ::=
+ * () |
+ * ( normalParameterTypes ,? ) |
+ * ( normalParameterTypes , optionalParameterTypes ) |
+ * ( optionalParameterTypes )
+ * namedParameterTypes ::=
+ * { namedParameterType (, namedParameterType)* ,? }
+ * namedParameterType ::=
+ * [TypeAnnotation]? [SimpleIdentifier]
+ * normalParameterTypes ::=
+ * normalParameterType (, normalParameterType)*
+ * normalParameterType ::=
+ * [TypeAnnotation] [SimpleIdentifier]?
+ * optionalParameterTypes ::=
+ * optionalPositionalParameterTypes | namedParameterTypes
+ * optionalPositionalParameterTypes ::=
+ * [ normalParameterTypes ,? ]
+ *
+ * Clients may not extend, implement or mix-in this class.
+ */
+abstract class GenericFunctionType extends TypeAnnotation {
+ /**
+ * Return the keyword 'Function'.
+ */
+ Token get functionKeyword;
+
+ /**
+ * Set the keyword 'Function' to the given [token].
+ */
+ void set functionKeyword(Token token);
+
+ /**
+ * Return the parameters associated with the function type.
+ */
+ FormalParameterList get parameters;
+
+ /**
+ * Set the parameters associated with the function type to the given list of
+ * [parameters].
+ */
+ void set parameters(FormalParameterList parameters);
+
+ /**
+ * Return the return type of the function type being defined, or `null` if
+ * no return type was given.
+ */
+ TypeAnnotation get returnType;
+
+ /**
+ * Set the return type of the function type being defined to the given[type].
+ */
+ void set returnType(TypeAnnotation type);
+
+ /**
+ * Return the type parameters for the function type, or `null` if the function
+ * type does not have any type parameters.
+ */
+ TypeParameterList get typeParameters;
+
+ /**
+ * Set the type parameters for the function type to the given list of
+ * [typeParameters].
+ */
+ void set typeParameters(TypeParameterList typeParameters);
+}
+
+/**
+ * A generic type alias.
+ *
+ * functionTypeAlias ::=
+ * metadata 'typedef' [SimpleIdentifier] [TypeParameterList]? = [FunctionType] ';'
+ *
+ * Clients may not extend, implement or mix-in this class.
+ */
+abstract class GenericTypeAlias extends TypeAlias {
+ /**
+ * Return the equal sign separating the name being defined from the function
+ * type.
+ */
+ Token get equals;
+
+ /**
+ * Set the equal sign separating the name being defined from the function type
+ * to the given [token].
+ */
+ void set equals(Token token);
+
+ /**
+ * Return the type of function being defined by the alias.
+ */
+ GenericFunctionType get functionType;
+
+ /**
+ * Set the type of function being defined by the alias to the given
+ * [functionType].
+ */
+ void set functionType(GenericFunctionType functionType);
+
+ /**
+ * Return the type parameters for the function type, or `null` if the function
+ * type does not have any type parameters.
+ */
+ TypeParameterList get typeParameters;
+
+ /**
+ * Set the type parameters for the function type to the given list of
+ * [typeParameters].
+ */
+ void set typeParameters(TypeParameterList typeParameters);
+}
+
+/**
* A combinator that restricts the names being imported to those that are not in
* a given list.
*
@@ -4303,7 +4434,7 @@
* An is expression.
*
* isExpression ::=
- * [Expression] 'is' '!'? [TypeName]
+ * [Expression] 'is' '!'? [TypeAnnotation]
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -4340,14 +4471,14 @@
void set notOperator(Token token);
/**
- * Return the name of the type being tested for.
+ * Return the type being tested for.
*/
- TypeName get type;
+ TypeAnnotation get type;
/**
- * Set the name of the type being tested for to the given [name].
+ * Set the type being tested for to the given [type].
*/
- void set type(TypeName name);
+ void set type(TypeAnnotation type);
}
/**
@@ -4466,7 +4597,7 @@
* A list literal.
*
* listLiteral ::=
- * 'const'? ('<' [TypeName] '>')? '[' ([Expression] ','?)? ']'
+ * 'const'? ('<' [TypeAnnotation] '>')? '[' ([Expression] ','?)? ']'
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -4517,7 +4648,7 @@
* A literal map.
*
* mapLiteral ::=
- * 'const'? ('<' [TypeName] (',' [TypeName])* '>')?
+ * 'const'? ('<' [TypeAnnotation] (',' [TypeAnnotation])* '>')?
* '{' ([MapLiteralEntry] (',' [MapLiteralEntry])* ','?)? '}'
*
* Clients may not extend, implement or mix-in this class.
@@ -4719,12 +4850,12 @@
* Return the return type of the method, or `null` if no return type was
* declared.
*/
- TypeName get returnType;
+ TypeAnnotation get returnType;
/**
- * Set the return type of the method to the given [typeName].
+ * Set the return type of the method to the given [type].
*/
- void set returnType(TypeName typeName);
+ void set returnType(TypeAnnotation type);
/**
* Return the type parameters associated with this method, or `null` if this
@@ -5636,7 +5767,7 @@
* A simple formal parameter.
*
* simpleFormalParameter ::=
- * ('final' [TypeName] | 'var' | [TypeName])? [SimpleIdentifier]
+ * ('final' [TypeAnnotation] | 'var' | [TypeAnnotation])? [SimpleIdentifier]
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -5654,15 +5785,15 @@
void set keyword(Token token);
/**
- * Return the name of the declared type of the parameter, or `null` if the
- * parameter does not have a declared type.
+ * Return the declared type of the parameter, or `null` if the parameter does
+ * not have a declared type.
*/
- TypeName get type;
+ TypeAnnotation get type;
/**
- * Set the name of the declared type of the parameter to the given [typeName].
+ * Set the declared type of the parameter to the given [type].
*/
- void set type(TypeName typeName);
+ void set type(TypeAnnotation type);
}
/**
@@ -6329,6 +6460,23 @@
}
/**
+ * A type annotation.
+ *
+ * type ::=
+ * [NamedType]
+ * | [GenericFunctionType]
+ *
+ * Clients may not extend, implement or mix-in this class.
+ */
+abstract class TypeAnnotation extends AstNode {
+ /**
+ * Return the type being named, or `null` if the AST structure has not been
+ * resolved.
+ */
+ DartType get type;
+}
+
+/**
* A list of type arguments.
*
* typeArguments ::=
@@ -6340,7 +6488,7 @@
/**
* Return the type arguments associated with the type.
*/
- NodeList<TypeName> get arguments;
+ NodeList<TypeAnnotation> get arguments;
/**
* Return the left bracket.
@@ -6405,7 +6553,7 @@
*
* Clients may not extend, implement or mix-in this class.
*/
-abstract class TypeName extends AstNode {
+abstract class TypeName extends TypeAnnotation {
/**
* Return `true` if this type is a deferred type.
*
@@ -6437,12 +6585,6 @@
void set question(Token question);
/**
- * Return the type being named, or `null` if the AST structure has not been
- * resolved.
- */
- DartType get type;
-
- /**
* Set the type being named to the given [type].
*/
void set type(DartType type);
@@ -6464,22 +6606,21 @@
* A type parameter.
*
* typeParameter ::=
- * [SimpleIdentifier] ('extends' [TypeName])?
+ * [SimpleIdentifier] ('extends' [TypeAnnotation])?
*
* Clients may not extend, implement or mix-in this class.
*/
abstract class TypeParameter extends Declaration {
/**
- * Return the name of the upper bound for legal arguments, or `null` if there
- * is no explicit upper bound.
+ * Return the upper bound for legal arguments, or `null` if there is no
+ * explicit upper bound.
*/
- TypeName get bound;
+ TypeAnnotation get bound;
/**
- * Set the name of the upper bound for legal arguments to the given
- * [typeName].
+ * Set the upper bound for legal arguments to the given [type].
*/
- void set bound(TypeName typeName);
+ void set bound(TypeAnnotation type);
/**
* Return the token representing the 'extends' keyword, or `null` if there is
@@ -6662,10 +6803,10 @@
* finalConstVarOrType [VariableDeclaration] (',' [VariableDeclaration])*
*
* finalConstVarOrType ::=
- * | 'final' [TypeName]?
- * | 'const' [TypeName]?
+ * | 'final' [TypeAnnotation]?
+ * | 'const' [TypeAnnotation]?
* | 'var'
- * | [TypeName]
+ * | [TypeAnnotation]
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -6700,12 +6841,12 @@
* Return the type of the variables being declared, or `null` if no type was
* provided.
*/
- TypeName get type;
+ TypeAnnotation get type;
/**
- * Set the type of the variables being declared to the given [typeName].
+ * Set the type of the variables being declared to the given [type].
*/
- void set type(TypeName typeName);
+ void set type(TypeAnnotation type);
/**
* Return a list containing the individual variables being declared.
diff --git a/pkg/analyzer/lib/dart/ast/ast_factory.dart b/pkg/analyzer/lib/dart/ast/ast_factory.dart
index ffaf90e..48b918d 100644
--- a/pkg/analyzer/lib/dart/ast/ast_factory.dart
+++ b/pkg/analyzer/lib/dart/ast/ast_factory.dart
@@ -39,7 +39,7 @@
* Returns a newly created as expression.
*/
AsExpression asExpression(
- Expression expression, Token asOperator, TypeName type);
+ Expression expression, Token asOperator, TypeAnnotation type);
/**
* Returns a newly created assert initializer. The [comma] and [message]
@@ -128,7 +128,7 @@
*/
CatchClause catchClause(
Token onKeyword,
- TypeName exceptionType,
+ TypeAnnotation exceptionType,
Token catchKeyword,
Token leftParenthesis,
SimpleIdentifier exceptionParameter,
@@ -290,7 +290,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
SimpleIdentifier identifier);
/**
@@ -423,7 +423,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
Token thisKeyword,
Token period,
SimpleIdentifier identifier,
@@ -502,7 +502,7 @@
Comment comment,
List<Annotation> metadata,
Token externalKeyword,
- TypeName returnType,
+ TypeAnnotation returnType,
Token propertyKeyword,
SimpleIdentifier name,
FunctionExpression functionExpression);
@@ -536,7 +536,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName returnType,
+ TypeAnnotation returnType,
SimpleIdentifier name,
TypeParameterList typeParameters,
FormalParameterList parameters,
@@ -551,7 +551,7 @@
FunctionTypedFormalParameter functionTypedFormalParameter(
Comment comment,
List<Annotation> metadata,
- TypeName returnType,
+ TypeAnnotation returnType,
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters,
@@ -642,7 +642,7 @@
* if the sense of the test is not negated.
*/
IsExpression isExpression(Expression expression, Token isOperator,
- Token notOperator, TypeName type);
+ Token notOperator, TypeAnnotation type);
/**
* Returns a newly created label.
@@ -706,7 +706,7 @@
List<Annotation> metadata,
Token externalKeyword,
Token modifierKeyword,
- TypeName returnType,
+ TypeAnnotation returnType,
Token propertyKeyword,
Token operatorKeyword,
SimpleIdentifier name,
@@ -849,7 +849,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
SimpleIdentifier identifier);
/**
@@ -948,7 +948,7 @@
* Returns a newly created list of type arguments.
*/
TypeArgumentList typeArgumentList(
- Token leftBracket, List<TypeName> arguments, Token rightBracket);
+ Token leftBracket, List<TypeAnnotation> arguments, Token rightBracket);
/**
* Returns a newly created type name. The [typeArguments] can be `null` if
@@ -964,7 +964,7 @@
* the parameter does not have an upper bound.
*/
TypeParameter typeParameter(Comment comment, List<Annotation> metadata,
- SimpleIdentifier name, Token extendsKeyword, TypeName bound);
+ SimpleIdentifier name, Token extendsKeyword, TypeAnnotation bound);
/**
* Returns a newly created list of type parameters.
@@ -989,10 +989,23 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
List<VariableDeclaration> variables);
/**
+ * Returns a newly created generic type alias. Either or both of the
+ * [comment] and [metadata] can be `null` if the variable list does not have
+ * the corresponding attribute. The [typeParameters] can be `null` if there
+ * are no type parameters.
+ */
+ GenericTypeAlias genericTypeAlias(Comment comment, List<Annotation> metadata, Token typedefKeyword, SimpleIdentifier name, TypeParameterList typeParameters, Token equals, GenericFunctionType functionType, Token semicolon);
+
+ /**
+ * Initialize a newly created generic function type.
+ */
+ GenericFunctionType genericFunctionType(TypeAnnotation returnType, Token functionKeyword, TypeParameterList typeParameters, FormalParameterList _parameters);
+
+ /**
* Returns a newly created variable declaration statement.
*/
VariableDeclarationStatement variableDeclarationStatement(
diff --git a/pkg/analyzer/lib/dart/ast/resolution_map.dart b/pkg/analyzer/lib/dart/ast/resolution_map.dart
index 37ee054..a9e59ff 100644
--- a/pkg/analyzer/lib/dart/ast/resolution_map.dart
+++ b/pkg/analyzer/lib/dart/ast/resolution_map.dart
@@ -279,7 +279,7 @@
* Return the type being named by [node], or `null` if the AST structure has
* not been resolved.
*/
- DartType typeForTypeName(TypeName node);
+ DartType typeForTypeName(TypeAnnotation node);
/**
* Return the element associated with the uri of the directive [node], or
diff --git a/pkg/analyzer/lib/dart/ast/visitor.dart b/pkg/analyzer/lib/dart/ast/visitor.dart
index ad96bed..79f3bfb 100644
--- a/pkg/analyzer/lib/dart/ast/visitor.dart
+++ b/pkg/analyzer/lib/dart/ast/visitor.dart
@@ -50,7 +50,7 @@
*
* visitor.visitAllNodes(rootNode);
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class BreadthFirstVisitor<R> extends GeneralizingAstVisitor<R> {
/**
@@ -147,7 +147,7 @@
* do so will cause the visit methods for superclasses of the node to not be
* invoked and will cause the children of the visited node to not be visited.
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class GeneralizingAstVisitor<R> implements AstVisitor<R> {
@override
@@ -336,6 +336,13 @@
visitNormalFormalParameter(node);
@override
+ R visitGenericFunctionType(GenericFunctionType node) =>
+ visitTypeAnnotation(node);
+
+ @override
+ R visitGenericTypeAlias(GenericTypeAlias node) => visitTypeAlias(node);
+
+ @override
R visitHideCombinator(HideCombinator node) => visitCombinator(node);
R visitIdentifier(Identifier node) => visitExpression(node);
@@ -528,6 +535,8 @@
R visitTypeAlias(TypeAlias node) => visitNamedCompilationUnitMember(node);
+ R visitTypeAnnotation(TypeAnnotation node) => visitNode(node);
+
@override
R visitTypeArgumentList(TypeArgumentList node) => visitNode(node);
@@ -576,7 +585,7 @@
* Failure to do so will cause the children of the visited node to not be
* visited.
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class RecursiveAstVisitor<R> implements AstVisitor<R> {
@override
@@ -880,6 +889,18 @@
}
@override
+ R visitGenericFunctionType(GenericFunctionType node) {
+ node.visitChildren(this);
+ return null;
+ }
+
+ @override
+ R visitGenericTypeAlias(GenericTypeAlias node) {
+ node.visitChildren(this);
+ return null;
+ }
+
+ @override
R visitHideCombinator(HideCombinator node) {
node.visitChildren(this);
return null;
@@ -1241,7 +1262,7 @@
* dispatch mechanism (and hence don't need to recursively visit a whole
* structure) and that only need to visit a small number of node types.
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class SimpleAstVisitor<R> implements AstVisitor<R> {
@override
@@ -1398,6 +1419,12 @@
null;
@override
+ R visitGenericFunctionType(GenericFunctionType node) => null;
+
+ @override
+ R visitGenericTypeAlias(GenericTypeAlias node) => null;
+
+ @override
R visitHideCombinator(HideCombinator node) => null;
@override
@@ -1579,7 +1606,366 @@
}
/**
- * An AST Visitor that captures visit call timings.
+ * An AST visitor that will throw an exception if any of the visit methods that
+ * are invoked have not been overridden. It is intended to be a superclass for
+ * classes that implement the visitor pattern and need to (a) override all of
+ * the visit methods or (b) need to override a subset of the visit method and
+ * want to catch when any other visit methods have been invoked.
+ *
+ * Clients may extend this class.
+ */
+class ThrowingAstVisitor<R> implements AstVisitor<R> {
+ @override
+ R visitAdjacentStrings(AdjacentStrings node) => _throw(node);
+
+ @override
+ R visitAnnotation(Annotation node) => _throw(node);
+
+ @override
+ R visitArgumentList(ArgumentList node) => _throw(node);
+
+ @override
+ R visitAsExpression(AsExpression node) => _throw(node);
+
+ @override
+ R visitAssertInitializer(AssertInitializer node) => _throw(node);
+
+ @override
+ R visitAssertStatement(AssertStatement node) => _throw(node);
+
+ @override
+ R visitAssignmentExpression(AssignmentExpression node) => _throw(node);
+
+ @override
+ R visitAwaitExpression(AwaitExpression node) => _throw(node);
+
+ @override
+ R visitBinaryExpression(BinaryExpression node) => _throw(node);
+
+ @override
+ R visitBlock(Block node) => _throw(node);
+
+ @override
+ R visitBlockFunctionBody(BlockFunctionBody node) => _throw(node);
+
+ @override
+ R visitBooleanLiteral(BooleanLiteral node) => _throw(node);
+
+ @override
+ R visitBreakStatement(BreakStatement node) => _throw(node);
+
+ @override
+ R visitCascadeExpression(CascadeExpression node) => _throw(node);
+
+ @override
+ R visitCatchClause(CatchClause node) => _throw(node);
+
+ @override
+ R visitClassDeclaration(ClassDeclaration node) => _throw(node);
+
+ @override
+ R visitClassTypeAlias(ClassTypeAlias node) => _throw(node);
+
+ @override
+ R visitComment(Comment node) => _throw(node);
+
+ @override
+ R visitCommentReference(CommentReference node) => _throw(node);
+
+ @override
+ R visitCompilationUnit(CompilationUnit node) => _throw(node);
+
+ @override
+ R visitConditionalExpression(ConditionalExpression node) => _throw(node);
+
+ @override
+ R visitConfiguration(Configuration node) => _throw(node);
+
+ @override
+ R visitConstructorDeclaration(ConstructorDeclaration node) => _throw(node);
+
+ @override
+ R visitConstructorFieldInitializer(ConstructorFieldInitializer node) =>
+ _throw(node);
+
+ @override
+ R visitConstructorName(ConstructorName node) => _throw(node);
+
+ @override
+ R visitContinueStatement(ContinueStatement node) => _throw(node);
+
+ @override
+ R visitDeclaredIdentifier(DeclaredIdentifier node) => _throw(node);
+
+ @override
+ R visitDefaultFormalParameter(DefaultFormalParameter node) => _throw(node);
+
+ @override
+ R visitDoStatement(DoStatement node) => _throw(node);
+
+ @override
+ R visitDottedName(DottedName node) => _throw(node);
+
+ @override
+ R visitDoubleLiteral(DoubleLiteral node) => _throw(node);
+
+ @override
+ R visitEmptyFunctionBody(EmptyFunctionBody node) => _throw(node);
+
+ @override
+ R visitEmptyStatement(EmptyStatement node) => _throw(node);
+
+ @override
+ R visitEnumConstantDeclaration(EnumConstantDeclaration node) => _throw(node);
+
+ @override
+ R visitEnumDeclaration(EnumDeclaration node) => _throw(node);
+
+ @override
+ R visitExportDirective(ExportDirective node) => _throw(node);
+
+ @override
+ R visitExpressionFunctionBody(ExpressionFunctionBody node) => _throw(node);
+
+ @override
+ R visitExpressionStatement(ExpressionStatement node) => _throw(node);
+
+ @override
+ R visitExtendsClause(ExtendsClause node) => _throw(node);
+
+ @override
+ R visitFieldDeclaration(FieldDeclaration node) => _throw(node);
+
+ @override
+ R visitFieldFormalParameter(FieldFormalParameter node) => _throw(node);
+
+ @override
+ R visitForEachStatement(ForEachStatement node) => _throw(node);
+
+ @override
+ R visitFormalParameterList(FormalParameterList node) => _throw(node);
+
+ @override
+ R visitForStatement(ForStatement node) => _throw(node);
+
+ @override
+ R visitFunctionDeclaration(FunctionDeclaration node) => _throw(node);
+
+ @override
+ R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) =>
+ _throw(node);
+
+ @override
+ R visitFunctionExpression(FunctionExpression node) => _throw(node);
+
+ @override
+ R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
+ _throw(node);
+
+ @override
+ R visitFunctionTypeAlias(FunctionTypeAlias node) => _throw(node);
+
+ @override
+ R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) =>
+ _throw(node);
+
+ @override
+ R visitGenericFunctionType(GenericFunctionType node) => _throw(node);
+
+ @override
+ R visitGenericTypeAlias(GenericTypeAlias node) => _throw(node);
+
+ @override
+ R visitHideCombinator(HideCombinator node) => _throw(node);
+
+ @override
+ R visitIfStatement(IfStatement node) => _throw(node);
+
+ @override
+ R visitImplementsClause(ImplementsClause node) => _throw(node);
+
+ @override
+ R visitImportDirective(ImportDirective node) => _throw(node);
+
+ @override
+ R visitIndexExpression(IndexExpression node) => _throw(node);
+
+ @override
+ R visitInstanceCreationExpression(InstanceCreationExpression node) =>
+ _throw(node);
+
+ @override
+ R visitIntegerLiteral(IntegerLiteral node) => _throw(node);
+
+ @override
+ R visitInterpolationExpression(InterpolationExpression node) => _throw(node);
+
+ @override
+ R visitInterpolationString(InterpolationString node) => _throw(node);
+
+ @override
+ R visitIsExpression(IsExpression node) => _throw(node);
+
+ @override
+ R visitLabel(Label node) => _throw(node);
+
+ @override
+ R visitLabeledStatement(LabeledStatement node) => _throw(node);
+
+ @override
+ R visitLibraryDirective(LibraryDirective node) => _throw(node);
+
+ @override
+ R visitLibraryIdentifier(LibraryIdentifier node) => _throw(node);
+
+ @override
+ R visitListLiteral(ListLiteral node) => _throw(node);
+
+ @override
+ R visitMapLiteral(MapLiteral node) => _throw(node);
+
+ @override
+ R visitMapLiteralEntry(MapLiteralEntry node) => _throw(node);
+
+ @override
+ R visitMethodDeclaration(MethodDeclaration node) => _throw(node);
+
+ @override
+ R visitMethodInvocation(MethodInvocation node) => _throw(node);
+
+ @override
+ R visitNamedExpression(NamedExpression node) => _throw(node);
+
+ @override
+ R visitNativeClause(NativeClause node) => _throw(node);
+
+ @override
+ R visitNativeFunctionBody(NativeFunctionBody node) => _throw(node);
+
+ @override
+ R visitNullLiteral(NullLiteral node) => _throw(node);
+
+ @override
+ R visitParenthesizedExpression(ParenthesizedExpression node) => _throw(node);
+
+ @override
+ R visitPartDirective(PartDirective node) => _throw(node);
+
+ @override
+ R visitPartOfDirective(PartOfDirective node) => _throw(node);
+
+ @override
+ R visitPostfixExpression(PostfixExpression node) => _throw(node);
+
+ @override
+ R visitPrefixedIdentifier(PrefixedIdentifier node) => _throw(node);
+
+ @override
+ R visitPrefixExpression(PrefixExpression node) => _throw(node);
+
+ @override
+ R visitPropertyAccess(PropertyAccess node) => _throw(node);
+
+ @override
+ R visitRedirectingConstructorInvocation(
+ RedirectingConstructorInvocation node) =>
+ _throw(node);
+
+ @override
+ R visitRethrowExpression(RethrowExpression node) => _throw(node);
+
+ @override
+ R visitReturnStatement(ReturnStatement node) => _throw(node);
+
+ @override
+ R visitScriptTag(ScriptTag node) => _throw(node);
+
+ @override
+ R visitShowCombinator(ShowCombinator node) => _throw(node);
+
+ @override
+ R visitSimpleFormalParameter(SimpleFormalParameter node) => _throw(node);
+
+ @override
+ R visitSimpleIdentifier(SimpleIdentifier node) => _throw(node);
+
+ @override
+ R visitSimpleStringLiteral(SimpleStringLiteral node) => _throw(node);
+
+ @override
+ R visitStringInterpolation(StringInterpolation node) => _throw(node);
+
+ @override
+ R visitSuperConstructorInvocation(SuperConstructorInvocation node) =>
+ _throw(node);
+
+ @override
+ R visitSuperExpression(SuperExpression node) => _throw(node);
+
+ @override
+ R visitSwitchCase(SwitchCase node) => _throw(node);
+
+ @override
+ R visitSwitchDefault(SwitchDefault node) => _throw(node);
+
+ @override
+ R visitSwitchStatement(SwitchStatement node) => _throw(node);
+
+ @override
+ R visitSymbolLiteral(SymbolLiteral node) => _throw(node);
+
+ @override
+ R visitThisExpression(ThisExpression node) => _throw(node);
+
+ @override
+ R visitThrowExpression(ThrowExpression node) => _throw(node);
+
+ @override
+ R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) =>
+ _throw(node);
+
+ @override
+ R visitTryStatement(TryStatement node) => _throw(node);
+
+ @override
+ R visitTypeArgumentList(TypeArgumentList node) => _throw(node);
+
+ @override
+ R visitTypeName(TypeName node) => _throw(node);
+
+ @override
+ R visitTypeParameter(TypeParameter node) => _throw(node);
+
+ @override
+ R visitTypeParameterList(TypeParameterList node) => _throw(node);
+
+ @override
+ R visitVariableDeclaration(VariableDeclaration node) => _throw(node);
+
+ @override
+ R visitVariableDeclarationList(VariableDeclarationList node) => _throw(node);
+
+ @override
+ R visitVariableDeclarationStatement(VariableDeclarationStatement node) =>
+ _throw(node);
+
+ @override
+ R visitWhileStatement(WhileStatement node) => _throw(node);
+
+ @override
+ R visitWithClause(WithClause node) => _throw(node);
+ @override
+ R visitYieldStatement(YieldStatement node) => _throw(node);
+
+ R _throw(AstNode node) {
+ throw new Exception('Missing implementation of visit${node.runtimeType}');
+ }
+}
+
+/**
+ * An AST visitor that captures visit call timings.
+ *
+ * Clients may not extend, implement or mix-in this class.
*/
class TimedAstVisitor<T> implements AstVisitor<T> {
/**
@@ -2000,6 +2386,22 @@
}
@override
+ T visitGenericFunctionType(GenericFunctionType node) {
+ stopwatch.start();
+ T result = _baseVisitor.visitGenericFunctionType(node);
+ stopwatch.stop();
+ return result;
+ }
+
+ @override
+ T visitGenericTypeAlias(GenericTypeAlias node) {
+ stopwatch.start();
+ T result = _baseVisitor.visitGenericTypeAlias(node);
+ stopwatch.stop();
+ return result;
+ }
+
+ @override
T visitHideCombinator(HideCombinator node) {
stopwatch.start();
T result = _baseVisitor.visitHideCombinator(node);
@@ -2483,7 +2885,7 @@
* Failure to do so will cause the children of the visited node to not be
* visited.
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class UnifyingAstVisitor<R> implements AstVisitor<R> {
@override
@@ -2642,6 +3044,12 @@
visitNode(node);
@override
+ R visitGenericFunctionType(GenericFunctionType node) => visitNode(node);
+
+ @override
+ R visitGenericTypeAlias(GenericTypeAlias node) => visitNode(node);
+
+ @override
R visitHideCombinator(HideCombinator node) => visitNode(node);
@override
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index c235ea3..5edb586 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -1017,7 +1017,14 @@
/**
* An object that can be used to visit an element structure.
*
- * Clients may implement this class.
+ * Clients may not extend, implement or mix-in this class. There are classes
+ * that implement this interface that provide useful default behaviors in
+ * `package:analyzer/dart/ast/visitor.dart`. A couple of the most useful include
+ * * SimpleElementVisitor which implements every visit method by doing nothing,
+ * * RecursiveElementVisitor which will cause every node in a structure to be
+ * visited, and
+ * * ThrowingElementVisitor which implements every visit method by throwing an
+ * exception.
*/
abstract class ElementVisitor<R> {
R visitClassElement(ClassElement element);
diff --git a/pkg/analyzer/lib/dart/element/visitor.dart b/pkg/analyzer/lib/dart/element/visitor.dart
index 185357d..c34c771 100644
--- a/pkg/analyzer/lib/dart/element/visitor.dart
+++ b/pkg/analyzer/lib/dart/element/visitor.dart
@@ -82,7 +82,7 @@
* do so will cause the visit methods for superclasses of the element to not be
* invoked and will cause the children of the visited node to not be visited.
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class GeneralizingElementVisitor<R> implements ElementVisitor<R> {
@override
@@ -189,7 +189,7 @@
* children. Failure to do so will cause the children of the visited element to
* not be visited.
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class RecursiveElementVisitor<R> implements ElementVisitor<R> {
@override
@@ -313,7 +313,7 @@
* mechanism (and hence don't need to recursively visit a whole structure) and
* that only need to visit a small number of element types.
*
- * Clients may extend or implement this class.
+ * Clients may extend this class.
*/
class SimpleElementVisitor<R> implements ElementVisitor<R> {
@override
@@ -374,3 +374,82 @@
@override
R visitTypeParameterElement(TypeParameterElement element) => null;
}
+
+/**
+ * An AST visitor that will throw an exception if any of the visit methods that
+ * are invoked have not been overridden. It is intended to be a superclass for
+ * classes that implement the visitor pattern and need to (a) override all of
+ * the visit methods or (b) need to override a subset of the visit method and
+ * want to catch when any other visit methods have been invoked.
+ *
+ * Clients may extend this class.
+ */
+class ThrowingElementVisitor<R> implements ElementVisitor<R> {
+ @override
+ R visitClassElement(ClassElement element) => _throw(element);
+
+ @override
+ R visitCompilationUnitElement(CompilationUnitElement element) =>
+ _throw(element);
+
+ @override
+ R visitConstructorElement(ConstructorElement element) => _throw(element);
+
+ @override
+ R visitExportElement(ExportElement element) => _throw(element);
+
+ @override
+ R visitFieldElement(FieldElement element) => _throw(element);
+
+ @override
+ R visitFieldFormalParameterElement(FieldFormalParameterElement element) =>
+ _throw(element);
+
+ @override
+ R visitFunctionElement(FunctionElement element) => _throw(element);
+
+ @override
+ R visitFunctionTypeAliasElement(FunctionTypeAliasElement element) =>
+ _throw(element);
+
+ @override
+ R visitImportElement(ImportElement element) => _throw(element);
+
+ @override
+ R visitLabelElement(LabelElement element) => _throw(element);
+
+ @override
+ R visitLibraryElement(LibraryElement element) => _throw(element);
+
+ @override
+ R visitLocalVariableElement(LocalVariableElement element) => _throw(element);
+
+ @override
+ R visitMethodElement(MethodElement element) => _throw(element);
+
+ @override
+ R visitMultiplyDefinedElement(MultiplyDefinedElement element) =>
+ _throw(element);
+
+ @override
+ R visitParameterElement(ParameterElement element) => _throw(element);
+
+ @override
+ R visitPrefixElement(PrefixElement element) => _throw(element);
+
+ @override
+ R visitPropertyAccessorElement(PropertyAccessorElement element) =>
+ _throw(element);
+
+ @override
+ R visitTopLevelVariableElement(TopLevelVariableElement element) =>
+ _throw(element);
+
+ @override
+ R visitTypeParameterElement(TypeParameterElement element) => _throw(element);
+
+ R _throw(Element element) {
+ throw new Exception(
+ 'Missing implementation of visit${element.runtimeType}');
+ }
+}
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index c2865a5..4f1234e 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -73,7 +73,7 @@
/**
* The version of data format, should be incremented on every format change.
*/
- static const int DATA_VERSION = 9;
+ static const int DATA_VERSION = 10;
/**
* The name of the driver, e.g. the name of the folder.
@@ -297,6 +297,11 @@
Set<String> get knownFiles => _fsState.knownFilePaths;
/**
+ * Return the number of files scheduled for analysis.
+ */
+ int get numberOfFilesToAnalyze => _filesToAnalyze.length;
+
+ /**
* Return the list of files that the driver should try to analyze sooner.
*/
List<String> get priorityFiles => _priorityFiles.toList(growable: false);
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index 3238aed..862b16c 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -504,15 +504,15 @@
Token asOperator;
/**
- * The name of the type being cast to.
+ * The type being cast to.
*/
- TypeName _type;
+ TypeAnnotation _type;
/**
* Initialize a newly created as expression.
*/
AsExpressionImpl(
- ExpressionImpl expression, this.asOperator, TypeNameImpl type) {
+ ExpressionImpl expression, this.asOperator, TypeAnnotationImpl type) {
_expression = _becomeParentOf(expression);
_type = _becomeParentOf(type);
}
@@ -539,11 +539,11 @@
int get precedence => 7;
@override
- TypeName get type => _type;
+ TypeAnnotation get type => _type;
@override
- void set type(TypeName name) {
- _type = _becomeParentOf(name as AstNodeImpl);
+ void set type(TypeAnnotation type) {
+ _type = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -1575,7 +1575,7 @@
* The type of exceptions caught by this catch clause, or `null` if this catch
* clause catches every type of exception.
*/
- TypeName _exceptionType;
+ TypeAnnotation _exceptionType;
/**
* The token representing the 'catch' keyword, or `null` if there is no
@@ -1628,7 +1628,7 @@
*/
CatchClauseImpl(
this.onKeyword,
- TypeNameImpl exceptionType,
+ TypeAnnotationImpl exceptionType,
this.catchKeyword,
this.leftParenthesis,
SimpleIdentifierImpl exceptionParameter,
@@ -1682,10 +1682,10 @@
}
@override
- TypeName get exceptionType => _exceptionType;
+ TypeAnnotation get exceptionType => _exceptionType;
@override
- void set exceptionType(TypeName exceptionType) {
+ void set exceptionType(TypeAnnotation exceptionType) {
_exceptionType = _becomeParentOf(exceptionType as AstNodeImpl);
}
@@ -3294,7 +3294,7 @@
* The name of the declared type of the parameter, or `null` if the parameter
* does not have a declared type.
*/
- TypeName _type;
+ TypeAnnotation _type;
/**
* The name of the variable being declared.
@@ -3308,7 +3308,7 @@
* given. The [type] must be `null` if the keyword is 'var'.
*/
DeclaredIdentifierImpl(CommentImpl comment, List<Annotation> metadata,
- this.keyword, TypeNameImpl type, SimpleIdentifierImpl identifier)
+ this.keyword, TypeAnnotationImpl type, SimpleIdentifierImpl identifier)
: super(comment, metadata) {
_type = _becomeParentOf(type);
_identifier = _becomeParentOf(identifier);
@@ -3354,11 +3354,11 @@
bool get isFinal => keyword?.keyword == Keyword.FINAL;
@override
- TypeName get type => _type;
+ TypeAnnotation get type => _type;
@override
- void set type(TypeName typeName) {
- _type = _becomeParentOf(typeName as AstNodeImpl);
+ void set type(TypeAnnotation type) {
+ _type = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -4408,7 +4408,7 @@
* The name of the declared type of the parameter, or `null` if the parameter
* does not have a declared type.
*/
- TypeName _type;
+ TypeAnnotation _type;
/**
* The token representing the 'this' keyword.
@@ -4447,7 +4447,7 @@
CommentImpl comment,
List<Annotation> metadata,
this.keyword,
- TypeNameImpl type,
+ TypeAnnotationImpl type,
this.thisKeyword,
this.period,
SimpleIdentifierImpl identifier,
@@ -4501,11 +4501,11 @@
}
@override
- TypeName get type => _type;
+ TypeAnnotation get type => _type;
@override
- void set type(TypeName typeName) {
- _type = _becomeParentOf(typeName as AstNodeImpl);
+ void set type(TypeAnnotation type) {
+ _type = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -5084,7 +5084,7 @@
/**
* The return type of the function, or `null` if no return type was declared.
*/
- TypeName _returnType;
+ TypeAnnotation _returnType;
/**
* The token representing the 'get' or 'set' keyword, or `null` if this is a
@@ -5110,7 +5110,7 @@
CommentImpl comment,
List<Annotation> metadata,
this.externalKeyword,
- TypeNameImpl returnType,
+ TypeAnnotationImpl returnType,
this.propertyKeyword,
SimpleIdentifierImpl name,
FunctionExpressionImpl functionExpression)
@@ -5162,11 +5162,11 @@
bool get isSetter => propertyKeyword?.keyword == Keyword.SET;
@override
- TypeName get returnType => _returnType;
+ TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeName returnType) {
- _returnType = _becomeParentOf(returnType as AstNodeImpl);
+ void set returnType(TypeAnnotation type) {
+ _returnType = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -5195,8 +5195,9 @@
/**
* Initialize a newly created function declaration statement.
*/
- FunctionDeclarationStatementImpl(FunctionDeclaration functionDeclaration) {
- _functionDeclaration = _becomeParentOf(functionDeclaration as AstNodeImpl);
+ FunctionDeclarationStatementImpl(
+ FunctionDeclarationImpl functionDeclaration) {
+ _functionDeclaration = _becomeParentOf(functionDeclaration);
}
@override
@@ -5434,7 +5435,7 @@
* The name of the return type of the function type being defined, or `null`
* if no return type was given.
*/
- TypeName _returnType;
+ TypeAnnotation _returnType;
/**
* The type parameters for the function type, or `null` if the function type
@@ -5458,7 +5459,7 @@
CommentImpl comment,
List<Annotation> metadata,
Token keyword,
- TypeNameImpl returnType,
+ TypeAnnotationImpl returnType,
SimpleIdentifierImpl name,
TypeParameterListImpl typeParameters,
FormalParameterListImpl parameters,
@@ -5491,11 +5492,11 @@
}
@override
- TypeName get returnType => _returnType;
+ TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeName typeName) {
- _returnType = _becomeParentOf(typeName as AstNodeImpl);
+ void set returnType(TypeAnnotation type) {
+ _returnType = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -5532,7 +5533,7 @@
* The return type of the function, or `null` if the function does not have a
* return type.
*/
- TypeName _returnType;
+ TypeAnnotation _returnType;
/**
* The type parameters associated with the function, or `null` if the function
@@ -5557,7 +5558,7 @@
FunctionTypedFormalParameterImpl(
CommentImpl comment,
List<Annotation> metadata,
- TypeNameImpl returnType,
+ TypeAnnotationImpl returnType,
SimpleIdentifierImpl identifier,
TypeParameterListImpl typeParameters,
FormalParameterListImpl parameters,
@@ -5598,10 +5599,10 @@
}
@override
- TypeName get returnType => _returnType;
+ TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeName type) {
+ void set returnType(TypeAnnotation type) {
_returnType = _becomeParentOf(type as AstNodeImpl);
}
@@ -5628,6 +5629,214 @@
}
/**
+ * An anonymous function type.
+ *
+ * functionType ::=
+ * [TypeAnnotation]? 'Function' [TypeParameterList]? [FormalParameterList]
+ *
+ * where the FormalParameterList is being used to represent the following
+ * grammar, despite the fact that FormalParameterList can represent a much
+ * larger grammar than the one below. This is done in order to simplify the
+ * implementation.
+ *
+ * parameterTypeList ::=
+ * () |
+ * ( normalParameterTypes ,? ) |
+ * ( normalParameterTypes , optionalParameterTypes ) |
+ * ( optionalParameterTypes )
+ * namedParameterTypes ::=
+ * { namedParameterType (, namedParameterType)* ,? }
+ * namedParameterType ::=
+ * [TypeAnnotation]? [SimpleIdentifier]
+ * normalParameterTypes ::=
+ * normalParameterType (, normalParameterType)*
+ * normalParameterType ::=
+ * [TypeAnnotation] [SimpleIdentifier]?
+ * optionalParameterTypes ::=
+ * optionalPositionalParameterTypes | namedParameterTypes
+ * optionalPositionalParameterTypes ::=
+ * [ normalParameterTypes ,? ]
+ */
+class GenericFunctionTypeImpl extends TypeAnnotationImpl
+ implements GenericFunctionType {
+ /**
+ * The name of the return type of the function type being defined, or
+ * `null` if no return type was given.
+ */
+ TypeAnnotation _returnType;
+
+ @override
+ Token functionKeyword;
+
+ /**
+ * The type parameters for the function type, or `null` if the function type
+ * does not have any type parameters.
+ */
+ TypeParameterList _typeParameters;
+
+ /**
+ * The parameters associated with the function type.
+ */
+ FormalParameterList _parameters;
+
+ /**
+ * Initialize a newly created generic function type.
+ */
+ GenericFunctionTypeImpl(
+ TypeAnnotationImpl returnType,
+ this.functionKeyword,
+ TypeParameterListImpl typeParameters,
+ FormalParameterListImpl parameters) {
+ _returnType = _becomeParentOf(returnType);
+ _typeParameters = _becomeParentOf(typeParameters);
+ _parameters = _becomeParentOf(parameters);
+ }
+
+ @override
+ Token get beginToken =>
+ _returnType == null ? functionKeyword : _returnType.beginToken;
+
+ @override
+ Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ ..add(_returnType)
+ ..add(functionKeyword)
+ ..add(_typeParameters)
+ ..add(_parameters);
+
+ @override
+ Token get endToken => _parameters.endToken;
+
+ @override
+ FormalParameterList get parameters => _parameters;
+
+ @override
+ void set parameters(FormalParameterList parameters) {
+ _parameters = _becomeParentOf(parameters as AstNodeImpl);
+ }
+
+ @override
+ TypeAnnotation get returnType => _returnType;
+
+ @override
+ void set returnType(TypeAnnotation type) {
+ _returnType = _becomeParentOf(type as AstNodeImpl);
+ }
+
+ @override
+ DartType get type => null;
+
+ /**
+ * Return the type parameters for the function type, or `null` if the function
+ * type does not have any type parameters.
+ */
+ TypeParameterList get typeParameters => _typeParameters;
+
+ /**
+ * Set the type parameters for the function type to the given list of
+ * [typeParameters].
+ */
+ void set typeParameters(TypeParameterList typeParameters) {
+ _typeParameters = _becomeParentOf(typeParameters as AstNodeImpl);
+ }
+
+ // TODO: implement type
+ @override
+ dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) {
+ return visitor.visitGenericFunctionType(this);
+ }
+
+ @override
+ void visitChildren(AstVisitor visitor) {
+ _returnType?.accept(visitor);
+ _typeParameters?.accept(visitor);
+ _parameters?.accept(visitor);
+ }
+}
+
+/**
+ * A generic type alias.
+ *
+ * functionTypeAlias ::=
+ * metadata 'typedef' [SimpleIdentifier] [TypeParameterList]? = [FunctionType] ';'
+ */
+class GenericTypeAliasImpl extends TypeAliasImpl implements GenericTypeAlias {
+ /**
+ * The type parameters for the function type, or `null` if the function
+ * type does not have any type parameters.
+ */
+ TypeParameterList _typeParameters;
+
+ @override
+ Token equals;
+
+ /**
+ * The type of function being defined by the alias.
+ */
+ GenericFunctionType _functionType;
+
+ /**
+ * Returns a newly created generic type alias. Either or both of the
+ * [comment] and [metadata] can be `null` if the variable list does not have
+ * the corresponding attribute. The [typeParameters] can be `null` if there
+ * are no type parameters.
+ */
+ GenericTypeAliasImpl(
+ Comment comment,
+ List<Annotation> metadata,
+ Token typedefToken,
+ SimpleIdentifier name,
+ TypeParameterListImpl typeParameters,
+ this.equals,
+ GenericFunctionTypeImpl functionType,
+ Token semicolon)
+ : super(comment, metadata, typedefToken, name, semicolon) {
+ _typeParameters = _becomeParentOf(typeParameters);
+ _functionType = _becomeParentOf(functionType);
+ }
+
+ @override
+ Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ ..addAll(metadata)
+ ..add(typedefKeyword)
+ ..add(name)
+ ..add(_typeParameters)
+ ..add(equals)
+ ..add(_functionType);
+ @override
+ Element get element => null;
+
+ @override
+ GenericFunctionType get functionType => _functionType;
+
+ @override
+ void set functionType(GenericFunctionType functionType) {
+ _functionType = _becomeParentOf(functionType as AstNodeImpl);
+ }
+
+ @override
+ TypeParameterList get typeParameters => _typeParameters;
+
+ @override
+ void set typeParameters(TypeParameterList typeParameters) {
+ _typeParameters = _becomeParentOf(typeParameters as AstNodeImpl);
+ }
+
+ @override
+ dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) {
+ return visitor.visitGenericTypeAlias(this);
+ }
+
+ // TODO: implement element
+ @override
+ void visitChildren(AstVisitor visitor) {
+ super.visitChildren(visitor);
+ name?.accept(visitor);
+ _typeParameters?.accept(visitor);
+ _functionType?.accept(visitor);
+ }
+}
+
+/**
* A combinator that restricts the names being imported to those that are not in
* a given list.
*
@@ -6527,14 +6736,14 @@
/**
* The name of the type being tested for.
*/
- TypeName _type;
+ TypeAnnotation _type;
/**
* Initialize a newly created is expression. The [notOperator] can be `null`
* if the sense of the test is not negated.
*/
IsExpressionImpl(ExpressionImpl expression, this.isOperator, this.notOperator,
- TypeNameImpl type) {
+ TypeAnnotationImpl type) {
_expression = _becomeParentOf(expression);
_type = _becomeParentOf(type);
}
@@ -6564,11 +6773,11 @@
int get precedence => 7;
@override
- TypeName get type => _type;
+ TypeAnnotation get type => _type;
@override
- void set type(TypeName name) {
- _type = _becomeParentOf(name as AstNodeImpl);
+ void set type(TypeAnnotation type) {
+ _type = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -7124,7 +7333,7 @@
/**
* The return type of the method, or `null` if no return type was declared.
*/
- TypeName _returnType;
+ TypeAnnotation _returnType;
/**
* The token representing the 'get' or 'set' keyword, or `null` if this is a
@@ -7178,7 +7387,7 @@
List<Annotation> metadata,
this.externalKeyword,
this.modifierKeyword,
- TypeNameImpl returnType,
+ TypeAnnotationImpl returnType,
this.propertyKeyword,
this.operatorKeyword,
SimpleIdentifierImpl name,
@@ -7277,11 +7486,11 @@
}
@override
- TypeName get returnType => _returnType;
+ TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeName typeName) {
- _returnType = _becomeParentOf(typeName as AstNodeImpl);
+ void set returnType(TypeAnnotation type) {
+ _returnType = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -8991,7 +9200,7 @@
* The name of the declared type of the parameter, or `null` if the parameter
* does not have a declared type.
*/
- TypeName _type;
+ TypeAnnotation _type;
/**
* Initialize a newly created formal parameter. Either or both of the
@@ -9000,7 +9209,7 @@
* specified. The [type] must be `null` if the keyword is 'var'.
*/
SimpleFormalParameterImpl(CommentImpl comment, List<Annotation> metadata,
- this.keyword, TypeNameImpl type, SimpleIdentifierImpl identifier)
+ this.keyword, TypeAnnotationImpl type, SimpleIdentifierImpl identifier)
: super(comment, metadata, identifier) {
_type = _becomeParentOf(type);
}
@@ -9032,11 +9241,11 @@
bool get isFinal => keyword?.keyword == Keyword.FINAL;
@override
- TypeName get type => _type;
+ TypeAnnotation get type => _type;
@override
- void set type(TypeName typeName) {
- _type = _becomeParentOf(typeName as AstNodeImpl);
+ void set type(TypeAnnotation type) {
+ _type = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -10299,6 +10508,16 @@
}
/**
+ * A type annotation.
+ *
+ * type ::=
+ * [NamedType]
+ * | [GenericFunctionType]
+ */
+abstract class TypeAnnotationImpl extends AstNodeImpl
+ implements TypeAnnotation {}
+
+/**
* A list of type arguments.
*
* typeArguments ::=
@@ -10313,7 +10532,7 @@
/**
* The type arguments associated with the type.
*/
- NodeList<TypeName> _arguments;
+ NodeList<TypeAnnotation> _arguments;
/**
* The right bracket.
@@ -10324,12 +10543,12 @@
* Initialize a newly created list of type arguments.
*/
TypeArgumentListImpl(
- this.leftBracket, List<TypeName> arguments, this.rightBracket) {
- _arguments = new NodeListImpl<TypeName>(this, arguments);
+ this.leftBracket, List<TypeAnnotation> arguments, this.rightBracket) {
+ _arguments = new NodeListImpl<TypeAnnotation>(this, arguments);
}
@override
- NodeList<TypeName> get arguments => _arguments;
+ NodeList<TypeAnnotation> get arguments => _arguments;
@override
Token get beginToken => leftBracket;
@@ -10406,7 +10625,7 @@
* typeName ::=
* [Identifier] typeArguments?
*/
-class TypeNameImpl extends AstNodeImpl implements TypeName {
+class TypeNameImpl extends TypeAnnotationImpl implements TypeName {
/**
* The name of the type.
*/
@@ -10512,7 +10731,7 @@
* The name of the upper bound for legal arguments, or `null` if there is no
* explicit upper bound.
*/
- TypeName _bound;
+ TypeAnnotation _bound;
/**
* Initialize a newly created type parameter. Either or both of the [comment]
@@ -10521,18 +10740,18 @@
* the parameter does not have an upper bound.
*/
TypeParameterImpl(CommentImpl comment, List<Annotation> metadata,
- SimpleIdentifierImpl name, this.extendsKeyword, TypeNameImpl bound)
+ SimpleIdentifierImpl name, this.extendsKeyword, TypeAnnotationImpl bound)
: super(comment, metadata) {
_name = _becomeParentOf(name);
_bound = _becomeParentOf(bound);
}
@override
- TypeName get bound => _bound;
+ TypeAnnotation get bound => _bound;
@override
- void set bound(TypeName typeName) {
- _bound = _becomeParentOf(typeName as AstNodeImpl);
+ void set bound(TypeAnnotation type) {
+ _bound = _becomeParentOf(type as AstNodeImpl);
}
@override
@@ -10890,7 +11109,7 @@
/**
* The type of the variables being declared, or `null` if no type was provided.
*/
- TypeName _type;
+ TypeAnnotation _type;
/**
* A list containing the individual variables being declared.
@@ -10903,8 +11122,12 @@
* the corresponding attribute. The [keyword] can be `null` if a type was
* specified. The [type] must be `null` if the keyword is 'var'.
*/
- VariableDeclarationListImpl(CommentImpl comment, List<Annotation> metadata,
- this.keyword, TypeNameImpl type, List<VariableDeclaration> variables)
+ VariableDeclarationListImpl(
+ CommentImpl comment,
+ List<Annotation> metadata,
+ this.keyword,
+ TypeAnnotationImpl type,
+ List<VariableDeclaration> variables)
: super(comment, metadata) {
_type = _becomeParentOf(type);
_variables = new NodeListImpl<VariableDeclaration>(this, variables);
@@ -10937,11 +11160,11 @@
bool get isFinal => keyword?.keyword == Keyword.FINAL;
@override
- TypeName get type => _type;
+ TypeAnnotation get type => _type;
@override
- void set type(TypeName typeName) {
- _type = _becomeParentOf(typeName as AstNodeImpl);
+ void set type(TypeAnnotation type) {
+ _type = _becomeParentOf(type as AstNodeImpl);
}
@override
diff --git a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
index 72079b6..482ae01 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
@@ -29,7 +29,7 @@
@override
AsExpression asExpression(
- Expression expression, Token asOperator, TypeName type) =>
+ Expression expression, Token asOperator, TypeAnnotation type) =>
new AsExpressionImpl(expression, asOperator, type);
@override
@@ -98,7 +98,7 @@
@override
CatchClause catchClause(
Token onKeyword,
- TypeName exceptionType,
+ TypeAnnotation exceptionType,
Token catchKeyword,
Token leftParenthesis,
SimpleIdentifier exceptionParameter,
@@ -262,7 +262,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
SimpleIdentifier identifier) =>
new DeclaredIdentifierImpl(comment, metadata, keyword, type, identifier);
@@ -367,7 +367,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
Token thisKeyword,
Token period,
SimpleIdentifier identifier,
@@ -455,7 +455,7 @@
Comment comment,
List<Annotation> metadata,
Token externalKeyword,
- TypeName returnType,
+ TypeAnnotation returnType,
Token propertyKeyword,
SimpleIdentifier name,
FunctionExpression functionExpression) =>
@@ -483,7 +483,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName returnType,
+ TypeAnnotation returnType,
SimpleIdentifier name,
TypeParameterList typeParameters,
FormalParameterList parameters,
@@ -495,7 +495,7 @@
FunctionTypedFormalParameter functionTypedFormalParameter(
Comment comment,
List<Annotation> metadata,
- TypeName returnType,
+ TypeAnnotation returnType,
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters,
@@ -504,6 +504,28 @@
identifier, typeParameters, parameters, question);
@override
+ GenericFunctionType genericFunctionType(
+ TypeAnnotation returnType,
+ Token functionKeyword,
+ TypeParameterList typeParameters,
+ FormalParameterList _parameters) =>
+ new GenericFunctionTypeImpl(
+ returnType, functionKeyword, typeParameters, _parameters);
+
+ @override
+ GenericTypeAlias genericTypeAlias(
+ Comment comment,
+ List<Annotation> metadata,
+ Token typedefKeyword,
+ SimpleIdentifier name,
+ TypeParameterList typeParameters,
+ Token equals,
+ GenericFunctionType functionType,
+ Token semicolon) =>
+ new GenericTypeAliasImpl(comment, metadata, typedefKeyword, name,
+ typeParameters, equals, functionType, semicolon);
+
+ @override
HideCombinator hideCombinator(
Token keyword, List<SimpleIdentifier> hiddenNames) =>
new HideCombinatorImpl(keyword, hiddenNames);
@@ -582,7 +604,7 @@
@override
IsExpression isExpression(Expression expression, Token isOperator,
- Token notOperator, TypeName type) =>
+ Token notOperator, TypeAnnotation type) =>
new IsExpressionImpl(expression, isOperator, notOperator, type);
@override
@@ -630,7 +652,7 @@
List<Annotation> metadata,
Token externalKeyword,
Token modifierKeyword,
- TypeName returnType,
+ TypeAnnotation returnType,
Token propertyKeyword,
Token operatorKeyword,
SimpleIdentifier name,
@@ -753,7 +775,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
SimpleIdentifier identifier) =>
new SimpleFormalParameterImpl(
comment, metadata, keyword, type, identifier);
@@ -787,7 +809,6 @@
@override
SuperExpression superExpression(Token superKeyword) =>
new SuperExpressionImpl(superKeyword);
-
@override
SwitchCase switchCase(List<Label> labels, Token keyword,
Expression expression, Token colon, List<Statement> statements) =>
@@ -797,6 +818,7 @@
SwitchDefault switchDefault(List<Label> labels, Token keyword, Token colon,
List<Statement> statements) =>
new SwitchDefaultImpl(labels, keyword, colon, statements);
+
@override
SwitchStatement switchStatement(
Token switchKeyword,
@@ -841,8 +863,8 @@
tryKeyword, body, catchClauses, finallyKeyword, finallyBlock);
@override
- TypeArgumentList typeArgumentList(
- Token leftBracket, List<TypeName> arguments, Token rightBracket) =>
+ TypeArgumentList typeArgumentList(Token leftBracket,
+ List<TypeAnnotation> arguments, Token rightBracket) =>
new TypeArgumentListImpl(leftBracket, arguments, rightBracket);
@override
@@ -852,7 +874,7 @@
@override
TypeParameter typeParameter(Comment comment, List<Annotation> metadata,
- SimpleIdentifier name, Token extendsKeyword, TypeName bound) =>
+ SimpleIdentifier name, Token extendsKeyword, TypeAnnotation bound) =>
new TypeParameterImpl(comment, metadata, name, extendsKeyword, bound);
@override
@@ -870,7 +892,7 @@
Comment comment,
List<Annotation> metadata,
Token keyword,
- TypeName type,
+ TypeAnnotation type,
List<VariableDeclaration> variables) =>
new VariableDeclarationListImpl(
comment, metadata, keyword, type, variables);
diff --git a/pkg/analyzer/lib/src/dart/ast/resolution_map.dart b/pkg/analyzer/lib/src/dart/ast/resolution_map.dart
index 975f97d..3fe5d0f 100644
--- a/pkg/analyzer/lib/src/dart/ast/resolution_map.dart
+++ b/pkg/analyzer/lib/src/dart/ast/resolution_map.dart
@@ -151,7 +151,7 @@
DartType staticTypeForExpression(Expression node) => node.staticType;
@override
- DartType typeForTypeName(TypeName node) => node.type;
+ DartType typeForTypeName(TypeAnnotation node) => node.type;
@override
Element uriElementForDirective(UriBasedDirective node) => node.uriElement;
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index d23485a..f615ef3 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -551,6 +551,26 @@
cloneNode(node.parameters));
@override
+ AstNode visitGenericFunctionType(GenericFunctionType node) =>
+ astFactory.genericFunctionType(
+ cloneNode(node.returnType),
+ cloneToken(node.functionKeyword),
+ cloneNode(node.typeParameters),
+ cloneNode(node.parameters));
+
+ @override
+ AstNode visitGenericTypeAlias(GenericTypeAlias node) =>
+ astFactory.genericTypeAlias(
+ cloneNode(node.documentationComment),
+ cloneNodeList(node.metadata),
+ cloneToken(node.typedefKeyword),
+ cloneNode(node.name),
+ cloneNode(node.typeParameters),
+ cloneToken(node.equals),
+ cloneNode(node.functionType),
+ cloneToken(node.semicolon));
+
+ @override
HideCombinator visitHideCombinator(HideCombinator node) =>
astFactory.hideCombinator(
cloneToken(node.keyword), cloneNodeList(node.hiddenNames));
@@ -1588,6 +1608,28 @@
}
@override
+ bool visitGenericFunctionType(GenericFunctionType node) {
+ GenericFunctionType other = _other as GenericFunctionType;
+ return isEqualNodes(node.returnType, other.returnType) &&
+ isEqualTokens(node.functionKeyword, other.functionKeyword) &&
+ isEqualNodes(node.typeParameters, other.typeParameters) &&
+ isEqualNodes(node.parameters, other.parameters);
+ }
+
+ @override
+ bool visitGenericTypeAlias(GenericTypeAlias node) {
+ GenericTypeAlias other = _other as GenericTypeAlias;
+ return isEqualNodes(
+ node.documentationComment, other.documentationComment) &&
+ _isEqualNodeLists(node.metadata, other.metadata) &&
+ isEqualTokens(node.typedefKeyword, other.typedefKeyword) &&
+ isEqualNodes(node.name, other.name) &&
+ isEqualNodes(node.typeParameters, other.typeParameters) &&
+ isEqualTokens(node.equals, other.equals) &&
+ isEqualNodes(node.functionType, other.functionType);
+ }
+
+ @override
bool visitHideCombinator(HideCombinator node) {
HideCombinator other = _other as HideCombinator;
return isEqualTokens(node.keyword, other.keyword) &&
@@ -3260,6 +3302,26 @@
_cloneNode(node.parameters));
@override
+ AstNode visitGenericFunctionType(GenericFunctionType node) =>
+ astFactory.genericFunctionType(
+ _cloneNode(node.returnType),
+ _mapToken(node.functionKeyword),
+ _cloneNode(node.typeParameters),
+ _cloneNode(node.parameters));
+
+ @override
+ AstNode visitGenericTypeAlias(GenericTypeAlias node) =>
+ astFactory.genericTypeAlias(
+ _cloneNode(node.documentationComment),
+ _cloneNodeList(node.metadata),
+ _mapToken(node.typedefKeyword),
+ _cloneNode(node.name),
+ _cloneNode(node.typeParameters),
+ _mapToken(node.equals),
+ _cloneNode(node.functionType),
+ _mapToken(node.semicolon));
+
+ @override
HideCombinator visitHideCombinator(HideCombinator node) =>
astFactory.hideCombinator(
_mapToken(node.keyword), _cloneNodeList(node.hiddenNames));
@@ -4107,7 +4169,7 @@
node.expression = _newNode as Expression;
return true;
} else if (identical(node.type, _oldNode)) {
- node.type = _newNode as TypeName;
+ node.type = _newNode as TypeAnnotation;
return true;
}
return visitNode(node);
@@ -4215,7 +4277,7 @@
@override
bool visitCatchClause(CatchClause node) {
if (identical(node.exceptionType, _oldNode)) {
- node.exceptionType = _newNode as TypeName;
+ node.exceptionType = _newNode as TypeAnnotation;
return true;
} else if (identical(node.exceptionParameter, _oldNode)) {
node.exceptionParameter = _newNode as SimpleIdentifier;
@@ -4393,7 +4455,7 @@
@override
bool visitDeclaredIdentifier(DeclaredIdentifier node) {
if (identical(node.type, _oldNode)) {
- node.type = _newNode as TypeName;
+ node.type = _newNode as TypeAnnotation;
return true;
} else if (identical(node.identifier, _oldNode)) {
node.identifier = _newNode as SimpleIdentifier;
@@ -4506,7 +4568,7 @@
@override
bool visitFieldFormalParameter(FieldFormalParameter node) {
if (identical(node.type, _oldNode)) {
- node.type = _newNode as TypeName;
+ node.type = _newNode as TypeAnnotation;
return true;
} else if (identical(node.parameters, _oldNode)) {
node.parameters = _newNode as FormalParameterList;
@@ -4564,7 +4626,7 @@
@override
bool visitFunctionDeclaration(FunctionDeclaration node) {
if (identical(node.returnType, _oldNode)) {
- node.returnType = _newNode as TypeName;
+ node.returnType = _newNode as TypeAnnotation;
return true;
} else if (identical(node.name, _oldNode)) {
node.name = _newNode as SimpleIdentifier;
@@ -4612,7 +4674,7 @@
@override
bool visitFunctionTypeAlias(FunctionTypeAlias node) {
if (identical(node.returnType, _oldNode)) {
- node.returnType = _newNode as TypeName;
+ node.returnType = _newNode as TypeAnnotation;
return true;
} else if (identical(node.name, _oldNode)) {
node.name = _newNode as SimpleIdentifier;
@@ -4630,7 +4692,7 @@
@override
bool visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
if (identical(node.returnType, _oldNode)) {
- node.returnType = _newNode as TypeName;
+ node.returnType = _newNode as TypeAnnotation;
return true;
} else if (identical(node.parameters, _oldNode)) {
node.parameters = _newNode as FormalParameterList;
@@ -4640,6 +4702,38 @@
}
@override
+ bool visitGenericFunctionType(GenericFunctionType node) {
+ if (identical(node.returnType, _oldNode)) {
+ node.returnType = _newNode as TypeAnnotation;
+ return true;
+ } else if (identical(node.typeParameters, _oldNode)) {
+ node.typeParameters = _newNode as TypeParameterList;
+ return true;
+ } else if (identical(node.parameters, _oldNode)) {
+ node.parameters = _newNode as FormalParameterList;
+ return true;
+ }
+ return null;
+ }
+
+ @override
+ bool visitGenericTypeAlias(GenericTypeAlias node) {
+ if (identical(node.name, _oldNode)) {
+ node.name = _newNode as SimpleIdentifier;
+ return true;
+ } else if (identical(node.typeParameters, _oldNode)) {
+ node.typeParameters = _newNode as TypeParameterList;
+ return true;
+ } else if (identical(node.functionType, _oldNode)) {
+ node.functionType = _newNode as GenericFunctionType;
+ return true;
+ } else if (_replaceInList(node.metadata)) {
+ return true;
+ }
+ return visitNode(node);
+ }
+
+ @override
bool visitHideCombinator(HideCombinator node) {
if (_replaceInList(node.hiddenNames)) {
return true;
@@ -4724,7 +4818,7 @@
node.expression = _newNode as Expression;
return true;
} else if (identical(node.type, _oldNode)) {
- node.type = _newNode as TypeName;
+ node.type = _newNode as TypeAnnotation;
return true;
}
return visitNode(node);
@@ -4798,7 +4892,7 @@
@override
bool visitMethodDeclaration(MethodDeclaration node) {
if (identical(node.returnType, _oldNode)) {
- node.returnType = _newNode as TypeName;
+ node.returnType = _newNode as TypeAnnotation;
return true;
} else if (identical(node.name, _oldNode)) {
node.name = _newNode as SimpleIdentifier;
@@ -4987,7 +5081,7 @@
@override
bool visitSimpleFormalParameter(SimpleFormalParameter node) {
if (identical(node.type, _oldNode)) {
- node.type = _newNode as TypeName;
+ node.type = _newNode as TypeAnnotation;
return true;
}
return visitNormalFormalParameter(node);
@@ -5126,7 +5220,7 @@
node.name = _newNode as SimpleIdentifier;
return true;
} else if (identical(node.bound, _oldNode)) {
- node.bound = _newNode as TypeName;
+ node.bound = _newNode as TypeAnnotation;
return true;
}
return visitNode(node);
@@ -5163,7 +5257,7 @@
@override
bool visitVariableDeclarationList(VariableDeclarationList node) {
if (identical(node.type, _oldNode)) {
- node.type = _newNode as TypeName;
+ node.type = _newNode as TypeAnnotation;
return true;
} else if (_replaceInList(node.variables)) {
return true;
@@ -5865,6 +5959,38 @@
}
@override
+ bool visitGenericFunctionType(GenericFunctionType node) {
+ GenericFunctionType toNode = this._toNode as GenericFunctionType;
+ if (_and(
+ _isEqualNodes(node.returnType, toNode.returnType),
+ _isEqualTokens(node.functionKeyword, toNode.functionKeyword),
+ _isEqualNodes(node.typeParameters, toNode.typeParameters),
+ _isEqualNodes(node.parameters, toNode.parameters))) {
+ // TODO(brianwilkerson) Copy the type information.
+ return true;
+ }
+ return false;
+ }
+
+ @override
+ bool visitGenericTypeAlias(GenericTypeAlias node) {
+ GenericTypeAlias toNode = this._toNode as GenericTypeAlias;
+ if (_and(
+ _isEqualNodes(node.documentationComment, toNode.documentationComment),
+ _isEqualNodeLists(node.metadata, toNode.metadata),
+ _isEqualTokens(node.typedefKeyword, toNode.typedefKeyword),
+ _isEqualNodes(node.name, toNode.name),
+ _isEqualNodes(node.typeParameters, toNode.typeParameters),
+ _isEqualTokens(node.equals, toNode.equals),
+ _isEqualNodes(node.functionType, toNode.functionType),
+ _isEqualTokens(node.semicolon, toNode.semicolon))) {
+ // TODO(brianwilkerson) Copy the type and element information.
+ return true;
+ }
+ return false;
+ }
+
+ @override
bool visitHideCombinator(HideCombinator node) {
HideCombinator toNode = this._toNode as HideCombinator;
return _and(_isEqualTokens(node.keyword, toNode.keyword),
@@ -7395,6 +7521,26 @@
}
@override
+ Object visitGenericFunctionType(GenericFunctionType node) {
+ _visitNode(node.returnType);
+ _writer.print(' Function ');
+ _visitNode(node.typeParameters);
+ _visitNode(node.parameters);
+ return null;
+ }
+
+ @override
+ Object visitGenericTypeAlias(GenericTypeAlias node) {
+ _visitNodeListWithSeparatorAndSuffix(node.metadata, " ", " ");
+ _writer.print("typedef ");
+ _visitNode(node.name);
+ _visitNode(node.typeParameters);
+ _writer.print(" = ");
+ _visitNode(node.functionType);
+ return null;
+ }
+
+ @override
Object visitHideCombinator(HideCombinator node) {
_writer.print("hide ");
_visitNodeListWithSeparator(node.hiddenNames, ", ");
@@ -8682,6 +8828,26 @@
}
@override
+ Object visitGenericFunctionType(GenericFunctionType node) {
+ safelyVisitNode(node.returnType);
+ sink.write(' Function ');
+ safelyVisitNode(node.typeParameters);
+ safelyVisitNode(node.parameters);
+ return null;
+ }
+
+ @override
+ Object visitGenericTypeAlias(GenericTypeAlias node) {
+ safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " ");
+ sink.write("typedef ");
+ safelyVisitNode(node.name);
+ safelyVisitNode(node.typeParameters);
+ sink.write(" = ");
+ safelyVisitNode(node.functionType);
+ return null;
+ }
+
+ @override
Object visitHideCombinator(HideCombinator node) {
sink.write("hide ");
safelyVisitNodeListWithSeparator(node.hiddenNames, ", ");
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 23ad1a2..4718171 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -8,6 +8,7 @@
import 'package:analyzer/context/declared_variables.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/standard_ast_factory.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/constant/value.dart';
@@ -29,7 +30,6 @@
import 'package:analyzer/src/generated/utilities_collection.dart';
import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind;
import 'package:analyzer/src/task/dart.dart';
-import 'package:analyzer/dart/ast/standard_ast_factory.dart';
/**
* Helper class encapsulating the methods for evaluating constants and
@@ -1292,8 +1292,8 @@
}
ParameterizedType thenType = thenResult.type;
ParameterizedType elseType = elseResult.type;
- return new DartObjectImpl.validWithUnknownValue(
- _typeSystem.getLeastUpperBound(thenType, elseType) as InterfaceType);
+ return new DartObjectImpl.validWithUnknownValue(_typeSystem
+ .getLeastUpperBound(thenType, elseType) as ParameterizedType);
}
@override
@@ -1358,9 +1358,9 @@
return null;
}
DartType elementType = _typeProvider.dynamicType;
- NodeList<TypeName> typeArgs = node.typeArguments?.arguments;
+ NodeList<TypeAnnotation> typeArgs = node.typeArguments?.arguments;
if (typeArgs?.length == 1) {
- DartType type = visitTypeName(typeArgs[0])?.toTypeValue();
+ DartType type = visitTypeAnnotation(typeArgs[0])?.toTypeValue();
if (type != null) {
elementType = type;
}
@@ -1393,13 +1393,15 @@
}
DartType keyType = _typeProvider.dynamicType;
DartType valueType = _typeProvider.dynamicType;
- NodeList<TypeName> typeArgs = node.typeArguments?.arguments;
+ NodeList<TypeAnnotation> typeArgs = node.typeArguments?.arguments;
if (typeArgs?.length == 2) {
- DartType keyTypeCandidate = visitTypeName(typeArgs[0])?.toTypeValue();
+ DartType keyTypeCandidate =
+ visitTypeAnnotation(typeArgs[0])?.toTypeValue();
if (keyTypeCandidate != null) {
keyType = keyTypeCandidate;
}
- DartType valueTypeCandidate = visitTypeName(typeArgs[1])?.toTypeValue();
+ DartType valueTypeCandidate =
+ visitTypeAnnotation(typeArgs[1])?.toTypeValue();
if (valueTypeCandidate != null) {
valueType = valueTypeCandidate;
}
@@ -1549,8 +1551,7 @@
_typeProvider.symbolType, new SymbolState(buffer.toString()));
}
- @override
- DartObjectImpl visitTypeName(TypeName node) {
+ DartObjectImpl visitTypeAnnotation(TypeAnnotation node) {
DartType type = evaluateType(node.type);
if (type == null) {
return super.visitTypeName(node);
@@ -1558,6 +1559,9 @@
return typeConstant(type);
}
+ @override
+ DartObjectImpl visitTypeName(TypeName node) => visitTypeAnnotation(node);
+
/**
* Create an error associated with the given [node]. The error will have the
* given error [code].
diff --git a/pkg/analyzer/lib/src/dart/constant/value.dart b/pkg/analyzer/lib/src/dart/constant/value.dart
index db4de37..a927df6 100644
--- a/pkg/analyzer/lib/src/dart/constant/value.dart
+++ b/pkg/analyzer/lib/src/dart/constant/value.dart
@@ -144,9 +144,6 @@
*/
static const List<DartObjectImpl> EMPTY_LIST = const <DartObjectImpl>[];
- /**
- * The run-time type of this object.
- */
@override
final ParameterizedType type;
@@ -163,7 +160,7 @@
/**
* Create an object to represent an unknown value.
*/
- factory DartObjectImpl.validWithUnknownValue(InterfaceType type) {
+ factory DartObjectImpl.validWithUnknownValue(ParameterizedType type) {
if (type.element.library.isDartCore) {
String typeName = type.name;
if (typeName == "bool") {
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 58932c6..968c18f 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -833,11 +833,12 @@
@override
bool isSubtypeOf(DartType type) {
+ var typeSystem = new TypeSystemImpl(null);
return relate(
- this,
- type,
+ typeSystem.instantiateToBounds(this),
+ typeSystem.instantiateToBounds(type),
(DartType t, DartType s, _, __) => t.isAssignableTo(s),
- new TypeSystemImpl(null).instantiateToBounds);
+ typeSystem.instantiateToBounds);
}
@override
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index 5c44f86..962e6f6 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -1575,7 +1575,7 @@
if (invokeType is FunctionType) {
List<TypeParameterElement> parameters = invokeType.typeFormals;
- NodeList<TypeName> arguments = typeArguments?.arguments;
+ NodeList<TypeAnnotation> arguments = typeArguments?.arguments;
if (arguments != null && arguments.length != parameters.length) {
if (_resolver.strongMode) {
_resolver.errorReporter.reportErrorForNode(
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 52aec1a..1b99f57 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -768,7 +768,7 @@
methodName = identifier.name;
}
_enclosingFunction = functionElement;
- TypeName returnType = node.returnType;
+ TypeAnnotation returnType = node.returnType;
if (node.isSetter || node.isGetter) {
_checkForMismatchedAccessorTypes(node, methodName);
if (node.isSetter) {
@@ -862,6 +862,20 @@
}
@override
+ Object visitGenericFunctionType(GenericFunctionType node) {
+ throw new StateError(
+ 'Support for generic function types is not yet implemented');
+// return super.visitGenericFunctionType(node);
+ }
+
+ @override
+ Object visitGenericTypeAlias(GenericTypeAlias node) {
+ throw new StateError(
+ 'Support for generic type aliases is not yet implemented');
+// return super.visitGenericTypeAlias(node);
+ }
+
+ @override
Object visitIfStatement(IfStatement node) {
_checkForNonBoolCondition(node.condition);
return super.visitIfStatement(node);
@@ -931,7 +945,7 @@
TypeArgumentList typeArguments = node.typeArguments;
if (typeArguments != null) {
if (!_options.strongMode && node.constKeyword != null) {
- NodeList<TypeName> arguments = typeArguments.arguments;
+ NodeList<TypeAnnotation> arguments = typeArguments.arguments;
if (arguments.isNotEmpty) {
_checkForInvalidTypeArgumentInConstTypedLiteral(arguments,
CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST);
@@ -948,7 +962,7 @@
Object visitMapLiteral(MapLiteral node) {
TypeArgumentList typeArguments = node.typeArguments;
if (typeArguments != null) {
- NodeList<TypeName> arguments = typeArguments.arguments;
+ NodeList<TypeAnnotation> arguments = typeArguments.arguments;
if (!_options.strongMode && arguments.isNotEmpty) {
if (node.constKeyword != null) {
_checkForInvalidTypeArgumentInConstTypedLiteral(arguments,
@@ -974,7 +988,7 @@
if (identifier != null) {
methodName = identifier.name;
}
- TypeName returnTypeName = node.returnType;
+ TypeAnnotation returnType = node.returnType;
if (node.isSetter || node.isGetter) {
_checkForMismatchedAccessorTypes(node, methodName);
}
@@ -985,7 +999,7 @@
_checkForInvalidModifierOnBody(
node.body, CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER);
_checkForWrongNumberOfParametersForSetter(node.name, node.parameters);
- _checkForNonVoidReturnTypeForSetter(returnTypeName);
+ _checkForNonVoidReturnTypeForSetter(returnType);
_checkForConflictingStaticSetterAndInstanceMember(node);
} else if (node.isOperator) {
_checkForOptionalParameterInOperator(node);
@@ -994,9 +1008,9 @@
}
_checkForConcreteClassWithAbstractMember(node);
_checkForAllInvalidOverrideErrorCodesForMethod(node);
- _checkForTypeAnnotationDeferredClass(returnTypeName);
- _checkForIllegalReturnType(returnTypeName);
- _checkForImplicitDynamicReturn(node.name, node.element);
+ _checkForTypeAnnotationDeferredClass(returnType);
+ _checkForIllegalReturnType(returnType);
+ _checkForImplicitDynamicReturn(node, node.element);
_checkForMustCallSuper(node);
return super.visitMethodDeclaration(node);
} finally {
@@ -1187,9 +1201,9 @@
@override
Object visitTypeArgumentList(TypeArgumentList node) {
- NodeList<TypeName> list = node.arguments;
- for (TypeName typeName in list) {
- _checkForTypeAnnotationDeferredClass(typeName);
+ NodeList<TypeAnnotation> list = node.arguments;
+ for (TypeAnnotation type in list) {
+ _checkForTypeAnnotationDeferredClass(type);
}
return super.visitTypeArgumentList(node);
}
@@ -3220,15 +3234,16 @@
}
/**
- * Verify that the given [typeName] does not reference any type parameters.
+ * Verify that the given [type] does not reference any type parameters.
*
* See [CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS].
*/
- void _checkForConstWithTypeParameters(TypeName typeName) {
+ void _checkForConstWithTypeParameters(TypeAnnotation type) {
// something wrong with AST
- if (typeName == null) {
+ if (type is! TypeName) {
return;
}
+ TypeName typeName = type;
Identifier name = typeName.name;
if (name == null) {
return;
@@ -3241,7 +3256,7 @@
// check type arguments
TypeArgumentList typeArguments = typeName.typeArguments;
if (typeArguments != null) {
- for (TypeName argument in typeArguments.arguments) {
+ for (TypeAnnotation argument in typeArguments.arguments) {
_checkForConstWithTypeParameters(argument);
}
}
@@ -3806,7 +3821,7 @@
* declared return type is assignable to Future, Stream, or Iterable,
* respectively. If not, report the error using [returnType].
*/
- void _checkForIllegalReturnType(TypeName returnType) {
+ void _checkForIllegalReturnType(TypeAnnotation returnType) {
if (returnType == null) {
// No declared return type, so the return type must be dynamic, which is
// assignable to everything.
@@ -3839,7 +3854,7 @@
* the declared [returnTypeName] is assignable to the required [expectedType]
* and if not report [errorCode].
*/
- void _checkForIllegalReturnTypeCode(TypeName returnTypeName,
+ void _checkForIllegalReturnTypeCode(TypeAnnotation returnTypeName,
DartType expectedType, StaticTypeWarningCode errorCode) {
DartType returnType = _enclosingFunction.returnType;
if (_options.strongMode) {
@@ -3986,10 +4001,10 @@
}
}
- void _checkForImplicitDynamicType(TypeName node) {
+ void _checkForImplicitDynamicType(TypeAnnotation node) {
if (_options.implicitDynamic ||
node == null ||
- node.typeArguments != null) {
+ (node is TypeName && node.typeArguments != null)) {
return;
}
DartType type = node.type;
@@ -4457,10 +4472,10 @@
* [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP].
*/
void _checkForInvalidTypeArgumentInConstTypedLiteral(
- NodeList<TypeName> arguments, ErrorCode errorCode) {
- for (TypeName typeName in arguments) {
- if (typeName.type is TypeParameterType) {
- _errorReporter.reportErrorForNode(errorCode, typeName, [typeName.name]);
+ NodeList<TypeAnnotation> arguments, ErrorCode errorCode) {
+ for (TypeAnnotation type in arguments) {
+ if (type is TypeName && type.type is TypeParameterType) {
+ _errorReporter.reportErrorForNode(errorCode, type, [type.name]);
}
}
}
@@ -5141,12 +5156,12 @@
return;
}
// check return type
- TypeName typeName = declaration.returnType;
- if (typeName != null) {
- DartType type = typeName.type;
+ TypeAnnotation annotation = declaration.returnType;
+ if (annotation != null) {
+ DartType type = annotation.type;
if (type != null && !type.isVoid) {
_errorReporter.reportErrorForNode(
- StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR, typeName);
+ StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR, annotation);
}
}
}
@@ -5157,7 +5172,7 @@
*
* See [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER].
*/
- void _checkForNonVoidReturnTypeForSetter(TypeName typeName) {
+ void _checkForNonVoidReturnTypeForSetter(TypeAnnotation typeName) {
if (typeName != null) {
DartType type = typeName.type;
if (type != null && !type.isVoid) {
@@ -5579,10 +5594,10 @@
*
* See [StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS].
*/
- void _checkForTypeAnnotationDeferredClass(TypeName name) {
- if (name != null && name.isDeferred) {
+ void _checkForTypeAnnotationDeferredClass(TypeAnnotation type) {
+ if (type is TypeName && type.isDeferred) {
_errorReporter.reportErrorForNode(
- StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS, name, [name.name]);
+ StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS, type, [type.name]);
}
}
@@ -5592,19 +5607,18 @@
*
* See [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER].
*/
- void _checkForTypeAnnotationGenericFunctionParameter(TypeName typeName) {
- if (typeName == null) {
- return;
- }
- Identifier name = typeName.name;
- if (name is SimpleIdentifier) {
- Element element = name.staticElement;
- if (element is TypeParameterElement &&
- element.enclosingElement is ExecutableElement) {
- _errorReporter.reportErrorForNode(
- StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER,
- name,
- [name.name]);
+ void _checkForTypeAnnotationGenericFunctionParameter(TypeAnnotation type) {
+ if (type is TypeName) {
+ Identifier name = type.name;
+ if (name is SimpleIdentifier) {
+ Element element = name.staticElement;
+ if (element is TypeParameterElement &&
+ element.enclosingElement is ExecutableElement) {
+ _errorReporter.reportErrorForNode(
+ StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER,
+ name,
+ [name.name]);
+ }
}
}
}
@@ -5631,14 +5645,14 @@
List<DartType> parameterTypes = element.type.typeArguments;
List<DartType> arguments = (type as ParameterizedType).typeArguments;
// iterate over each bounded type parameter and corresponding argument
- NodeList<TypeName> typeNameArgList = typeName.typeArguments.arguments;
+ NodeList<TypeAnnotation> argumentNodes = typeName.typeArguments.arguments;
int loopThroughIndex =
- math.min(typeNameArgList.length, parameterElements.length);
+ math.min(argumentNodes.length, parameterElements.length);
bool shouldSubstitute =
arguments.length != 0 && arguments.length == parameterTypes.length;
for (int i = 0; i < loopThroughIndex; i++) {
- TypeName argTypeName = typeNameArgList[i];
- DartType argType = argTypeName.type;
+ TypeAnnotation argumentNode = argumentNodes[i];
+ DartType argType = argumentNode.type;
DartType boundType = parameterElements[i].bound;
if (argType != null && boundType != null) {
if (shouldSubstitute) {
@@ -5654,7 +5668,7 @@
StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS;
}
_errorReporter.reportTypeErrorForNode(
- errorCode, argTypeName, [argType, boundType]);
+ errorCode, argumentNode, [argType, boundType]);
}
}
}
@@ -5864,12 +5878,11 @@
* See [StaticWarningCode.VOID_RETURN_FOR_GETTER].
*/
void _checkForVoidReturnType(MethodDeclaration getter) {
- TypeName returnType = getter.returnType;
- if (returnType == null || returnType.name.name != "void") {
- return;
+ TypeAnnotation returnType = getter.returnType;
+ if (returnType is TypeName && returnType.name.name == "void") {
+ _errorReporter.reportErrorForNode(
+ StaticWarningCode.VOID_RETURN_FOR_GETTER, returnType);
}
- _errorReporter.reportErrorForNode(
- StaticWarningCode.VOID_RETURN_FOR_GETTER, returnType);
}
/**
@@ -6077,8 +6090,8 @@
if (element == null || typeArguments == null) {
return;
}
- void reportError(
- TypeName argument, DartType argumentType, DartType parameterType) {
+ void reportError(TypeAnnotation argument, DartType argumentType,
+ DartType parameterType) {
_errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
argument,
@@ -6102,16 +6115,16 @@
List<TypeParameterElement> typeParameters,
TypeArgumentList typeArgumentList,
DartType targetType,
- void reportError(
- TypeName argument, DartType argumentType, DartType parameterType)) {
- NodeList<TypeName> typeArguments = typeArgumentList.arguments;
+ void reportError(TypeAnnotation argument, DartType argumentType,
+ DartType parameterType)) {
+ NodeList<TypeAnnotation> typeArguments = typeArgumentList.arguments;
int argumentsLength = typeArguments.length;
int maxIndex = math.min(typeParameters.length, argumentsLength);
bool shouldSubstitute =
argumentsLength != 0 && argumentsLength == typeParameters.length;
List<DartType> argumentTypes = shouldSubstitute
- ? typeArguments.map((TypeName typeName) => typeName.type).toList()
+ ? typeArguments.map((TypeAnnotation type) => type.type).toList()
: null;
List<DartType> parameterTypes = shouldSubstitute
? typeParameters
@@ -6120,8 +6133,8 @@
: null;
List<DartType> targetTypeParameterTypes = null;
for (int i = 0; i < maxIndex; i++) {
- TypeName argTypeName = typeArguments[i];
- DartType argType = argTypeName.type;
+ TypeAnnotation argument = typeArguments[i];
+ DartType argType = argument.type;
DartType boundType = typeParameters[i].bound;
if (argType != null && boundType != null) {
if (targetType is ParameterizedType) {
@@ -6137,7 +6150,7 @@
boundType = boundType.substitute2(argumentTypes, parameterTypes);
}
if (!_typeSystem.isSubtypeOf(argType, boundType)) {
- reportError(argTypeName, argType, boundType);
+ reportError(argument, argType, boundType);
}
}
}
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 2e1b856..6e3ecfc 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -372,13 +372,13 @@
*/
bool _checkAllTypeChecks(IsExpression node) {
Expression expression = node.expression;
- TypeName typeName = node.type;
+ TypeAnnotation typeName = node.type;
DartType lhsType = expression.staticType;
DartType rhsType = typeName.type;
if (lhsType == null || rhsType == null) {
return false;
}
- String rhsNameStr = typeName.name.name;
+ String rhsNameStr = typeName is TypeName ? typeName.name.name : null;
// if x is dynamic
if (rhsType.isDynamic && rhsNameStr == Keyword.DYNAMIC.syntax) {
if (node.notOperator == null) {
@@ -884,7 +884,7 @@
* @return `true` if and only if a hint code is generated on the passed node
* See [HintCode.MISSING_RETURN].
*/
- void _checkForMissingReturn(TypeName returnType, FunctionBody body) {
+ void _checkForMissingReturn(TypeAnnotation returnType, FunctionBody body) {
// Check that the method or function has a return type, and a function body
if (returnType == null || body == null) {
return;
@@ -1847,8 +1847,7 @@
* [HintCode.IS_NOT_INT].
*/
bool _checkForIsDoubleHints(IsExpression node) {
- TypeName typeName = node.type;
- DartType type = typeName.type;
+ DartType type = node.type.type;
Element element = type?.element;
if (element != null) {
String typeNameStr = element.name;
@@ -3020,6 +3019,9 @@
}
@override
+ bool visitGenericFunctionType(GenericFunctionType node) => false;
+
+ @override
bool visitIdentifier(Identifier node) => false;
@override
@@ -6092,6 +6094,9 @@
}
@override
+ Object visitGenericFunctionType(GenericFunctionType node) => null;
+
+ @override
Object visitHideCombinator(HideCombinator node) => null;
@override
@@ -8025,7 +8030,7 @@
}
/**
- * Helper for resolving [TypeName]s.
+ * Helper for resolving types.
*
* The client must set [nameScope] before calling [resolveTypeName].
*/
@@ -8304,15 +8309,14 @@
return;
}
if (argumentList != null) {
- NodeList<TypeName> arguments = argumentList.arguments;
+ NodeList<TypeAnnotation> arguments = argumentList.arguments;
int argumentCount = arguments.length;
List<DartType> parameters = typeSystem.typeFormalsAsTypes(type);
int parameterCount = parameters.length;
List<DartType> typeArguments = new List<DartType>(parameterCount);
if (argumentCount == parameterCount) {
for (int i = 0; i < parameterCount; i++) {
- TypeName argumentTypeName = arguments[i];
- DartType argumentType = _getType(argumentTypeName);
+ DartType argumentType = _getType(arguments[i]);
if (argumentType == null) {
argumentType = dynamicType;
}
@@ -8334,16 +8338,12 @@
}
/**
- * The number of type arguments in the given type name does not match the number of parameters in
- * the corresponding class element. Return the error code that should be used to report this
- * error.
- *
- * @param node the type name with the wrong number of type arguments
- * @return the error code that should be used to report that the wrong number of type arguments
- * were provided
+ * The number of type arguments in the given [typeName] does not match the
+ * number of parameters in the corresponding class element. Return the error
+ * code that should be used to report this error.
*/
- ErrorCode _getInvalidTypeParametersErrorCode(TypeName node) {
- AstNode parent = node.parent;
+ ErrorCode _getInvalidTypeParametersErrorCode(TypeName typeName) {
+ AstNode parent = typeName.parent;
if (parent is ConstructorName) {
parent = parent.parent;
if (parent is InstanceCreationExpression) {
@@ -8358,11 +8358,7 @@
}
/**
- * Checks if the given type name is the target in a redirected constructor.
- *
- * @param typeName the type name to analyze
- * @return some [RedirectingConstructorKind] if the given type name is used as the type in a
- * redirected constructor, or `null` otherwise
+ * Checks if the given [typeName] is the target in a redirected constructor.
*/
RedirectingConstructorKind _getRedirectingConstructorKind(TypeName typeName) {
AstNode parent = typeName.parent;
@@ -8381,13 +8377,10 @@
}
/**
- * Return the type represented by the given type name.
- *
- * @param typeName the type name representing the type to be returned
- * @return the type represented by the type name
+ * Return the type represented by the given type [annotation].
*/
- DartType _getType(TypeName typeName) {
- DartType type = typeName.type;
+ DartType _getType(TypeAnnotation annotation) {
+ DartType type = annotation.type;
if (type == null) {
return undefinedType;
}
@@ -8431,10 +8424,7 @@
}
/**
- * Checks if the given type name is used as the type in an as expression.
- *
- * @param typeName the type name to analyzer
- * @return `true` if the given type name is used as the type in an as expression
+ * Checks if the given [typeName] is used as the type in an as expression.
*/
bool _isTypeNameInAsExpression(TypeName typeName) {
AstNode parent = typeName.parent;
@@ -8445,10 +8435,8 @@
}
/**
- * Checks if the given type name is used as the exception type in a catch clause.
- *
- * @param typeName the type name to analyzer
- * @return `true` if the given type name is used as the exception type in a catch clause
+ * Checks if the given [typeName] is used as the exception type in a catch
+ * clause.
*/
bool _isTypeNameInCatchClause(TypeName typeName) {
AstNode parent = typeName.parent;
@@ -8459,11 +8447,8 @@
}
/**
- * Checks if the given type name is used as the type in an instance creation expression.
- *
- * @param typeName the type name to analyzer
- * @return `true` if the given type name is used as the type in an instance creation
- * expression
+ * Checks if the given [typeName] is used as the type in an instance creation
+ * expression.
*/
bool _isTypeNameInInstanceCreationExpression(TypeName typeName) {
AstNode parent = typeName.parent;
@@ -8475,10 +8460,7 @@
}
/**
- * Checks if the given type name is used as the type in an is expression.
- *
- * @param typeName the type name to analyzer
- * @return `true` if the given type name is used as the type in an is expression
+ * Checks if the given [typeName] is used as the type in an is expression.
*/
bool _isTypeNameInIsExpression(TypeName typeName) {
AstNode parent = typeName.parent;
@@ -8489,10 +8471,7 @@
}
/**
- * Checks if the given type name used in a type argument list.
- *
- * @param typeName the type name to analyzer
- * @return `true` if the given type name is in a type argument list
+ * Checks if the given [typeName] used in a type argument list.
*/
bool _isTypeNameInTypeArgumentList(TypeName typeName) =>
typeName.parent is TypeArgumentList;
@@ -8515,24 +8494,24 @@
}
/**
- * @return `true` if the name of the given [TypeName] is an built-in identifier.
+ * Return `true` if the name of the given [typeName] is an built-in identifier.
*/
- static bool _isBuiltInIdentifier(TypeName node) {
- Token token = node.name.beginToken;
+ static bool _isBuiltInIdentifier(TypeName typeName) {
+ Token token = typeName.name.beginToken;
return token.type == TokenType.KEYWORD;
}
/**
- * @return `true` if given [TypeName] is used as a type annotation.
+ * @return `true` if given [typeName] is used as a type annotation.
*/
- static bool _isTypeAnnotation(TypeName node) {
- AstNode parent = node.parent;
+ static bool _isTypeAnnotation(TypeName typeName) {
+ AstNode parent = typeName.parent;
if (parent is VariableDeclarationList) {
- return identical(parent.type, node);
+ return identical(parent.type, typeName);
} else if (parent is FieldFormalParameter) {
- return identical(parent.type, node);
+ return identical(parent.type, typeName);
} else if (parent is SimpleFormalParameter) {
- return identical(parent.type, node);
+ return identical(parent.type, typeName);
}
return false;
}
@@ -8800,10 +8779,15 @@
}
}
- void _resolveTypeName(TypeName typeName) {
- typeName.typeArguments?.arguments?.forEach(_resolveTypeName);
- typeNameResolver.resolveTypeName(typeName);
- // TODO(scheglov) report error when don't apply type bounds for type bounds
+ void _resolveTypeName(TypeAnnotation type) {
+ if (type is TypeName) {
+ type.typeArguments?.arguments?.forEach(_resolveTypeName);
+ typeNameResolver.resolveTypeName(type);
+ // TODO(scheglov) report error when don't apply type bounds for type bounds
+ } else {
+ // TODO(brianwilkerson) Add resolution of GenericFunctionType
+ throw new ArgumentError('Cannot resolve a ${type.runtimeType}');
+ }
}
void _resolveTypeParameters(
@@ -8811,13 +8795,19 @@
if (typeParameters != null) {
Scope typeParametersScope = null;
for (TypeParameter typeParameter in typeParameters.typeParameters) {
- TypeName bound = typeParameter.bound;
+ TypeAnnotation bound = typeParameter.bound;
if (bound != null) {
Element typeParameterElement = typeParameter.name.staticElement;
if (typeParameterElement is TypeParameterElementImpl) {
if (LibraryElementImpl.hasResolutionCapability(
library, LibraryResolutionCapability.resolvedTypeNames)) {
- bound.type = typeParameterElement.bound;
+ if (bound is TypeName) {
+ bound.type = typeParameterElement.bound;
+ } else {
+ // TODO(brianwilkerson) Add resolution of GenericFunctionType
+ throw new ArgumentError(
+ 'Cannot resolve a ${bound.runtimeType}');
+ }
} else {
libraryScope ??= new LibraryScope(library);
typeParametersScope ??= createTypeParametersScope();
@@ -9495,7 +9485,7 @@
TypeSystem _typeSystem;
/**
- * The helper to resolve [TypeName]s.
+ * The helper to resolve types.
*/
TypeNameResolver _typeNameResolver;
@@ -9577,7 +9567,7 @@
// If an 'on' clause is provided the type of the exception parameter is
// the type in the 'on' clause. Otherwise, the type of the exception
// parameter is 'Object'.
- TypeName exceptionTypeName = node.exceptionType;
+ TypeAnnotation exceptionTypeName = node.exceptionType;
DartType exceptionType;
if (exceptionTypeName == null) {
exceptionType = typeProvider.dynamicType;
@@ -9716,7 +9706,7 @@
Object visitDeclaredIdentifier(DeclaredIdentifier node) {
super.visitDeclaredIdentifier(node);
DartType declaredType;
- TypeName typeName = node.type;
+ TypeAnnotation typeName = node.type;
if (typeName == null) {
declaredType = _dynamicType;
} else {
@@ -9735,7 +9725,7 @@
FormalParameterList parameterList = node.parameters;
if (parameterList == null) {
DartType type;
- TypeName typeName = node.type;
+ TypeAnnotation typeName = node.type;
if (typeName == null) {
element.hasImplicitType = true;
if (element is FieldFormalParameterElement) {
@@ -9958,7 +9948,7 @@
Object visitSimpleFormalParameter(SimpleFormalParameter node) {
super.visitSimpleFormalParameter(node);
DartType declaredType;
- TypeName typeName = node.type;
+ TypeAnnotation typeName = node.type;
if (typeName == null) {
declaredType = _dynamicType;
} else {
@@ -9997,7 +9987,7 @@
// Bounds of parameters of classes and function type aliases are
// already resolved.
} else {
- TypeName bound = node.bound;
+ TypeAnnotation bound = node.bound;
if (bound != null) {
TypeParameterElementImpl typeParameter =
node.name.staticElement as TypeParameterElementImpl;
@@ -10022,7 +10012,7 @@
}
// Resolve the type.
DartType declaredType;
- TypeName typeName = variableList.type;
+ TypeAnnotation typeName = variableList.type;
if (typeName == null) {
declaredType = _dynamicType;
} else {
@@ -10036,13 +10026,10 @@
}
/**
- * Given a type name representing the return type of a function, compute the return type of the
+ * Given the [returnType] of a function, compute the return type of the
* function.
- *
- * @param returnType the type name representing the return type of the function
- * @return the return type that was computed
*/
- DartType _computeReturnType(TypeName returnType) {
+ DartType _computeReturnType(TypeAnnotation returnType) {
if (returnType == null) {
return _dynamicType;
} else {
@@ -10124,13 +10111,8 @@
}
/**
- * Resolve the types in the given with and implements clauses and associate those types with the
- * given class element.
- *
- * @param classElement the class element with which the mixin and interface types are to be
- * associated
- * @param withClause the with clause to be resolved
- * @param implementsClause the implements clause to be resolved
+ * Resolve the types in the given [withClause] and [implementsClause] and
+ * associate those types with the given [classElement].
*/
void _resolve(ClassElementImpl classElement, WithClause withClause,
ImplementsClause implementsClause) {
@@ -10239,15 +10221,12 @@
}
/**
- * Given a parameter element, create a function type based on the given return type and parameter
- * list and associate the created type with the element.
- *
- * @param element the parameter element whose type is to be set
- * @param returnType the (possibly `null`) return type of the function
- * @param parameterList the list of parameters to the function
+ * Given a parameter [element], create a function type based on the given
+ * [returnType] and [parameterList] and associate the created type with the
+ * element.
*/
void _setFunctionTypedParameterType(ParameterElementImpl element,
- TypeName returnType, FormalParameterList parameterList) {
+ TypeAnnotation returnType, FormalParameterList parameterList) {
List<ParameterElement> parameters = _getElements(parameterList);
FunctionElementImpl functionElement = new FunctionElementImpl.forNode(null);
functionElement.isSynthetic = true;
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index 63b7b54..b3ec3eb 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -607,10 +607,9 @@
// If we have explicit arguments, use them
if (typeArguments != null) {
DartType staticType = _dynamicType;
- NodeList<TypeName> arguments = typeArguments.arguments;
+ NodeList<TypeAnnotation> arguments = typeArguments.arguments;
if (arguments != null && arguments.length == 1) {
- TypeName argumentTypeName = arguments[0];
- DartType argumentType = _getType(argumentTypeName);
+ DartType argumentType = _getType(arguments[0]);
if (argumentType != null) {
staticType = argumentType;
}
@@ -684,15 +683,13 @@
if (typeArguments != null) {
DartType staticKeyType = _dynamicType;
DartType staticValueType = _dynamicType;
- NodeList<TypeName> arguments = typeArguments.arguments;
+ NodeList<TypeAnnotation> arguments = typeArguments.arguments;
if (arguments != null && arguments.length == 2) {
- TypeName entryKeyTypeName = arguments[0];
- DartType entryKeyType = _getType(entryKeyTypeName);
+ DartType entryKeyType = _getType(arguments[0]);
if (entryKeyType != null) {
staticKeyType = entryKeyType;
}
- TypeName entryValueTypeName = arguments[1];
- DartType entryValueType = _getType(entryValueTypeName);
+ DartType entryValueType = _getType(arguments[1]);
if (entryValueType != null) {
staticValueType = entryValueType;
}
@@ -1073,10 +1070,8 @@
} else if (staticElement is VariableElement) {
staticType = staticElement.type;
}
- if (_strongMode) {
- staticType = _inferGenericInstantiationFromContext(
- InferenceContext.getType(node), staticType);
- }
+ staticType = _inferGenericInstantiationFromContext(node, staticType);
+
if (!(_strongMode &&
_inferObjectAccess(node, staticType, prefixedIdentifier))) {
_recordStaticType(prefixedIdentifier, staticType);
@@ -1206,10 +1201,8 @@
} else {
// TODO(brianwilkerson) Report this internal error.
}
- if (_strongMode) {
- staticType = _inferGenericInstantiationFromContext(
- InferenceContext.getType(node), staticType);
- }
+ staticType = _inferGenericInstantiationFromContext(node, staticType);
+
if (!(_strongMode && _inferObjectAccess(node, staticType, propertyName))) {
_recordStaticType(propertyName, staticType);
_recordStaticType(node, staticType);
@@ -1310,10 +1303,8 @@
} else {
staticType = _dynamicType;
}
- if (_strongMode) {
- staticType = _inferGenericInstantiationFromContext(
- InferenceContext.getType(node), staticType);
- }
+ staticType = _inferGenericInstantiationFromContext(node, staticType);
+
_recordStaticType(node, staticType);
// TODO(brianwilkerson) I think we want to repeat the logic above using the
// propagated element to get another candidate for the propagated type.
@@ -1571,7 +1562,7 @@
*/
DartType _computeStaticReturnTypeOfFunctionDeclaration(
FunctionDeclaration node) {
- TypeName returnType = node.returnType;
+ TypeAnnotation returnType = node.returnType;
if (returnType == null) {
return _dynamicType;
}
@@ -1828,13 +1819,10 @@
}
/**
- * Return the type represented by the given type name.
- *
- * @param typeName the type name representing the type to be returned
- * @return the type represented by the type name
+ * Return the type represented by the given type [annotation].
*/
- DartType _getType(TypeName typeName) {
- DartType type = typeName.type;
+ DartType _getType(TypeAnnotation annotation) {
+ DartType type = annotation.type;
if (type == null) {
//TODO(brianwilkerson) Determine the conditions for which the type is
// null.
@@ -1906,13 +1894,19 @@
* Given an uninstantiated generic function type, try to infer the
* instantiated generic function type from the surrounding context.
*/
- DartType _inferGenericInstantiationFromContext(
- DartType context, DartType type) {
- TypeSystem ts = _typeSystem;
- if (context is FunctionType &&
- type is FunctionType &&
- ts is StrongTypeSystemImpl) {
- return ts.inferFunctionTypeInstantiation(context, type);
+ DartType _inferGenericInstantiationFromContext(AstNode node, DartType type) {
+ if (_strongMode) {
+ TypeSystem ts = _typeSystem;
+ DartType context = InferenceContext.getType(node);
+ if (context is FunctionType &&
+ type is FunctionType &&
+ ts is StrongTypeSystemImpl) {
+ return ts.inferFunctionTypeInstantiation(context, type);
+ }
+ } else if (type is FunctionType) {
+ // In Dart 1 mode we want to implicitly instantiate generic functions to
+ // their bounds always, so we don't get a universal function type.
+ return _typeSystem.instantiateToBounds(type);
}
return type;
}
@@ -2253,10 +2247,7 @@
library != null && "dart.dom.html" == library.name;
/**
- * Return `true` if the given node is not a type literal.
- *
- * @param node the node being tested
- * @return `true` if the given node is not a type literal
+ * Return `true` if the given [node] is not a type literal.
*/
bool _isNotTypeLiteral(Identifier node) {
AstNode parent = node.parent;
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 724a24b..826ee7d 100644
--- a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
@@ -45,7 +45,8 @@
astFactory.argumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN));
- static AsExpression asExpression(Expression expression, TypeName type) =>
+ static AsExpression asExpression(
+ Expression expression, TypeAnnotation type) =>
astFactory.asExpression(
expression, TokenFactory.tokenFromKeyword(Keyword.AS), type);
@@ -158,16 +159,16 @@
[List<Statement> statements]) =>
catchClause5(null, exceptionParameter, stackTraceParameter, statements);
- static CatchClause catchClause3(TypeName exceptionType,
+ static CatchClause catchClause3(TypeAnnotation exceptionType,
[List<Statement> statements]) =>
catchClause5(exceptionType, null, null, statements);
static CatchClause catchClause4(
- TypeName exceptionType, String exceptionParameter,
+ TypeAnnotation exceptionType, String exceptionParameter,
[List<Statement> statements]) =>
catchClause5(exceptionType, exceptionParameter, null, statements);
- static CatchClause catchClause5(TypeName exceptionType,
+ static CatchClause catchClause5(TypeAnnotation exceptionType,
String exceptionParameter, String stackTraceParameter,
[List<Statement> statements]) =>
astFactory.catchClause(
@@ -367,7 +368,7 @@
declaredIdentifier2(keyword, null, identifier);
static DeclaredIdentifier declaredIdentifier2(
- Keyword keyword, TypeName type, String identifier) =>
+ Keyword keyword, TypeAnnotation type, String identifier) =>
astFactory.declaredIdentifier(
null,
null,
@@ -379,7 +380,7 @@
declaredIdentifier2(Keyword.VAR, null, identifier);
static DeclaredIdentifier declaredIdentifier4(
- TypeName type, String identifier) =>
+ TypeAnnotation type, String identifier) =>
declaredIdentifier2(null, type, identifier);
static Comment documentationComment(
@@ -459,7 +460,7 @@
TokenFactory.tokenFromKeyword(Keyword.EXTENDS), type);
static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword,
- TypeName type, List<VariableDeclaration> variables) =>
+ TypeAnnotation type, List<VariableDeclaration> variables) =>
astFactory.fieldDeclaration(
null,
null,
@@ -472,7 +473,7 @@
fieldDeclaration(isStatic, keyword, null, variables);
static FieldFormalParameter fieldFormalParameter(
- Keyword keyword, TypeName type, String identifier,
+ Keyword keyword, TypeAnnotation type, String identifier,
[FormalParameterList parameterList]) =>
astFactory.fieldFormalParameter(
null,
@@ -549,8 +550,11 @@
TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
body);
- static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword,
- String name, FunctionExpression functionExpression) =>
+ static FunctionDeclaration functionDeclaration(
+ TypeAnnotation type,
+ Keyword keyword,
+ String name,
+ FunctionExpression functionExpression) =>
astFactory.functionDeclaration(
null,
null,
@@ -561,7 +565,7 @@
functionExpression);
static FunctionDeclarationStatement functionDeclarationStatement(
- TypeName type,
+ TypeAnnotation type,
Keyword keyword,
String name,
FunctionExpression functionExpression) =>
@@ -594,7 +598,7 @@
function, typeArguments, argumentList(arguments));
static FunctionTypedFormalParameter functionTypedFormalParameter(
- TypeName returnType, String identifier,
+ TypeAnnotation returnType, String identifier,
[List<FormalParameter> parameters]) =>
astFactory.functionTypedFormalParameter(null, null, returnType,
identifier3(identifier), null, formalParameterList(parameters));
@@ -737,7 +741,7 @@
TokenFactory.tokenFromString(contents), value);
static IsExpression isExpression(
- Expression expression, bool negated, TypeName type) =>
+ Expression expression, bool negated, TypeAnnotation type) =>
astFactory.isExpression(
expression,
TokenFactory.tokenFromKeyword(Keyword.IS),
@@ -813,7 +817,7 @@
static MethodDeclaration methodDeclaration(
Keyword modifier,
- TypeName returnType,
+ TypeAnnotation returnType,
Keyword property,
Keyword operator,
SimpleIdentifier name,
@@ -833,7 +837,7 @@
static MethodDeclaration methodDeclaration2(
Keyword modifier,
- TypeName returnType,
+ TypeAnnotation returnType,
Keyword property,
Keyword operator,
SimpleIdentifier name,
@@ -854,7 +858,7 @@
static MethodDeclaration methodDeclaration3(
Keyword modifier,
- TypeName returnType,
+ TypeAnnotation returnType,
Keyword property,
Keyword operator,
SimpleIdentifier name,
@@ -877,7 +881,7 @@
static MethodDeclaration methodDeclaration4(
{bool external: false,
Keyword modifier,
- TypeName returnType,
+ TypeAnnotation returnType,
Keyword property,
bool operator: false,
String name,
@@ -1051,7 +1055,7 @@
simpleFormalParameter2(keyword, null, parameterName);
static SimpleFormalParameter simpleFormalParameter2(
- Keyword keyword, TypeName type, String parameterName) =>
+ Keyword keyword, TypeAnnotation type, String parameterName) =>
astFactory.simpleFormalParameter(
null,
null,
@@ -1063,7 +1067,7 @@
simpleFormalParameter2(null, null, parameterName);
static SimpleFormalParameter simpleFormalParameter4(
- TypeName type, String parameterName) =>
+ TypeAnnotation type, String parameterName) =>
simpleFormalParameter2(null, type, parameterName);
static StringInterpolation string([List<InterpolationElement> elements]) =>
@@ -1153,7 +1157,7 @@
static TopLevelVariableDeclaration topLevelVariableDeclaration(
Keyword keyword,
- TypeName type,
+ TypeAnnotation type,
List<VariableDeclaration> variables) =>
astFactory.topLevelVariableDeclaration(
null,
@@ -1187,7 +1191,7 @@
: TokenFactory.tokenFromKeyword(Keyword.FINALLY),
finallyClause);
- static FunctionTypeAlias typeAlias(TypeName returnType, String name,
+ static FunctionTypeAlias typeAlias(TypeAnnotation returnType, String name,
TypeParameterList typeParameters, FormalParameterList parameters) =>
astFactory.functionTypeAlias(
null,
@@ -1199,12 +1203,12 @@
parameters,
TokenFactory.tokenFromType(TokenType.SEMICOLON));
- static TypeArgumentList typeArgumentList(List<TypeName> typeNames) {
- if (typeNames == null || typeNames.length == 0) {
+ static TypeArgumentList typeArgumentList(List<TypeAnnotation> types) {
+ if (types == null || types.length == 0) {
return null;
}
return astFactory.typeArgumentList(TokenFactory.tokenFromType(TokenType.LT),
- typeNames, TokenFactory.tokenFromType(TokenType.GT));
+ types, TokenFactory.tokenFromType(TokenType.GT));
}
/**
@@ -1214,7 +1218,8 @@
* <b>Note:</b> This method does not correctly handle class elements that have
* type parameters.
*/
- static TypeName typeName(ClassElement element, [List<TypeName> arguments]) {
+ static TypeName typeName(ClassElement element,
+ [List<TypeAnnotation> arguments]) {
SimpleIdentifier name = identifier3(element.name);
name.staticElement = element;
TypeName typeName = typeName3(name, arguments);
@@ -1222,16 +1227,17 @@
return typeName;
}
- static TypeName typeName3(Identifier name, [List<TypeName> arguments]) =>
+ static TypeName typeName3(Identifier name,
+ [List<TypeAnnotation> arguments]) =>
astFactory.typeName(name, typeArgumentList(arguments));
- static TypeName typeName4(String name, [List<TypeName> arguments]) =>
+ static TypeName typeName4(String name, [List<TypeAnnotation> arguments]) =>
astFactory.typeName(identifier3(name), typeArgumentList(arguments));
static TypeParameter typeParameter(String name) =>
astFactory.typeParameter(null, null, identifier3(name), null, null);
- static TypeParameter typeParameter2(String name, TypeName bound) =>
+ static TypeParameter typeParameter2(String name, TypeAnnotation bound) =>
astFactory.typeParameter(null, null, identifier3(name),
TokenFactory.tokenFromKeyword(Keyword.EXTENDS), bound);
@@ -1258,7 +1264,7 @@
TokenFactory.tokenFromType(TokenType.EQ), initializer);
static VariableDeclarationList variableDeclarationList(Keyword keyword,
- TypeName type, List<VariableDeclaration> variables) =>
+ TypeAnnotation type, List<VariableDeclaration> variables) =>
astFactory.variableDeclarationList(
null,
null,
@@ -1272,7 +1278,7 @@
static VariableDeclarationStatement variableDeclarationStatement(
Keyword keyword,
- TypeName type,
+ TypeAnnotation type,
List<VariableDeclaration> variables) =>
astFactory.variableDeclarationStatement(
variableDeclarationList(keyword, type, variables),
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index 69298a5..73f6b8a 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -477,17 +477,18 @@
_pushList(null);
break;
case UnlinkedExprOperation.makeTypedList:
- TypeName itemType = _newTypeName();
- _pushList(AstTestFactory.typeArgumentList(<TypeName>[itemType]));
+ TypeAnnotation itemType = _newTypeName();
+ _pushList(
+ AstTestFactory.typeArgumentList(<TypeAnnotation>[itemType]));
break;
case UnlinkedExprOperation.makeUntypedMap:
_pushMap(null);
break;
case UnlinkedExprOperation.makeTypedMap:
- TypeName keyType = _newTypeName();
- TypeName valueType = _newTypeName();
- _pushMap(
- AstTestFactory.typeArgumentList(<TypeName>[keyType, valueType]));
+ TypeAnnotation keyType = _newTypeName();
+ TypeAnnotation valueType = _newTypeName();
+ _pushMap(AstTestFactory
+ .typeArgumentList(<TypeAnnotation>[keyType, valueType]));
break;
case UnlinkedExprOperation.pushReference:
_pushReference();
@@ -579,8 +580,8 @@
return AstTestFactory.propertyAccess(enclosing, property);
}
- TypeName _buildTypeAst(DartType type) {
- List<TypeName> argumentNodes;
+ TypeAnnotation _buildTypeAst(DartType type) {
+ List<TypeAnnotation> argumentNodes;
if (type is ParameterizedType) {
if (!resynthesizer.libraryResynthesizer.typesWithImplicitTypeArguments
.contains(type)) {
@@ -614,7 +615,7 @@
* Convert the next reference to the [DartType] and return the AST
* corresponding to this type.
*/
- TypeName _newTypeName() {
+ TypeAnnotation _newTypeName() {
EntityRef typeRef = uc.references[refPtr++];
DartType type =
resynthesizer.buildType(typeRef, context?.typeParameterContext);
@@ -724,7 +725,8 @@
TypeArgumentList typeArguments;
int numTypeArguments = uc.ints[intPtr++];
if (numTypeArguments > 0) {
- List<TypeName> typeNames = new List<TypeName>(numTypeArguments);
+ List<TypeAnnotation> typeNames =
+ new List<TypeAnnotation>(numTypeArguments);
for (int i = 0; i < numTypeArguments; i++) {
typeNames[i] = _newTypeName();
}
@@ -1309,7 +1311,7 @@
// If type arguments are specified, use them.
// Otherwise, delay until they are requested.
if (numTypeParameters == 0) {
- typeArguments = const <DartType>[];
+ return element.type;
} else if (numTypeArguments == numTypeParameters) {
typeArguments = new List<DartType>(numTypeParameters);
for (int i = 0; i < numTypeParameters; i++) {
diff --git a/pkg/analyzer/lib/src/summary/summarize_ast.dart b/pkg/analyzer/lib/src/summary/summarize_ast.dart
index 46b7b2d..7eb3ad5 100644
--- a/pkg/analyzer/lib/src/summary/summarize_ast.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_ast.dart
@@ -567,7 +567,7 @@
NodeList<Annotation> annotations,
bool isFinal,
bool isConst,
- TypeName type,
+ TypeAnnotation type,
bool assignPropagatedTypeSlot,
SimpleIdentifier declaredIdentifier) {
UnlinkedVariableBuilder b = new UnlinkedVariableBuilder();
@@ -615,7 +615,7 @@
int nameOffset,
bool isGetter,
bool isSetter,
- TypeName returnType,
+ TypeAnnotation returnType,
FormalParameterList formalParameters,
FunctionBody body,
bool isTopLevel,
@@ -764,7 +764,7 @@
* parameter and store them in [b].
*/
void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b,
- TypeName returnType, FormalParameterList parameters) {
+ TypeAnnotation returnType, FormalParameterList parameters) {
EntityRefBuilder serializedReturnType = serializeTypeName(returnType);
if (serializedReturnType != null) {
b.type = serializedReturnType;
@@ -933,8 +933,13 @@
* a [EntityRef]. Note that this method does the right thing if the
* name doesn't refer to an entity other than a type (e.g. a class member).
*/
- EntityRefBuilder serializeTypeName(TypeName node) {
- return serializeType(node?.name, node?.typeArguments);
+ EntityRefBuilder serializeTypeName(TypeAnnotation node) {
+ if (node is TypeName) {
+ return serializeType(node?.name, node?.typeArguments);
+ } else if (node != null) {
+ throw new ArgumentError('Cannot serialize a ${node.runtimeType}');
+ }
+ return null;
}
/**
@@ -1397,14 +1402,6 @@
}
/**
- * Helper method to determine if a given [typeName] refers to `dynamic`.
- */
- static bool isDynamic(TypeName typeName) {
- Identifier name = typeName.name;
- return name is SimpleIdentifier && name.name == 'dynamic';
- }
-
- /**
* Compute the API signature of the unit and record it.
*/
static void _computeApiSignature(UnlinkedUnitBuilder b) {
diff --git a/pkg/analyzer/lib/src/summary/summarize_const_expr.dart b/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
index 5a8702a..e3a9017 100644
--- a/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
@@ -178,8 +178,12 @@
/**
* Return [EntityRefBuilder] that corresponds to the given [type].
*/
- EntityRefBuilder serializeTypeName(TypeName type) {
- return serializeType(type?.type, type?.name, type?.typeArguments);
+ EntityRefBuilder serializeTypeName(TypeAnnotation type) {
+ if (type is TypeName) {
+ return serializeType(type?.type, type?.name, type?.typeArguments);
+ }
+ throw new ArgumentError(
+ 'Cannot serialize an instance of ${type.runtimeType}');
}
/**
@@ -649,8 +653,8 @@
ints.add(0);
} else {
ints.add(typeArguments.arguments.length);
- for (TypeName typeName in typeArguments.arguments) {
- references.add(serializeTypeName(typeName));
+ for (TypeAnnotation type in typeArguments.arguments) {
+ references.add(serializeTypeName(type));
}
}
}
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart
index c528c65c..7ccdcc9 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -217,8 +217,8 @@
}
}
- DartType getType(TypeName name) {
- return (name == null) ? DynamicTypeImpl.instance : name.type;
+ DartType getType(TypeAnnotation type) {
+ return type?.type ?? DynamicTypeImpl.instance;
}
void reset() {
@@ -492,7 +492,7 @@
void visitListLiteral(ListLiteral node) {
DartType type = DynamicTypeImpl.instance;
if (node.typeArguments != null) {
- NodeList<TypeName> targs = node.typeArguments.arguments;
+ NodeList<TypeAnnotation> targs = node.typeArguments.arguments;
if (targs.length > 0) {
type = targs[0].type;
}
@@ -517,7 +517,7 @@
DartType ktype = DynamicTypeImpl.instance;
DartType vtype = DynamicTypeImpl.instance;
if (node.typeArguments != null) {
- NodeList<TypeName> targs = node.typeArguments.arguments;
+ NodeList<TypeAnnotation> targs = node.typeArguments.arguments;
if (targs.length > 0) {
ktype = targs[0].type;
}
@@ -657,7 +657,7 @@
@override
void visitVariableDeclarationList(VariableDeclarationList node) {
- TypeName type = node.type;
+ TypeAnnotation type = node.type;
if (type == null) {
// No checks are needed when the type is var. Although internally the
// typing rules may have inferred a more precise type for the variable
@@ -876,8 +876,8 @@
if (expression != null) checkAssignment(expression, type);
}
- void _checkRuntimeTypeCheck(AstNode node, TypeName typeName) {
- var type = getType(typeName);
+ void _checkRuntimeTypeCheck(AstNode node, TypeAnnotation annotation) {
+ var type = getType(annotation);
if (!rules.isGroundType(type)) {
_recordMessage(node, StrongModeCode.NON_GROUND_TYPE_CHECK_INFO, [type]);
}
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index 6229305..5a0a1ba 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -4,6 +4,8 @@
library analyzer.test.generated.all_the_rest_test;
+import 'dart:async';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -93,7 +95,7 @@
@reflectiveTest
class ContentCacheTest {
- void test_setContents() {
+ test_setContents() async {
Source source = new TestSource();
ContentCache cache = new ContentCache();
expect(cache.getContents(source), isNull);
@@ -363,11 +365,11 @@
void reset() {
AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl();
analysisOptions.hint = false;
- resetWithOptions(analysisOptions);
+ resetWith(options: analysisOptions);
}
- void test_locate_AssignmentExpression() {
- AstNode id = _findNodeIn(
+ test_locate_AssignmentExpression() async {
+ AstNode id = await _findNodeIn(
"+=",
r'''
int x = 0;
@@ -379,29 +381,29 @@
(obj) => obj is MethodElement, MethodElement, element);
}
- void test_locate_BinaryExpression() {
- AstNode id = _findNodeIn("+", "var x = 3 + 4;");
+ test_locate_BinaryExpression() async {
+ AstNode id = await _findNodeIn("+", "var x = 3 + 4;");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is MethodElement, MethodElement, element);
}
- void test_locate_ClassDeclaration() {
- AstNode id = _findNodeIn("class", "class A { }");
+ test_locate_ClassDeclaration() async {
+ AstNode id = await _findNodeIn("class", "class A { }");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is ClassElement, ClassElement, element);
}
- void test_locate_CompilationUnit() {
- CompilationUnit cu = _resolveContents("// only comment");
+ test_locate_CompilationUnit() async {
+ CompilationUnit cu = await _resolveContents("// only comment");
expect(cu.element, isNotNull);
Element element = ElementLocator.locate(cu);
expect(element, same(cu.element));
}
- void test_locate_ConstructorDeclaration() {
- AstNode id = _findNodeIndexedIn(
+ test_locate_ConstructorDeclaration() async {
+ AstNode id = await _findNodeIndexedIn(
"bar",
0,
r'''
@@ -415,15 +417,15 @@
(obj) => obj is ConstructorElement, ConstructorElement, element);
}
- void test_locate_ExportDirective() {
- AstNode id = _findNodeIn("export", "export 'dart:core';");
+ test_locate_ExportDirective() async {
+ AstNode id = await _findNodeIn("export", "export 'dart:core';");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is ExportElement, ExportElement, element);
}
- void test_locate_FunctionDeclaration() {
- AstNode id = _findNodeIn("f", "int f() => 3;");
+ test_locate_FunctionDeclaration() async {
+ AstNode id = await _findNodeIn("f", "int f() => 3;");
FunctionDeclaration declaration =
id.getAncestor((node) => node is FunctionDeclaration);
Element element = ElementLocator.locate(declaration);
@@ -431,9 +433,8 @@
(obj) => obj is FunctionElement, FunctionElement, element);
}
- void
- test_locate_Identifier_annotationClass_namedConstructor_forSimpleFormalParameter() {
- AstNode id = _findNodeIndexedIn(
+ test_locate_Identifier_annotationClass_namedConstructor_forSimpleFormalParameter() async {
+ AstNode id = await _findNodeIndexedIn(
"Class",
2,
r'''
@@ -447,9 +448,8 @@
(obj) => obj is ClassElement, ClassElement, element);
}
- void
- test_locate_Identifier_annotationClass_unnamedConstructor_forSimpleFormalParameter() {
- AstNode id = _findNodeIndexedIn(
+ test_locate_Identifier_annotationClass_unnamedConstructor_forSimpleFormalParameter() async {
+ AstNode id = await _findNodeIndexedIn(
"Class",
2,
r'''
@@ -463,15 +463,15 @@
(obj) => obj is ConstructorElement, ConstructorElement, element);
}
- void test_locate_Identifier_className() {
- AstNode id = _findNodeIn("A", "class A { }");
+ test_locate_Identifier_className() async {
+ AstNode id = await _findNodeIn("A", "class A { }");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is ClassElement, ClassElement, element);
}
- void test_locate_Identifier_constructor_named() {
- AstNode id = _findNodeIndexedIn(
+ test_locate_Identifier_constructor_named() async {
+ AstNode id = await _findNodeIndexedIn(
"bar",
0,
r'''
@@ -483,8 +483,8 @@
(obj) => obj is ConstructorElement, ConstructorElement, element);
}
- void test_locate_Identifier_constructor_unnamed() {
- AstNode id = _findNodeIndexedIn(
+ test_locate_Identifier_constructor_unnamed() async {
+ AstNode id = await _findNodeIndexedIn(
"A",
1,
r'''
@@ -496,22 +496,22 @@
(obj) => obj is ConstructorElement, ConstructorElement, element);
}
- void test_locate_Identifier_fieldName() {
- AstNode id = _findNodeIn("x", "class A { var x; }");
+ test_locate_Identifier_fieldName() async {
+ AstNode id = await _findNodeIn("x", "class A { var x; }");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is FieldElement, FieldElement, element);
}
- void test_locate_Identifier_libraryDirective() {
- AstNode id = _findNodeIn("foo", "library foo.bar;");
+ test_locate_Identifier_libraryDirective() async {
+ AstNode id = await _findNodeIn("foo", "library foo.bar;");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is LibraryElement, LibraryElement, element);
}
- void test_locate_Identifier_propertyAccess() {
- AstNode id = _findNodeIn(
+ test_locate_Identifier_propertyAccess() async {
+ AstNode id = await _findNodeIn(
"length",
r'''
void main() {
@@ -522,15 +522,15 @@
PropertyAccessorElement, element);
}
- void test_locate_ImportDirective() {
- AstNode id = _findNodeIn("import", "import 'dart:core';");
+ test_locate_ImportDirective() async {
+ AstNode id = await _findNodeIn("import", "import 'dart:core';");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is ImportElement, ImportElement, element);
}
- void test_locate_IndexExpression() {
- AstNode id = _findNodeIndexedIn(
+ test_locate_IndexExpression() async {
+ AstNode id = await _findNodeIndexedIn(
"\\[",
1,
r'''
@@ -543,8 +543,8 @@
(obj) => obj is MethodElement, MethodElement, element);
}
- void test_locate_InstanceCreationExpression() {
- AstNode node = _findNodeIndexedIn(
+ test_locate_InstanceCreationExpression() async {
+ AstNode node = await _findNodeIndexedIn(
"A(",
0,
r'''
@@ -557,7 +557,7 @@
(obj) => obj is ConstructorElement, ConstructorElement, element);
}
- void test_locate_InstanceCreationExpression_type_prefixedIdentifier() {
+ test_locate_InstanceCreationExpression_type_prefixedIdentifier() async {
// prepare: new pref.A()
SimpleIdentifier identifier = AstTestFactory.identifier3("A");
PrefixedIdentifier prefixedIdentifier =
@@ -577,7 +577,7 @@
expect(element, same(classElement));
}
- void test_locate_InstanceCreationExpression_type_simpleIdentifier() {
+ test_locate_InstanceCreationExpression_type_simpleIdentifier() async {
// prepare: new A()
SimpleIdentifier identifier = AstTestFactory.identifier3("A");
InstanceCreationExpression creation =
@@ -595,15 +595,15 @@
expect(element, same(classElement));
}
- void test_locate_LibraryDirective() {
- AstNode id = _findNodeIn("library", "library foo;");
+ test_locate_LibraryDirective() async {
+ AstNode id = await _findNodeIn("library", "library foo;");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is LibraryElement, LibraryElement, element);
}
- void test_locate_MethodDeclaration() {
- AstNode id = _findNodeIn(
+ test_locate_MethodDeclaration() async {
+ AstNode id = await _findNodeIn(
"m",
r'''
class A {
@@ -616,8 +616,8 @@
(obj) => obj is MethodElement, MethodElement, element);
}
- void test_locate_MethodInvocation_method() {
- AstNode id = _findNodeIndexedIn(
+ test_locate_MethodInvocation_method() async {
+ AstNode id = await _findNodeIndexedIn(
"bar",
1,
r'''
@@ -632,13 +632,13 @@
(obj) => obj is MethodElement, MethodElement, element);
}
- void test_locate_MethodInvocation_topLevel() {
+ test_locate_MethodInvocation_topLevel() async {
String code = r'''
foo(x) {}
void main() {
foo(0);
}''';
- CompilationUnit cu = _resolveContents(code);
+ CompilationUnit cu = await _resolveContents(code);
int offset = code.indexOf('foo(0)');
AstNode node = new NodeLocator(offset).searchWithin(cu);
MethodInvocation invocation =
@@ -648,7 +648,7 @@
(obj) => obj is FunctionElement, FunctionElement, element);
}
- void test_locate_PartOfDirective() {
+ test_locate_PartOfDirective() async {
Source librarySource = addNamedSource(
'/lib.dart',
'''
@@ -668,15 +668,15 @@
(obj) => obj is LibraryElement, LibraryElement, element);
}
- void test_locate_PostfixExpression() {
- AstNode id = _findNodeIn("++", "int addOne(int x) => x++;");
+ test_locate_PostfixExpression() async {
+ AstNode id = await _findNodeIn("++", "int addOne(int x) => x++;");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is MethodElement, MethodElement, element);
}
- void test_locate_PrefixedIdentifier() {
- AstNode id = _findNodeIn(
+ test_locate_PrefixedIdentifier() async {
+ AstNode id = await _findNodeIn(
"int",
r'''
import 'dart:core' as core;
@@ -688,46 +688,47 @@
(obj) => obj is ClassElement, ClassElement, element);
}
- void test_locate_PrefixExpression() {
- AstNode id = _findNodeIn("++", "int addOne(int x) => ++x;");
+ test_locate_PrefixExpression() async {
+ AstNode id = await _findNodeIn("++", "int addOne(int x) => ++x;");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is MethodElement, MethodElement, element);
}
- void test_locate_StringLiteral_exportUri() {
+ test_locate_StringLiteral_exportUri() async {
addNamedSource("/foo.dart", "library foo;");
- AstNode id = _findNodeIn("'foo.dart'", "export 'foo.dart';");
+ AstNode id = await _findNodeIn("'foo.dart'", "export 'foo.dart';");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is LibraryElement, LibraryElement, element);
}
- void test_locate_StringLiteral_expression() {
- AstNode id = _findNodeIn("abc", "var x = 'abc';");
+ test_locate_StringLiteral_expression() async {
+ AstNode id = await _findNodeIn("abc", "var x = 'abc';");
Element element = ElementLocator.locate(id);
expect(element, isNull);
}
- void test_locate_StringLiteral_importUri() {
+ test_locate_StringLiteral_importUri() async {
addNamedSource("/foo.dart", "library foo; class A {}");
- AstNode id =
- _findNodeIn("'foo.dart'", "import 'foo.dart'; class B extends A {}");
+ AstNode id = await _findNodeIn(
+ "'foo.dart'", "import 'foo.dart'; class B extends A {}");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf(
(obj) => obj is LibraryElement, LibraryElement, element);
}
- void test_locate_StringLiteral_partUri() {
+ test_locate_StringLiteral_partUri() async {
addNamedSource("/foo.dart", "part of app;");
- AstNode id = _findNodeIn("'foo.dart'", "library app; part 'foo.dart';");
+ AstNode id =
+ await _findNodeIn("'foo.dart'", "library app; part 'foo.dart';");
Element element = ElementLocator.locate(id);
EngineTestCase.assertInstanceOf((obj) => obj is CompilationUnitElement,
CompilationUnitElement, element);
}
- void test_locate_VariableDeclaration() {
- AstNode id = _findNodeIn("x", "var x = 'abc';");
+ test_locate_VariableDeclaration() async {
+ AstNode id = await _findNodeIn("x", "var x = 'abc';");
VariableDeclaration declaration =
id.getAncestor((node) => node is VariableDeclaration);
Element element = ElementLocator.locate(declaration);
@@ -742,8 +743,8 @@
* [code] the code to resolve.
* Returns the matched node in the resolved AST for the given source lines.
*/
- AstNode _findNodeIn(String nodePattern, String code) {
- return _findNodeIndexedIn(nodePattern, 0, code);
+ Future<AstNode> _findNodeIn(String nodePattern, String code) async {
+ return await _findNodeIndexedIn(nodePattern, 0, code);
}
/**
@@ -755,8 +756,9 @@
* [code] the code to resolve.
* Returns the matched node in the resolved AST for the given source lines
*/
- AstNode _findNodeIndexedIn(String nodePattern, int index, String code) {
- CompilationUnit cu = _resolveContents(code);
+ Future<AstNode> _findNodeIndexedIn(
+ String nodePattern, int index, String code) async {
+ CompilationUnit cu = await _resolveContents(code);
int start = _getOffsetOfMatch(code, nodePattern, index);
int end = start + nodePattern.length;
return new NodeLocator(start, end).searchWithin(cu);
@@ -782,9 +784,10 @@
*
* Throws if source cannot be verified.
*/
- CompilationUnit _resolveContents(String code) {
+ Future<CompilationUnit> _resolveContents(String code) async {
Source source = addSource(code);
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
return analysisContext.resolveCompilationUnit(source, library);
@@ -793,7 +796,7 @@
@reflectiveTest
class EnumMemberBuilderTest extends EngineTestCase {
- void test_visitEnumDeclaration_multiple() {
+ test_visitEnumDeclaration_multiple() async {
String firstName = "ONE";
String secondName = "TWO";
String thirdName = "THREE";
@@ -826,7 +829,7 @@
_assertGetter(constant);
}
- void test_visitEnumDeclaration_single() {
+ test_visitEnumDeclaration_single() async {
String firstName = "ONE";
EnumDeclaration enumDeclaration =
AstTestFactory.enumDeclaration2("E", [firstName]);
@@ -901,13 +904,13 @@
return element.type;
}
- void test_creation() {
+ test_creation() async {
GatheringErrorListener listener = new GatheringErrorListener();
TestSource source = new TestSource();
expect(new ErrorReporter(listener, source), isNotNull);
}
- void test_reportErrorForElement_named() {
+ test_reportErrorForElement_named() async {
DartType type = createType("/test1.dart", "A");
ClassElement element = type.element;
GatheringErrorListener listener = new GatheringErrorListener();
@@ -920,7 +923,7 @@
expect(error.offset, element.nameOffset);
}
- void test_reportErrorForElement_unnamed() {
+ test_reportErrorForElement_unnamed() async {
ImportElementImpl element =
ElementFactory.importFor(ElementFactory.library(null, ''), null);
GatheringErrorListener listener = new GatheringErrorListener();
@@ -936,7 +939,7 @@
expect(error.offset, element.nameOffset);
}
- void test_reportErrorForSpan() {
+ test_reportErrorForSpan() async {
GatheringErrorListener listener = new GatheringErrorListener();
ErrorReporter reporter = new ErrorReporter(listener, new TestSource());
@@ -959,7 +962,7 @@
expect(listener.errors.first.length, length);
}
- void test_reportTypeErrorForNode_differentNames() {
+ test_reportTypeErrorForNode_differentNames() async {
DartType firstType = createType("/test1.dart", "A");
DartType secondType = createType("/test2.dart", "B");
GatheringErrorListener listener = new GatheringErrorListener();
@@ -973,7 +976,7 @@
expect(error.message.indexOf("(") < 0, isTrue);
}
- void test_reportTypeErrorForNode_sameName() {
+ test_reportTypeErrorForNode_sameName() async {
String typeName = "A";
DartType firstType = createType("/test1.dart", typeName);
DartType secondType = createType("/test2.dart", typeName);
@@ -991,47 +994,47 @@
@reflectiveTest
class ErrorSeverityTest extends EngineTestCase {
- void test_max_error_error() {
+ test_max_error_error() async {
expect(ErrorSeverity.ERROR.max(ErrorSeverity.ERROR),
same(ErrorSeverity.ERROR));
}
- void test_max_error_none() {
+ test_max_error_none() async {
expect(
ErrorSeverity.ERROR.max(ErrorSeverity.NONE), same(ErrorSeverity.ERROR));
}
- void test_max_error_warning() {
+ test_max_error_warning() async {
expect(ErrorSeverity.ERROR.max(ErrorSeverity.WARNING),
same(ErrorSeverity.ERROR));
}
- void test_max_none_error() {
+ test_max_none_error() async {
expect(
ErrorSeverity.NONE.max(ErrorSeverity.ERROR), same(ErrorSeverity.ERROR));
}
- void test_max_none_none() {
+ test_max_none_none() async {
expect(
ErrorSeverity.NONE.max(ErrorSeverity.NONE), same(ErrorSeverity.NONE));
}
- void test_max_none_warning() {
+ test_max_none_warning() async {
expect(ErrorSeverity.NONE.max(ErrorSeverity.WARNING),
same(ErrorSeverity.WARNING));
}
- void test_max_warning_error() {
+ test_max_warning_error() async {
expect(ErrorSeverity.WARNING.max(ErrorSeverity.ERROR),
same(ErrorSeverity.ERROR));
}
- void test_max_warning_none() {
+ test_max_warning_none() async {
expect(ErrorSeverity.WARNING.max(ErrorSeverity.NONE),
same(ErrorSeverity.WARNING));
}
- void test_max_warning_warning() {
+ test_max_warning_warning() async {
expect(ErrorSeverity.WARNING.max(ErrorSeverity.WARNING),
same(ErrorSeverity.WARNING));
}
@@ -1044,220 +1047,220 @@
*/
@reflectiveTest
class ExitDetectorTest extends ParserTestCase {
- void test_asExpression() {
+ test_asExpression() async {
_assertFalse("a as Object;");
}
- void test_asExpression_throw() {
+ test_asExpression_throw() async {
_assertTrue("throw '' as Object;");
}
- void test_assertStatement() {
+ test_assertStatement() async {
_assertFalse("assert(a);");
}
- void test_assertStatement_throw() {
+ test_assertStatement_throw() async {
_assertFalse("assert((throw 0));");
}
- void test_assignmentExpression() {
+ test_assignmentExpression() async {
_assertFalse("v = 1;");
}
- void test_assignmentExpression_compound_lazy() {
+ test_assignmentExpression_compound_lazy() async {
enableLazyAssignmentOperators = true;
_assertFalse("v ||= false;");
}
- void test_assignmentExpression_lhs_throw() {
+ test_assignmentExpression_lhs_throw() async {
_assertTrue("a[throw ''] = 0;");
}
- void test_assignmentExpression_rhs_throw() {
+ test_assignmentExpression_rhs_throw() async {
_assertTrue("v = throw '';");
}
- void test_await_false() {
+ test_await_false() async {
_assertFalse("await x;");
}
- void test_await_throw_true() {
+ test_await_throw_true() async {
_assertTrue("bool b = await (throw '' || true);");
}
- void test_binaryExpression_and() {
+ test_binaryExpression_and() async {
_assertFalse("a && b;");
}
- void test_binaryExpression_and_lhs() {
+ test_binaryExpression_and_lhs() async {
_assertTrue("throw '' && b;");
}
- void test_binaryExpression_and_rhs() {
+ test_binaryExpression_and_rhs() async {
_assertFalse("a && (throw '');");
}
- void test_binaryExpression_and_rhs2() {
+ test_binaryExpression_and_rhs2() async {
_assertFalse("false && (throw '');");
}
- void test_binaryExpression_and_rhs3() {
+ test_binaryExpression_and_rhs3() async {
_assertTrue("true && (throw '');");
}
- void test_binaryExpression_ifNull() {
+ test_binaryExpression_ifNull() async {
_assertFalse("a ?? b;");
}
- void test_binaryExpression_ifNull_lhs() {
+ test_binaryExpression_ifNull_lhs() async {
_assertTrue("throw '' ?? b;");
}
- void test_binaryExpression_ifNull_rhs() {
+ test_binaryExpression_ifNull_rhs() async {
_assertFalse("a ?? (throw '');");
}
- void test_binaryExpression_ifNull_rhs2() {
+ test_binaryExpression_ifNull_rhs2() async {
_assertFalse("null ?? (throw '');");
}
- void test_binaryExpression_or() {
+ test_binaryExpression_or() async {
_assertFalse("a || b;");
}
- void test_binaryExpression_or_lhs() {
+ test_binaryExpression_or_lhs() async {
_assertTrue("throw '' || b;");
}
- void test_binaryExpression_or_rhs() {
+ test_binaryExpression_or_rhs() async {
_assertFalse("a || (throw '');");
}
- void test_binaryExpression_or_rhs2() {
+ test_binaryExpression_or_rhs2() async {
_assertFalse("true || (throw '');");
}
- void test_binaryExpression_or_rhs3() {
+ test_binaryExpression_or_rhs3() async {
_assertTrue("false || (throw '');");
}
- void test_block_empty() {
+ test_block_empty() async {
_assertFalse("{}");
}
- void test_block_noReturn() {
+ test_block_noReturn() async {
_assertFalse("{ int i = 0; }");
}
- void test_block_return() {
+ test_block_return() async {
_assertTrue("{ return 0; }");
}
- void test_block_returnNotLast() {
+ test_block_returnNotLast() async {
_assertTrue("{ return 0; throw 'a'; }");
}
- void test_block_throwNotLast() {
+ test_block_throwNotLast() async {
_assertTrue("{ throw 0; x = null; }");
}
- void test_cascadeExpression_argument() {
+ test_cascadeExpression_argument() async {
_assertTrue("a..b(throw '');");
}
- void test_cascadeExpression_index() {
+ test_cascadeExpression_index() async {
_assertTrue("a..[throw ''];");
}
- void test_cascadeExpression_target() {
+ test_cascadeExpression_target() async {
_assertTrue("throw ''..b();");
}
- void test_conditional_ifElse_bothThrows() {
+ test_conditional_ifElse_bothThrows() async {
_assertTrue("c ? throw '' : throw '';");
}
- void test_conditional_ifElse_elseThrows() {
+ test_conditional_ifElse_elseThrows() async {
_assertFalse("c ? i : throw '';");
}
- void test_conditional_ifElse_noThrow() {
+ test_conditional_ifElse_noThrow() async {
_assertFalse("c ? i : j;");
}
- void test_conditional_ifElse_thenThrow() {
+ test_conditional_ifElse_thenThrow() async {
_assertFalse("c ? throw '' : j;");
}
- void test_conditionalAccess() {
+ test_conditionalAccess() async {
_assertFalse("a?.b;");
}
- void test_conditionalAccess_lhs() {
+ test_conditionalAccess_lhs() async {
_assertTrue("(throw '')?.b;");
}
- void test_conditionalAccessAssign() {
+ test_conditionalAccessAssign() async {
_assertFalse("a?.b = c;");
}
- void test_conditionalAccessAssign_lhs() {
+ test_conditionalAccessAssign_lhs() async {
_assertTrue("(throw '')?.b = c;");
}
- void test_conditionalAccessAssign_rhs() {
+ test_conditionalAccessAssign_rhs() async {
_assertFalse("a?.b = throw '';");
}
- void test_conditionalAccessAssign_rhs2() {
+ test_conditionalAccessAssign_rhs2() async {
_assertFalse("null?.b = throw '';");
}
- void test_conditionalAccessIfNullAssign() {
+ test_conditionalAccessIfNullAssign() async {
_assertFalse("a?.b ??= c;");
}
- void test_conditionalAccessIfNullAssign_lhs() {
+ test_conditionalAccessIfNullAssign_lhs() async {
_assertTrue("(throw '')?.b ??= c;");
}
- void test_conditionalAccessIfNullAssign_rhs() {
+ test_conditionalAccessIfNullAssign_rhs() async {
_assertFalse("a?.b ??= throw '';");
}
- void test_conditionalAccessIfNullAssign_rhs2() {
+ test_conditionalAccessIfNullAssign_rhs2() async {
_assertFalse("null?.b ??= throw '';");
}
- void test_conditionalCall() {
+ test_conditionalCall() async {
_assertFalse("a?.b(c);");
}
- void test_conditionalCall_lhs() {
+ test_conditionalCall_lhs() async {
_assertTrue("(throw '')?.b(c);");
}
- void test_conditionalCall_rhs() {
+ test_conditionalCall_rhs() async {
_assertFalse("a?.b(throw '');");
}
- void test_conditionalCall_rhs2() {
+ test_conditionalCall_rhs2() async {
_assertFalse("null?.b(throw '');");
}
- void test_creation() {
+ test_creation() async {
expect(new ExitDetector(), isNotNull);
}
- void test_doStatement_break_and_throw() {
+ test_doStatement_break_and_throw() async {
_assertFalse("{ do { if (1==1) break; throw 'T'; } while (0==1); }");
}
- void test_doStatement_continue_and_throw() {
+ test_doStatement_continue_and_throw() async {
_assertFalse("{ do { if (1==1) continue; throw 'T'; } while (0==1); }");
}
- void test_doStatement_continueDoInSwitch_and_throw() {
+ test_doStatement_continueDoInSwitch_and_throw() async {
_assertFalse('''
{
D: do {
@@ -1270,7 +1273,7 @@
}''');
}
- void test_doStatement_continueInSwitch_and_throw() {
+ test_doStatement_continueInSwitch_and_throw() async {
_assertFalse('''
{
do {
@@ -1283,287 +1286,287 @@
}''');
}
- void test_doStatement_return() {
+ test_doStatement_return() async {
_assertTrue("{ do { return null; } while (1 == 2); }");
}
- void test_doStatement_throwCondition() {
+ test_doStatement_throwCondition() async {
_assertTrue("{ do {} while (throw ''); }");
}
- void test_doStatement_true_break() {
+ test_doStatement_true_break() async {
_assertFalse("{ do { break; } while (true); }");
}
- void test_doStatement_true_continue() {
+ test_doStatement_true_continue() async {
_assertTrue("{ do { continue; } while (true); }");
}
- void test_doStatement_true_continueWithLabel() {
+ test_doStatement_true_continueWithLabel() async {
_assertTrue("{ x: do { continue x; } while (true); }");
}
- void test_doStatement_true_if_return() {
+ test_doStatement_true_if_return() async {
_assertTrue("{ do { if (true) {return null;} } while (true); }");
}
- void test_doStatement_true_noBreak() {
+ test_doStatement_true_noBreak() async {
_assertTrue("{ do {} while (true); }");
}
- void test_doStatement_true_return() {
+ test_doStatement_true_return() async {
_assertTrue("{ do { return null; } while (true); }");
}
- void test_emptyStatement() {
+ test_emptyStatement() async {
_assertFalse(";");
}
- void test_forEachStatement() {
+ test_forEachStatement() async {
_assertFalse("for (element in list) {}");
}
- void test_forEachStatement_throw() {
+ test_forEachStatement_throw() async {
_assertTrue("for (element in throw '') {}");
}
- void test_forStatement_condition() {
+ test_forStatement_condition() async {
_assertTrue("for (; throw 0;) {}");
}
- void test_forStatement_implicitTrue() {
+ test_forStatement_implicitTrue() async {
_assertTrue("for (;;) {}");
}
- void test_forStatement_implicitTrue_break() {
+ test_forStatement_implicitTrue_break() async {
_assertFalse("for (;;) { break; }");
}
- void test_forStatement_implicitTrue_if_break() {
+ test_forStatement_implicitTrue_if_break() async {
_assertFalse("{ for (;;) { if (1==2) { var a = 1; } else { break; } } }");
}
- void test_forStatement_initialization() {
+ test_forStatement_initialization() async {
_assertTrue("for (i = throw 0;;) {}");
}
- void test_forStatement_true() {
+ test_forStatement_true() async {
_assertTrue("for (; true; ) {}");
}
- void test_forStatement_true_break() {
+ test_forStatement_true_break() async {
_assertFalse("{ for (; true; ) { break; } }");
}
- void test_forStatement_true_continue() {
+ test_forStatement_true_continue() async {
_assertTrue("{ for (; true; ) { continue; } }");
}
- void test_forStatement_true_if_return() {
+ test_forStatement_true_if_return() async {
_assertTrue("{ for (; true; ) { if (true) {return null;} } }");
}
- void test_forStatement_true_noBreak() {
+ test_forStatement_true_noBreak() async {
_assertTrue("{ for (; true; ) {} }");
}
- void test_forStatement_updaters() {
+ test_forStatement_updaters() async {
_assertTrue("for (;; i++, throw 0) {}");
}
- void test_forStatement_variableDeclaration() {
+ test_forStatement_variableDeclaration() async {
_assertTrue("for (int i = throw 0;;) {}");
}
- void test_functionExpression() {
+ test_functionExpression() async {
_assertFalse("(){};");
}
- void test_functionExpression_bodyThrows() {
+ test_functionExpression_bodyThrows() async {
_assertFalse("(int i) => throw '';");
}
- void test_functionExpressionInvocation() {
+ test_functionExpressionInvocation() async {
_assertFalse("f(g);");
}
- void test_functionExpressionInvocation_argumentThrows() {
+ test_functionExpressionInvocation_argumentThrows() async {
_assertTrue("f(throw '');");
}
- void test_functionExpressionInvocation_targetThrows() {
+ test_functionExpressionInvocation_targetThrows() async {
_assertTrue("throw ''(g);");
}
- void test_identifier_prefixedIdentifier() {
+ test_identifier_prefixedIdentifier() async {
_assertFalse("a.b;");
}
- void test_identifier_simpleIdentifier() {
+ test_identifier_simpleIdentifier() async {
_assertFalse("a;");
}
- void test_if_false_else_return() {
+ test_if_false_else_return() async {
_assertTrue("if (false) {} else { return 0; }");
}
- void test_if_false_noReturn() {
+ test_if_false_noReturn() async {
_assertFalse("if (false) {}");
}
- void test_if_false_return() {
+ test_if_false_return() async {
_assertFalse("if (false) { return 0; }");
}
- void test_if_noReturn() {
+ test_if_noReturn() async {
_assertFalse("if (c) i++;");
}
- void test_if_return() {
+ test_if_return() async {
_assertFalse("if (c) return 0;");
}
- void test_if_true_noReturn() {
+ test_if_true_noReturn() async {
_assertFalse("if (true) {}");
}
- void test_if_true_return() {
+ test_if_true_return() async {
_assertTrue("if (true) { return 0; }");
}
- void test_ifElse_bothReturn() {
+ test_ifElse_bothReturn() async {
_assertTrue("if (c) return 0; else return 1;");
}
- void test_ifElse_elseReturn() {
+ test_ifElse_elseReturn() async {
_assertFalse("if (c) i++; else return 1;");
}
- void test_ifElse_noReturn() {
+ test_ifElse_noReturn() async {
_assertFalse("if (c) i++; else j++;");
}
- void test_ifElse_thenReturn() {
+ test_ifElse_thenReturn() async {
_assertFalse("if (c) return 0; else j++;");
}
- void test_ifNullAssign() {
+ test_ifNullAssign() async {
_assertFalse("a ??= b;");
}
- void test_ifNullAssign_rhs() {
+ test_ifNullAssign_rhs() async {
_assertFalse("a ??= throw '';");
}
- void test_indexExpression() {
+ test_indexExpression() async {
_assertFalse("a[b];");
}
- void test_indexExpression_index() {
+ test_indexExpression_index() async {
_assertTrue("a[throw ''];");
}
- void test_indexExpression_target() {
+ test_indexExpression_target() async {
_assertTrue("throw ''[b];");
}
- void test_instanceCreationExpression() {
+ test_instanceCreationExpression() async {
_assertFalse("new A(b);");
}
- void test_instanceCreationExpression_argumentThrows() {
+ test_instanceCreationExpression_argumentThrows() async {
_assertTrue("new A(throw '');");
}
- void test_isExpression() {
+ test_isExpression() async {
_assertFalse("A is B;");
}
- void test_isExpression_throws() {
+ test_isExpression_throws() async {
_assertTrue("throw '' is B;");
}
- void test_labeledStatement() {
+ test_labeledStatement() async {
_assertFalse("label: a;");
}
- void test_labeledStatement_throws() {
+ test_labeledStatement_throws() async {
_assertTrue("label: throw '';");
}
- void test_literal_boolean() {
+ test_literal_boolean() async {
_assertFalse("true;");
}
- void test_literal_double() {
+ test_literal_double() async {
_assertFalse("1.1;");
}
- void test_literal_integer() {
+ test_literal_integer() async {
_assertFalse("1;");
}
- void test_literal_null() {
+ test_literal_null() async {
_assertFalse("null;");
}
- void test_literal_String() {
+ test_literal_String() async {
_assertFalse("'str';");
}
- void test_methodInvocation() {
+ test_methodInvocation() async {
_assertFalse("a.b(c);");
}
- void test_methodInvocation_argument() {
+ test_methodInvocation_argument() async {
_assertTrue("a.b(throw '');");
}
- void test_methodInvocation_target() {
+ test_methodInvocation_target() async {
_assertTrue("throw ''.b(c);");
}
- void test_parenthesizedExpression() {
+ test_parenthesizedExpression() async {
_assertFalse("(a);");
}
- void test_parenthesizedExpression_throw() {
+ test_parenthesizedExpression_throw() async {
_assertTrue("(throw '');");
}
- void test_propertyAccess() {
+ test_propertyAccess() async {
_assertFalse("new Object().a;");
}
- void test_propertyAccess_throws() {
+ test_propertyAccess_throws() async {
_assertTrue("(throw '').a;");
}
- void test_rethrow() {
+ test_rethrow() async {
_assertTrue("rethrow;");
}
- void test_return() {
+ test_return() async {
_assertTrue("return 0;");
}
- void test_superExpression() {
+ test_superExpression() async {
_assertFalse("super.a;");
}
- void test_switch_allReturn() {
+ test_switch_allReturn() async {
_assertTrue("switch (i) { case 0: return 0; default: return 1; }");
}
- void test_switch_defaultWithNoStatements() {
+ test_switch_defaultWithNoStatements() async {
_assertFalse("switch (i) { case 0: return 0; default: }");
}
- void test_switch_fallThroughToNotReturn() {
+ test_switch_fallThroughToNotReturn() async {
_assertFalse("switch (i) { case 0: case 1: break; default: return 1; }");
}
- void test_switch_fallThroughToReturn() {
+ test_switch_fallThroughToReturn() async {
_assertTrue("switch (i) { case 0: case 1: return 0; default: return 1; }");
}
@@ -1571,7 +1574,7 @@
// determine that `case 0` exits, `case 1` continues to an exiting case, and
// `default` exits, so the switch exits.
@failingTest
- void test_switch_includesContinue() {
+ test_switch_includesContinue() async {
_assertTrue('''
switch (i) {
zero: case 0: return 0;
@@ -1580,63 +1583,63 @@
}''');
}
- void test_switch_noDefault() {
+ test_switch_noDefault() async {
_assertFalse("switch (i) { case 0: return 0; }");
}
- void test_switch_nonReturn() {
+ test_switch_nonReturn() async {
_assertFalse("switch (i) { case 0: i++; default: return 1; }");
}
- void test_thisExpression() {
+ test_thisExpression() async {
_assertFalse("this.a;");
}
- void test_throwExpression() {
+ test_throwExpression() async {
_assertTrue("throw new Object();");
}
- void test_tryStatement_noReturn() {
+ test_tryStatement_noReturn() async {
_assertFalse("try {} catch (e, s) {} finally {}");
}
- void test_tryStatement_noReturn_noFinally() {
+ test_tryStatement_noReturn_noFinally() async {
_assertFalse("try {} catch (e, s) {}");
}
- void test_tryStatement_return_catch() {
+ test_tryStatement_return_catch() async {
_assertFalse("try {} catch (e, s) { return 1; } finally {}");
}
- void test_tryStatement_return_catch_noFinally() {
+ test_tryStatement_return_catch_noFinally() async {
_assertFalse("try {} catch (e, s) { return 1; }");
}
- void test_tryStatement_return_finally() {
+ test_tryStatement_return_finally() async {
_assertTrue("try {} catch (e, s) {} finally { return 1; }");
}
- void test_tryStatement_return_try_noCatch() {
+ test_tryStatement_return_try_noCatch() async {
_assertTrue("try { return 1; } finally {}");
}
- void test_tryStatement_return_try_oneCatchDoesNotExit() {
+ test_tryStatement_return_try_oneCatchDoesNotExit() async {
_assertFalse("try { return 1; } catch (e, s) {} finally {}");
}
- void test_tryStatement_return_try_oneCatchDoesNotExit_noFinally() {
+ test_tryStatement_return_try_oneCatchDoesNotExit_noFinally() async {
_assertFalse("try { return 1; } catch (e, s) {}");
}
- void test_tryStatement_return_try_oneCatchExits() {
+ test_tryStatement_return_try_oneCatchExits() async {
_assertTrue("try { return 1; } catch (e, s) { return 1; } finally {}");
}
- void test_tryStatement_return_try_oneCatchExits_noFinally() {
+ test_tryStatement_return_try_oneCatchExits_noFinally() async {
_assertTrue("try { return 1; } catch (e, s) { return 1; }");
}
- void test_tryStatement_return_try_twoCatchesDoExit() {
+ test_tryStatement_return_try_twoCatchesDoExit() async {
_assertTrue('''
try { return 1; }
on int catch (e, s) { return 1; }
@@ -1644,14 +1647,14 @@
finally {}''');
}
- void test_tryStatement_return_try_twoCatchesDoExit_noFinally() {
+ test_tryStatement_return_try_twoCatchesDoExit_noFinally() async {
_assertTrue('''
try { return 1; }
on int catch (e, s) { return 1; }
on String catch (e, s) { return 1; }''');
}
- void test_tryStatement_return_try_twoCatchesDoNotExit() {
+ test_tryStatement_return_try_twoCatchesDoNotExit() async {
_assertFalse('''
try { return 1; }
on int catch (e, s) {}
@@ -1659,14 +1662,14 @@
finally {}''');
}
- void test_tryStatement_return_try_twoCatchesDoNotExit_noFinally() {
+ test_tryStatement_return_try_twoCatchesDoNotExit_noFinally() async {
_assertFalse('''
try { return 1; }
on int catch (e, s) {}
on String catch (e, s) {}''');
}
- void test_tryStatement_return_try_twoCatchesMixed() {
+ test_tryStatement_return_try_twoCatchesMixed() async {
_assertFalse('''
try { return 1; }
on int catch (e, s) {}
@@ -1674,66 +1677,66 @@
finally {}''');
}
- void test_tryStatement_return_try_twoCatchesMixed_noFinally() {
+ test_tryStatement_return_try_twoCatchesMixed_noFinally() async {
_assertFalse('''
try { return 1; }
on int catch (e, s) {}
on String catch (e, s) { return 1; }''');
}
- void test_variableDeclarationStatement_noInitializer() {
+ test_variableDeclarationStatement_noInitializer() async {
_assertFalse("int i;");
}
- void test_variableDeclarationStatement_noThrow() {
+ test_variableDeclarationStatement_noThrow() async {
_assertFalse("int i = 0;");
}
- void test_variableDeclarationStatement_throw() {
+ test_variableDeclarationStatement_throw() async {
_assertTrue("int i = throw new Object();");
}
- void test_whileStatement_false_nonReturn() {
+ test_whileStatement_false_nonReturn() async {
_assertFalse("{ while (false) {} }");
}
- void test_whileStatement_throwCondition() {
+ test_whileStatement_throwCondition() async {
_assertTrue("{ while (throw '') {} }");
}
- void test_whileStatement_true_break() {
+ test_whileStatement_true_break() async {
_assertFalse("{ while (true) { break; } }");
}
- void test_whileStatement_true_break_and_throw() {
+ test_whileStatement_true_break_and_throw() async {
_assertFalse("{ while (true) { if (1==1) break; throw 'T'; } }");
}
- void test_whileStatement_true_continue() {
+ test_whileStatement_true_continue() async {
_assertTrue("{ while (true) { continue; } }");
}
- void test_whileStatement_true_continueWithLabel() {
+ test_whileStatement_true_continueWithLabel() async {
_assertTrue("{ x: while (true) { continue x; } }");
}
- void test_whileStatement_true_doStatement_scopeRequired() {
+ test_whileStatement_true_doStatement_scopeRequired() async {
_assertTrue("{ while (true) { x: do { continue x; } while (true); } }");
}
- void test_whileStatement_true_if_return() {
+ test_whileStatement_true_if_return() async {
_assertTrue("{ while (true) { if (true) {return null;} } }");
}
- void test_whileStatement_true_noBreak() {
+ test_whileStatement_true_noBreak() async {
_assertTrue("{ while (true) {} }");
}
- void test_whileStatement_true_return() {
+ test_whileStatement_true_return() async {
_assertTrue("{ while (true) { return null; } }");
}
- void test_whileStatement_true_throw() {
+ test_whileStatement_true_throw() async {
_assertTrue("{ while (true) { throw ''; } }");
}
@@ -1759,7 +1762,7 @@
*/
@reflectiveTest
class ExitDetectorTest2 extends ResolverTestCase {
- void test_forStatement_implicitTrue_breakWithLabel() {
+ test_forStatement_implicitTrue_breakWithLabel() async {
Source source = addSource(r'''
void f() {
x: for (;;) {
@@ -1773,7 +1776,7 @@
_assertNthStatementDoesNotExit(source, 0);
}
- void test_switch_withEnum_false_noDefault() {
+ test_switch_withEnum_false_noDefault() async {
Source source = addSource(r'''
enum E { A, B }
String f(E e) {
@@ -1790,7 +1793,7 @@
_assertNthStatementDoesNotExit(source, 1);
}
- void test_switch_withEnum_false_withDefault() {
+ test_switch_withEnum_false_withDefault() async {
Source source = addSource(r'''
enum E { A, B }
String f(E e) {
@@ -1807,7 +1810,7 @@
_assertNthStatementDoesNotExit(source, 1);
}
- void test_switch_withEnum_true_noDefault() {
+ test_switch_withEnum_true_noDefault() async {
Source source = addSource(r'''
enum E { A, B }
String f(E e) {
@@ -1822,7 +1825,7 @@
_assertNthStatementDoesNotExit(source, 0);
}
- void test_switch_withEnum_true_withExitingDefault() {
+ test_switch_withEnum_true_withExitingDefault() async {
Source source = addSource(r'''
enum E { A, B }
String f(E e) {
@@ -1837,7 +1840,7 @@
_assertNthStatementExits(source, 0);
}
- void test_switch_withEnum_true_withNonExitingDefault() {
+ test_switch_withEnum_true_withNonExitingDefault() async {
Source source = addSource(r'''
enum E { A, B }
String f(E e) {
@@ -1853,7 +1856,7 @@
_assertNthStatementDoesNotExit(source, 1);
}
- void test_whileStatement_breakWithLabel() {
+ test_whileStatement_breakWithLabel() async {
Source source = addSource(r'''
void f() {
x: while (true) {
@@ -1867,7 +1870,7 @@
_assertNthStatementDoesNotExit(source, 0);
}
- void test_whileStatement_breakWithLabel_afterExiting() {
+ test_whileStatement_breakWithLabel_afterExiting() async {
Source source = addSource(r'''
void f() {
x: while (true) {
@@ -1881,7 +1884,7 @@
_assertNthStatementExits(source, 0);
}
- void test_whileStatement_switchWithBreakWithLabel() {
+ test_whileStatement_switchWithBreakWithLabel() async {
Source source = addSource(r'''
void f() {
x: while (true) {
@@ -1895,7 +1898,7 @@
_assertNthStatementDoesNotExit(source, 0);
}
- void test_yieldStatement_plain() {
+ test_yieldStatement_plain() async {
Source source = addSource(r'''
void f() sync* {
yield 1;
@@ -1904,7 +1907,7 @@
_assertNthStatementDoesNotExit(source, 0);
}
- void test_yieldStatement_star_plain() {
+ test_yieldStatement_star_plain() async {
Source source = addSource(r'''
void f() sync* {
yield* 1;
@@ -1913,7 +1916,7 @@
_assertNthStatementDoesNotExit(source, 0);
}
- void test_yieldStatement_star_throw() {
+ test_yieldStatement_star_throw() async {
Source source = addSource(r'''
void f() sync* {
yield* throw '';
@@ -1922,7 +1925,7 @@
_assertNthStatementExits(source, 0);
}
- void test_yieldStatement_throw() {
+ test_yieldStatement_throw() async {
Source source = addSource(r'''
void f() sync* {
yield throw '';
@@ -1955,7 +1958,7 @@
@reflectiveTest
class FileBasedSourceTest {
- void test_equals_false_differentFiles() {
+ test_equals_false_differentFiles() async {
JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart");
JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart");
FileBasedSource source1 = new FileBasedSource(file1);
@@ -1963,13 +1966,13 @@
expect(source1 == source2, isFalse);
}
- void test_equals_false_null() {
+ test_equals_false_null() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist1.dart");
FileBasedSource source1 = new FileBasedSource(file);
expect(source1 == null, isFalse);
}
- void test_equals_true() {
+ test_equals_true() async {
JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
FileBasedSource source1 = new FileBasedSource(file1);
@@ -1977,7 +1980,7 @@
expect(source1 == source2, isTrue);
}
- void test_fileReadMode() {
+ test_fileReadMode() async {
expect(FileBasedSource.fileReadMode('a'), 'a');
expect(FileBasedSource.fileReadMode('a\n'), 'a\n');
expect(FileBasedSource.fileReadMode('ab'), 'ab');
@@ -1987,7 +1990,7 @@
expect(FileBasedSource.fileReadMode('a\r\nb'), 'a\r\nb');
}
- void test_fileReadMode_changed() {
+ test_fileReadMode_changed() async {
FileBasedSource.fileReadMode = (String s) => s + 'xyz';
expect(FileBasedSource.fileReadMode('a'), 'axyz');
expect(FileBasedSource.fileReadMode('a\n'), 'a\nxyz');
@@ -1996,7 +1999,7 @@
FileBasedSource.fileReadMode = (String s) => s;
}
- void test_fileReadMode_normalize_eol_always() {
+ test_fileReadMode_normalize_eol_always() async {
FileBasedSource.fileReadMode =
PhysicalResourceProvider.NORMALIZE_EOL_ALWAYS;
expect(FileBasedSource.fileReadMode('a'), 'a');
@@ -2019,7 +2022,7 @@
FileBasedSource.fileReadMode = (String s) => s;
}
- void test_getEncoding() {
+ test_getEncoding() async {
SourceFactory factory = new SourceFactory(
[new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)]);
String fullPath = "/does/not/exist.dart";
@@ -2028,20 +2031,20 @@
expect(factory.fromEncoding(source.encoding), source);
}
- void test_getFullName() {
+ test_getFullName() async {
String fullPath = "/does/not/exist.dart";
JavaFile file = FileUtilities2.createFile(fullPath);
FileBasedSource source = new FileBasedSource(file);
expect(source.fullName, file.getAbsolutePath());
}
- void test_getShortName() {
+ test_getShortName() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
FileBasedSource source = new FileBasedSource(file);
expect(source.shortName, "exist.dart");
}
- void test_hashCode() {
+ test_hashCode() async {
JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
FileBasedSource source1 = new FileBasedSource(file1);
@@ -2049,7 +2052,7 @@
expect(source2.hashCode, source1.hashCode);
}
- void test_isInSystemLibrary_contagious() {
+ test_isInSystemLibrary_contagious() async {
DartSdk sdk = _createSdk();
UriResolver resolver = new DartUriResolver(sdk);
SourceFactory factory = new SourceFactory([resolver]);
@@ -2063,7 +2066,7 @@
expect(partSource.isInSystemLibrary, isTrue);
}
- void test_isInSystemLibrary_false() {
+ test_isInSystemLibrary_false() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
FileBasedSource source = new FileBasedSource(file);
expect(source, isNotNull);
@@ -2071,7 +2074,7 @@
expect(source.isInSystemLibrary, isFalse);
}
- void test_issue14500() {
+ test_issue14500() async {
// see https://code.google.com/p/dart/issues/detail?id=14500
FileBasedSource source = new FileBasedSource(
FileUtilities2.createFile("/some/packages/foo:bar.dart"));
@@ -2079,7 +2082,7 @@
expect(source.exists(), isFalse);
}
- void test_resolveRelative_file_fileName() {
+ test_resolveRelative_file_fileName() async {
if (OSUtilities.isWindows()) {
// On Windows, the URI that is produced includes a drive letter,
// which I believe is not consistent across all machines that might run
@@ -2094,7 +2097,7 @@
expect(relative.toString(), "file:///a/b/lib.dart");
}
- void test_resolveRelative_file_filePath() {
+ test_resolveRelative_file_filePath() async {
if (OSUtilities.isWindows()) {
// On Windows, the URI that is produced includes a drive letter,
// which I believe is not consistent across all machines that might run
@@ -2109,7 +2112,7 @@
expect(relative.toString(), "file:///a/b/c/lib.dart");
}
- void test_resolveRelative_file_filePathWithParent() {
+ test_resolveRelative_file_filePathWithParent() async {
if (OSUtilities.isWindows()) {
// On Windows, the URI that is produced includes a drive letter, which I
// believe is not consistent across all machines that might run this test.
@@ -2123,7 +2126,7 @@
expect(relative.toString(), "file:///a/c/lib.dart");
}
- void test_system() {
+ test_system() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
FileBasedSource source = new FileBasedSource(file, Uri.parse("dart:core"));
expect(source, isNotNull);
@@ -2134,44 +2137,44 @@
@reflectiveTest
class ResolveRelativeUriTest {
- void test_resolveRelative_dart_dartUri() {
+ test_resolveRelative_dart_dartUri() async {
_assertResolve('dart:foo', 'dart:bar', 'dart:bar');
}
- void test_resolveRelative_dart_fileName() {
+ test_resolveRelative_dart_fileName() async {
_assertResolve('dart:test', 'lib.dart', 'dart:test/lib.dart');
}
- void test_resolveRelative_dart_filePath() {
+ test_resolveRelative_dart_filePath() async {
_assertResolve('dart:test', 'c/lib.dart', 'dart:test/c/lib.dart');
}
- void test_resolveRelative_dart_filePathWithParent() {
+ test_resolveRelative_dart_filePathWithParent() async {
_assertResolve(
'dart:test/b/test.dart', '../c/lib.dart', 'dart:test/c/lib.dart');
}
- void test_resolveRelative_package_dartUri() {
+ test_resolveRelative_package_dartUri() async {
_assertResolve('package:foo/bar.dart', 'dart:test', 'dart:test');
}
- void test_resolveRelative_package_emptyPath() {
+ test_resolveRelative_package_emptyPath() async {
_assertResolve('package:foo/bar.dart', '', 'package:foo/bar.dart');
}
- void test_resolveRelative_package_fileName() {
+ test_resolveRelative_package_fileName() async {
_assertResolve('package:b/test.dart', 'lib.dart', 'package:b/lib.dart');
}
- void test_resolveRelative_package_fileNameWithoutPackageName() {
+ test_resolveRelative_package_fileNameWithoutPackageName() async {
_assertResolve('package:test.dart', 'lib.dart', 'package:lib.dart');
}
- void test_resolveRelative_package_filePath() {
+ test_resolveRelative_package_filePath() async {
_assertResolve('package:b/test.dart', 'c/lib.dart', 'package:b/c/lib.dart');
}
- void test_resolveRelative_package_filePathWithParent() {
+ test_resolveRelative_package_filePathWithParent() async {
_assertResolve(
'package:a/b/test.dart', '../c/lib.dart', 'package:a/c/lib.dart');
}
@@ -2188,7 +2191,7 @@
@deprecated
@reflectiveTest
class SDKLibrariesReaderTest extends EngineTestCase {
- void test_readFrom_dart2js() {
+ test_readFrom_dart2js() async {
LibraryMap libraryMap = new SdkLibrariesReader(true).readFromFile(
FileUtilities2.createFile("/libs.dart"),
r'''
@@ -2213,14 +2216,14 @@
expect(first.isVmLibrary, true);
}
- void test_readFrom_empty() {
+ test_readFrom_empty() async {
LibraryMap libraryMap = new SdkLibrariesReader(false)
.readFromFile(FileUtilities2.createFile("/libs.dart"), "");
expect(libraryMap, isNotNull);
expect(libraryMap.size(), 0);
}
- void test_readFrom_normal() {
+ test_readFrom_normal() async {
LibraryMap libraryMap = new SdkLibrariesReader(false).readFromFile(
FileUtilities2.createFile("/libs.dart"),
r'''
@@ -2263,14 +2266,14 @@
@reflectiveTest
class UriKindTest {
- void test_fromEncoding() {
+ test_fromEncoding() async {
expect(UriKind.fromEncoding(0x64), same(UriKind.DART_URI));
expect(UriKind.fromEncoding(0x66), same(UriKind.FILE_URI));
expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI));
expect(UriKind.fromEncoding(0x58), same(null));
}
- void test_getEncoding() {
+ test_getEncoding() async {
expect(UriKind.DART_URI.encoding, 0x64);
expect(UriKind.FILE_URI.encoding, 0x66);
expect(UriKind.PACKAGE_URI.encoding, 0x70);
diff --git a/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart b/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
index 7fa42f2..e948278 100644
--- a/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
@@ -13,12 +13,13 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(CheckedModeCompileTimeErrorCodeTest);
+ defineReflectiveTests(CheckedModeCompileTimeErrorCodeTest_Driver);
});
}
@reflectiveTest
class CheckedModeCompileTimeErrorCodeTest extends ResolverTestCase {
- void test_fieldFormalParameterAssignableToField_extends() {
+ test_fieldFormalParameterAssignableToField_extends() async {
// According to checked-mode type checking rules, a value of type B is
// assignable to a field of type A, because B extends A (and hence is a
// subtype of A).
@@ -34,12 +35,12 @@
const C(this.a);
}
var v = const C(const B());''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_fieldType_unresolved_null() {
+ test_fieldFormalParameterAssignableToField_fieldType_unresolved_null() async {
// Null always passes runtime type checks, even when the type is
// unresolved.
Source source = addSource(r'''
@@ -48,12 +49,12 @@
const A(String this.x);
}
var v = const A(null);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_implements() {
+ test_fieldFormalParameterAssignableToField_implements() async {
// According to checked-mode type checking rules, a value of type B is
// assignable to a field of type A, because B implements A (and hence is a
// subtype of A).
@@ -67,36 +68,36 @@
const C(this.a);
}
var v = const C(const B());''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_list_dynamic() {
+ test_fieldFormalParameterAssignableToField_list_dynamic() async {
// [1, 2, 3] has type List<dynamic>, which is a subtype of List<int>.
Source source = addSource(r'''
class A {
const A(List<int> x);
}
var x = const A(const [1, 2, 3]);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_list_nonDynamic() {
+ test_fieldFormalParameterAssignableToField_list_nonDynamic() async {
// <int>[1, 2, 3] has type List<int>, which is a subtype of List<num>.
Source source = addSource(r'''
class A {
const A(List<num> x);
}
var x = const A(const <int>[1, 2, 3]);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_map_dynamic() {
+ test_fieldFormalParameterAssignableToField_map_dynamic() async {
// {1: 2} has type Map<dynamic, dynamic>, which is a subtype of
// Map<int, int>.
Source source = addSource(r'''
@@ -104,12 +105,12 @@
const A(Map<int, int> x);
}
var x = const A(const {1: 2});''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_map_keyDifferent() {
+ test_fieldFormalParameterAssignableToField_map_keyDifferent() async {
// <int, int>{1: 2} has type Map<int, int>, which is a subtype of
// Map<num, int>.
Source source = addSource(r'''
@@ -117,12 +118,12 @@
const A(Map<num, int> x);
}
var x = const A(const <int, int>{1: 2});''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_map_valueDifferent() {
+ test_fieldFormalParameterAssignableToField_map_valueDifferent() async {
// <int, int>{1: 2} has type Map<int, int>, which is a subtype of
// Map<int, num>.
Source source = addSource(r'''
@@ -130,12 +131,12 @@
const A(Map<int, num> x);
}
var x = const A(const <int, int>{1: 2});''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_notype() {
+ test_fieldFormalParameterAssignableToField_notype() async {
// If a field is declared without a type, then any value may be assigned to
// it.
Source source = addSource(r'''
@@ -144,12 +145,12 @@
const A(this.x);
}
var v = const A(5);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_null() {
+ test_fieldFormalParameterAssignableToField_null() async {
// Null is assignable to anything.
Source source = addSource(r'''
class A {
@@ -157,12 +158,12 @@
const A(this.x);
}
var v = const A(null);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_typedef() {
+ test_fieldFormalParameterAssignableToField_typedef() async {
// foo has the runtime type dynamic -> dynamic, so it should be assignable
// to A.f.
Source source = addSource(r'''
@@ -173,12 +174,12 @@
}
foo(x) => 1;
var v = const A(foo);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterAssignableToField_typeSubstitution() {
+ test_fieldFormalParameterAssignableToField_typeSubstitution() async {
// foo has the runtime type dynamic -> dynamic, so it should be assignable
// to A.f.
Source source = addSource(r'''
@@ -187,19 +188,19 @@
const A(this.x);
}
var v = const A<int>(3);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField() {
+ test_fieldFormalParameterNotAssignableToField() async {
Source source = addSource(r'''
class A {
final int x;
const A(this.x);
}
var v = const A('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -207,7 +208,7 @@
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_extends() {
+ test_fieldFormalParameterNotAssignableToField_extends() async {
// According to checked-mode type checking rules, a value of type A is not
// assignable to a field of type B, because B extends A (the subtyping
// relationship is in the wrong direction).
@@ -223,21 +224,21 @@
const C(this.b);
}
var v = const C(const A());''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
]);
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_fieldType() {
+ test_fieldFormalParameterNotAssignableToField_fieldType() async {
Source source = addSource(r'''
class A {
final int x;
const A(String this.x);
}
var v = const A('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE
@@ -245,14 +246,14 @@
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_fieldType_unresolved() {
+ test_fieldFormalParameterNotAssignableToField_fieldType_unresolved() async {
Source source = addSource(r'''
class A {
final Unresolved x;
const A(String this.x);
}
var v = const A('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticWarningCode.UNDEFINED_CLASS
@@ -260,7 +261,7 @@
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_implements() {
+ test_fieldFormalParameterNotAssignableToField_implements() async {
// According to checked-mode type checking rules, a value of type A is not
// assignable to a field of type B, because B implements A (the subtyping
// relationship is in the wrong direction).
@@ -274,28 +275,28 @@
const C(this.b);
}
var v = const C(const A());''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
]);
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_list() {
+ test_fieldFormalParameterNotAssignableToField_list() async {
// <num>[1, 2, 3] has type List<num>, which is not a subtype of List<int>.
Source source = addSource(r'''
class A {
const A(List<int> x);
}
var x = const A(const <num>[1, 2, 3]);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
]);
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_map_keyMismatch() {
+ test_fieldFormalParameterNotAssignableToField_map_keyMismatch() async {
// <num, int>{1: 2} has type Map<num, int>, which is not a subtype of
// Map<int, int>.
Source source = addSource(r'''
@@ -303,14 +304,14 @@
const A(Map<int, int> x);
}
var x = const A(const <num, int>{1: 2});''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
]);
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_map_valueMismatch() {
+ test_fieldFormalParameterNotAssignableToField_map_valueMismatch() async {
// <int, num>{1: 2} has type Map<int, num>, which is not a subtype of
// Map<int, int>.
Source source = addSource(r'''
@@ -318,21 +319,21 @@
const A(Map<int, int> x);
}
var x = const A(const <int, num>{1: 2});''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
]);
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_optional() {
+ test_fieldFormalParameterNotAssignableToField_optional() async {
Source source = addSource(r'''
class A {
final int x;
const A([this.x = 'foo']);
}
var v = const A();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticTypeWarningCode.INVALID_ASSIGNMENT
@@ -340,7 +341,7 @@
verify([source]);
}
- void test_fieldFormalParameterNotAssignableToField_typedef() {
+ test_fieldFormalParameterNotAssignableToField_typedef() async {
// foo has the runtime type String -> int, so it should not be assignable
// to A.f (A.f requires it to be int -> String).
Source source = addSource(r'''
@@ -351,7 +352,7 @@
}
int foo(String x) => 1;
var v = const A(foo);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -359,13 +360,13 @@
verify([source]);
}
- void test_fieldInitializerNotAssignable() {
+ test_fieldInitializerNotAssignable() async {
Source source = addSource(r'''
class A {
final int x;
const A() : x = '';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE,
StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE
@@ -373,21 +374,21 @@
verify([source]);
}
- void test_fieldTypeMismatch() {
+ test_fieldTypeMismatch() async {
Source source = addSource(r'''
class A {
const A(x) : y = x;
final int y;
}
var v = const A('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
]);
verify([source]);
}
- void test_fieldTypeMismatch_generic() {
+ test_fieldTypeMismatch_generic() async {
Source source = addSource(r'''
class C<T> {
final T x = y;
@@ -396,7 +397,7 @@
const int y = 1;
var v = const C<String>();
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
StaticTypeWarningCode.INVALID_ASSIGNMENT
@@ -404,14 +405,14 @@
verify([source]);
}
- void test_fieldTypeMismatch_unresolved() {
+ test_fieldTypeMismatch_unresolved() async {
Source source = addSource(r'''
class A {
const A(x) : y = x;
final Unresolved y;
}
var v = const A('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
StaticWarningCode.UNDEFINED_CLASS
@@ -419,7 +420,7 @@
verify([source]);
}
- void test_fieldTypeOk_generic() {
+ test_fieldTypeOk_generic() async {
Source source = addSource(r'''
class C<T> {
final T x = y;
@@ -428,24 +429,24 @@
const int y = 1;
var v = const C<int>();
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
verify([source]);
}
- void test_fieldTypeOk_null() {
+ test_fieldTypeOk_null() async {
Source source = addSource(r'''
class A {
const A(x) : y = x;
final int y;
}
var v = const A(null);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldTypeOk_unresolved_null() {
+ test_fieldTypeOk_unresolved_null() async {
// Null always passes runtime type checks, even when the type is
// unresolved.
Source source = addSource(r'''
@@ -454,14 +455,14 @@
final Unresolved y;
}
var v = const A(null);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
verify([source]);
}
- void test_listElementTypeNotAssignable() {
+ test_listElementTypeNotAssignable() async {
Source source = addSource("var v = const <String> [42];");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
@@ -469,9 +470,9 @@
verify([source]);
}
- void test_mapKeyTypeNotAssignable() {
+ test_mapKeyTypeNotAssignable() async {
Source source = addSource("var v = const <String, int > {1 : 2};");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE
@@ -479,9 +480,9 @@
verify([source]);
}
- void test_mapValueTypeNotAssignable() {
+ test_mapValueTypeNotAssignable() async {
Source source = addSource("var v = const <String, String> {'a' : 2};");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE
@@ -489,30 +490,30 @@
verify([source]);
}
- void test_parameterAssignable_null() {
+ test_parameterAssignable_null() async {
// Null is assignable to anything.
Source source = addSource(r'''
class A {
const A(int x);
}
var v = const A(null);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_parameterAssignable_typeSubstitution() {
+ test_parameterAssignable_typeSubstitution() async {
Source source = addSource(r'''
class A<T> {
const A(T x);
}
var v = const A<int>(3);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_parameterAssignable_undefined_null() {
+ test_parameterAssignable_undefined_null() async {
// Null always passes runtime type checks, even when the type is
// unresolved.
Source source = addSource(r'''
@@ -520,18 +521,18 @@
const A(Unresolved x);
}
var v = const A(null);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
verify([source]);
}
- void test_parameterNotAssignable() {
+ test_parameterNotAssignable() async {
Source source = addSource(r'''
class A {
const A(int x);
}
var v = const A('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -539,13 +540,13 @@
verify([source]);
}
- void test_parameterNotAssignable_typeSubstitution() {
+ test_parameterNotAssignable_typeSubstitution() async {
Source source = addSource(r'''
class A<T> {
const A(T x);
}
var v = const A<int>('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -553,13 +554,13 @@
verify([source]);
}
- void test_parameterNotAssignable_undefined() {
+ test_parameterNotAssignable_undefined() async {
Source source = addSource(r'''
class A {
const A(Unresolved x);
}
var v = const A('foo');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
StaticWarningCode.UNDEFINED_CLASS
@@ -567,39 +568,39 @@
verify([source]);
}
- void test_redirectingConstructor_paramTypeMismatch() {
+ test_redirectingConstructor_paramTypeMismatch() async {
Source source = addSource(r'''
class A {
const A.a1(x) : this.a2(x);
const A.a2(String x);
}
var v = const A.a1(0);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
]);
verify([source]);
}
- void test_topLevelVarAssignable_null() {
+ test_topLevelVarAssignable_null() async {
Source source = addSource("const int x = null;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_topLevelVarAssignable_undefined_null() {
+ test_topLevelVarAssignable_undefined_null() async {
// Null always passes runtime type checks, even when the type is
// unresolved.
Source source = addSource("const Unresolved x = null;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
verify([source]);
}
- void test_topLevelVarNotAssignable() {
+ test_topLevelVarNotAssignable() async {
Source source = addSource("const int x = 'foo';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
StaticTypeWarningCode.INVALID_ASSIGNMENT
@@ -607,9 +608,9 @@
verify([source]);
}
- void test_topLevelVarNotAssignable_undefined() {
+ test_topLevelVarNotAssignable_undefined() async {
Source source = addSource("const Unresolved x = 'foo';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
StaticWarningCode.UNDEFINED_CLASS
@@ -617,3 +618,10 @@
verify([source]);
}
}
+
+@reflectiveTest
+class CheckedModeCompileTimeErrorCodeTest_Driver
+ extends CheckedModeCompileTimeErrorCodeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
diff --git a/pkg/analyzer/test/generated/compile_time_error_code_driver_test.dart b/pkg/analyzer/test/generated/compile_time_error_code_driver_test.dart
new file mode 100644
index 0000000..96200ce
--- /dev/null
+++ b/pkg/analyzer/test/generated/compile_time_error_code_driver_test.dart
@@ -0,0 +1,104 @@
+// Copyright (c) 2017, 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:test_reflective_loader/test_reflective_loader.dart';
+
+import 'compile_time_error_code_test.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(CompileTimeErrorCodeTest_Driver);
+ });
+}
+
+@reflectiveTest
+class CompileTimeErrorCodeTest_Driver extends CompileTimeErrorCodeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ @failingTest
+ @override
+ test_exportOfNonLibrary() {
+ return super.test_exportOfNonLibrary();
+ }
+
+ @failingTest
+ @override
+ test_fieldInitializerOutsideConstructor_inFunctionTypeParameter() {
+ return super
+ .test_fieldInitializerOutsideConstructor_inFunctionTypeParameter();
+ }
+
+ @failingTest
+ @override
+ test_fromEnvironment_bool_badDefault_whenDefined() {
+ return super.test_fromEnvironment_bool_badDefault_whenDefined();
+ }
+
+ @failingTest
+ @override
+ test_importOfNonLibrary() {
+ return super.test_importOfNonLibrary();
+ }
+
+ @failingTest
+ @override
+ test_nonConstValueInInitializer_assert_condition() {
+ return super.test_nonConstValueInInitializer_assert_condition();
+ }
+
+ @failingTest
+ @override
+ test_nonConstValueInInitializer_assert_message() {
+ return super.test_nonConstValueInInitializer_assert_message();
+ }
+
+ @failingTest
+ @override
+ test_prefixCollidesWithTopLevelMembers_functionTypeAlias() {
+ return super.test_prefixCollidesWithTopLevelMembers_functionTypeAlias();
+ }
+
+ @failingTest
+ @override
+ test_prefixCollidesWithTopLevelMembers_topLevelFunction() {
+ return super.test_prefixCollidesWithTopLevelMembers_topLevelFunction();
+ }
+
+ @failingTest
+ @override
+ test_prefixCollidesWithTopLevelMembers_topLevelVariable() {
+ return super.test_prefixCollidesWithTopLevelMembers_topLevelVariable();
+ }
+
+ @failingTest
+ @override
+ test_prefixCollidesWithTopLevelMembers_type() {
+ return super.test_prefixCollidesWithTopLevelMembers_type();
+ }
+
+ @failingTest
+ @override
+ test_typeAliasCannotReferenceItself_typeVariableBounds() {
+ return super.test_typeAliasCannotReferenceItself_typeVariableBounds();
+ }
+
+ @failingTest
+ @override
+ test_uriDoesNotExist_import_appears_after_deleting_target() {
+ return super.test_uriDoesNotExist_import_appears_after_deleting_target();
+ }
+
+ @failingTest
+ @override
+ test_uriDoesNotExist_import_disappears_when_fixed() {
+ return super.test_uriDoesNotExist_import_disappears_when_fixed();
+ }
+
+ @failingTest
+ @override
+ test_uriWithInterpolation_nonConstant() {
+ return super.test_uriWithInterpolation_nonConstant();
+ }
+}
diff --git a/pkg/analyzer/test/generated/compile_time_error_code_test.dart b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
index 098ff94..b3e4254 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
@@ -4,6 +4,8 @@
library analyzer.test.generated.compile_time_error_code_test;
+import 'dart:async';
+
import 'package:analyzer/error/error.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/engine.dart';
@@ -22,7 +24,7 @@
@reflectiveTest
class CompileTimeErrorCodeTest extends ResolverTestCase {
- void fail_awaitInWrongContext_sync() {
+ fail_awaitInWrongContext_sync() async {
// This test requires better error recovery than we currently have. In
// particular, we need to be able to distinguish between an await expression
// in the wrong context, and the use of 'await' as an identifier.
@@ -30,12 +32,12 @@
f(x) {
return await x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
verify([source]);
}
- void fail_awaitInWrongContext_syncStar() {
+ fail_awaitInWrongContext_syncStar() async {
// This test requires better error recovery than we currently have. In
// particular, we need to be able to distinguish between an await expression
// in the wrong context, and the use of 'await' as an identifier.
@@ -43,24 +45,24 @@
f(x) sync* {
yield await x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
verify([source]);
}
- void fail_constEvalThrowsException() {
+ fail_constEvalThrowsException() async {
Source source = addSource(r'''
class C {
const C();
}
f() { return const C(); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION]);
verify([source]);
}
- void fail_invalidIdentifierInAsync_async() {
+ fail_invalidIdentifierInAsync_async() async {
// TODO(brianwilkerson) Report this error.
Source source = addSource(r'''
class A {
@@ -68,12 +70,12 @@
int async;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]);
verify([source]);
}
- void fail_invalidIdentifierInAsync_await() {
+ fail_invalidIdentifierInAsync_await() async {
// TODO(brianwilkerson) Report this error.
Source source = addSource(r'''
class A {
@@ -81,12 +83,12 @@
int await;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]);
verify([source]);
}
- void fail_invalidIdentifierInAsync_yield() {
+ fail_invalidIdentifierInAsync_yield() async {
// TODO(brianwilkerson) Report this error.
Source source = addSource(r'''
class A {
@@ -94,109 +96,109 @@
int yield;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC]);
verify([source]);
}
- void fail_mixinDeclaresConstructor() {
+ fail_mixinDeclaresConstructor() async {
Source source = addSource(r'''
class A {
A() {}
}
class B extends Object mixin A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
verify([source]);
}
- void fail_mixinOfNonClass() {
+ fail_mixinOfNonClass() async {
// TODO(brianwilkerson) Compare with MIXIN_WITH_NON_CLASS_SUPERCLASS.
Source source = addSource(r'''
var A;
class B extends Object mixin A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
verify([source]);
}
- void fail_objectCannotExtendAnotherClass() {
+ fail_objectCannotExtendAnotherClass() async {
Source source = addSource(r'''
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]);
verify([source]);
}
- void fail_superInitializerInObject() {
+ fail_superInitializerInObject() async {
Source source = addSource(r'''
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]);
verify([source]);
}
- void fail_yieldEachInNonGenerator_async() {
+ fail_yieldEachInNonGenerator_async() async {
// TODO(brianwilkerson) We are currently parsing the yield statement as a
// binary expression.
Source source = addSource(r'''
f() async {
yield* 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]);
verify([source]);
}
- void fail_yieldEachInNonGenerator_sync() {
+ fail_yieldEachInNonGenerator_sync() async {
// TODO(brianwilkerson) We are currently parsing the yield statement as a
// binary expression.
Source source = addSource(r'''
f() {
yield* 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.YIELD_IN_NON_GENERATOR]);
verify([source]);
}
- void fail_yieldInNonGenerator_async() {
+ fail_yieldInNonGenerator_async() async {
// TODO(brianwilkerson) We are currently trying to parse the yield statement
// as a binary expression.
Source source = addSource(r'''
f() async {
yield 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.YIELD_IN_NON_GENERATOR]);
verify([source]);
}
- void fail_yieldInNonGenerator_sync() {
+ fail_yieldInNonGenerator_sync() async {
// TODO(brianwilkerson) We are currently trying to parse the yield statement
// as a binary expression.
Source source = addSource(r'''
f() {
yield 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]);
verify([source]);
}
- void test_accessPrivateEnumField() {
+ test_accessPrivateEnumField() async {
Source source = addSource(r'''
enum E { ONE }
String name(E e) {
return e._name;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD]);
// Cannot verify because "_name" cannot be resolved.
}
- void test_ambiguousExport() {
+ test_ambiguousExport() async {
Source source = addSource(r'''
library L;
export 'lib1.dart';
@@ -211,12 +213,12 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]);
verify([source]);
}
- void test_annotationWithNotClass() {
+ test_annotationWithNotClass() async {
Source source = addSource('''
class Property {
final int value;
@@ -229,12 +231,12 @@
main() {
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]);
verify([source]);
}
- void test_annotationWithNotClass_prefixed() {
+ test_annotationWithNotClass_prefixed() async {
addNamedSource(
"/annotations.dart",
r'''
@@ -251,12 +253,12 @@
main() {
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]);
verify([source]);
}
- void test_async_used_as_identifier_in_annotation() {
+ test_async_used_as_identifier_in_annotation() async {
Source source = addSource('''
const int async = 0;
f() async {
@@ -264,12 +266,12 @@
g(0);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_argument_label() {
+ test_async_used_as_identifier_in_argument_label() async {
Source source = addSource('''
@proxy
class C {}
@@ -277,35 +279,35 @@
new C().g(async: 0);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
// Note: we don't call verify([source]) because verify() doesn't understand
// about @proxy.
}
- void test_async_used_as_identifier_in_async_method() {
+ test_async_used_as_identifier_in_async_method() async {
Source source = addSource('''
f() async {
var async = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_async_star_method() {
+ test_async_used_as_identifier_in_async_star_method() async {
Source source = addSource('''
f() async* {
var async = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_break_statement() {
+ test_async_used_as_identifier_in_break_statement() async {
Source source = addSource('''
f() async {
while (true) {
@@ -313,7 +315,7 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
CompileTimeErrorCode.LABEL_UNDEFINED
@@ -322,7 +324,7 @@
// "async" label is unresolved.
}
- void test_async_used_as_identifier_in_cascaded_invocation() {
+ test_async_used_as_identifier_in_cascaded_invocation() async {
Source source = addSource('''
class C {
int async() => 1;
@@ -331,12 +333,12 @@
return new C()..async();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_cascaded_setter_invocation() {
+ test_async_used_as_identifier_in_cascaded_setter_invocation() async {
Source source = addSource('''
class C {
void set async(int i) {}
@@ -345,12 +347,12 @@
return new C()..async = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_catch_exception_argument() {
+ test_async_used_as_identifier_in_catch_exception_argument() async {
Source source = addSource('''
g() {}
f() async {
@@ -359,12 +361,12 @@
} catch (async) { }
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_catch_stacktrace_argument() {
+ test_async_used_as_identifier_in_catch_stacktrace_argument() async {
Source source = addSource('''
g() {}
f() async {
@@ -373,12 +375,12 @@
} catch (e, async) { }
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_continue_statement() {
+ test_async_used_as_identifier_in_continue_statement() async {
Source source = addSource('''
f() async {
while (true) {
@@ -386,7 +388,7 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
CompileTimeErrorCode.LABEL_UNDEFINED
@@ -395,31 +397,31 @@
// "async" label is unresolved.
}
- void test_async_used_as_identifier_in_for_statement() {
+ test_async_used_as_identifier_in_for_statement() async {
Source source = addSource('''
var async;
f() async {
for (async in []) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_formal_parameter_name() {
+ test_async_used_as_identifier_in_formal_parameter_name() async {
Source source = addSource('''
f() async {
g(int async) {}
g(0);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_getter_name() {
+ test_async_used_as_identifier_in_getter_name() async {
Source source = addSource('''
class C {
int get async => 1;
@@ -428,12 +430,12 @@
return new C().async;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_invocation() {
+ test_async_used_as_identifier_in_invocation() async {
Source source = addSource('''
class C {
int async() => 1;
@@ -442,35 +444,35 @@
return new C().async();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_local_function_name() {
+ test_async_used_as_identifier_in_local_function_name() async {
Source source = addSource('''
f() async {
int async() => null;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_prefix() {
+ test_async_used_as_identifier_in_prefix() async {
Source source = addSource('''
import 'dart:async' as async;
f() async {
return new async.Future.value(0);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_setter_name() {
+ test_async_used_as_identifier_in_setter_name() async {
Source source = addSource('''
class C {
void set async(int i) {}
@@ -479,36 +481,36 @@
new C().async = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_statement_label() {
+ test_async_used_as_identifier_in_statement_label() async {
Source source = addSource('''
f() async {
async: g();
}
g() {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_string_interpolation() {
+ test_async_used_as_identifier_in_string_interpolation() async {
Source source = addSource(r'''
int async = 1;
f() async {
return "$async";
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_suffix() {
+ test_async_used_as_identifier_in_suffix() async {
addNamedSource(
"/lib1.dart",
r'''
@@ -521,12 +523,12 @@
return l.async;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_switch_label() {
+ test_async_used_as_identifier_in_switch_label() async {
Source source = addSource('''
f() async {
switch (0) {
@@ -534,67 +536,67 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_async_used_as_identifier_in_sync_star_method() {
+ test_async_used_as_identifier_in_sync_star_method() async {
Source source = addSource('''
f() sync* {
var async = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_asyncForInWrongContext() {
+ test_asyncForInWrongContext() async {
Source source = addSource(r'''
f(list) {
await for (var e in list) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT]);
verify([source]);
}
- void test_await_used_as_identifier_in_async_method() {
+ test_await_used_as_identifier_in_async_method() async {
Source source = addSource('''
f() async {
var await = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_await_used_as_identifier_in_async_star_method() {
+ test_await_used_as_identifier_in_async_star_method() async {
Source source = addSource('''
f() async* {
var await = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_await_used_as_identifier_in_sync_star_method() {
+ test_await_used_as_identifier_in_sync_star_method() async {
Source source = addSource('''
f() sync* {
var await = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_bug_23176() {
+ test_bug_23176() async {
Source source = addSource('''
class A {
const A([x]);
@@ -603,7 +605,7 @@
dynamic @A(const A()) x;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.EXPECTED_CLASS_MEMBER,
ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
@@ -611,72 +613,72 @@
verify([source]);
}
- void test_builtInIdentifierAsMixinName_classTypeAlias() {
+ test_builtInIdentifierAsMixinName_classTypeAlias() async {
Source source = addSource(r'''
class A {}
class B {}
class as = A with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
verify([source]);
}
- void test_builtInIdentifierAsType_formalParameter_field() {
+ test_builtInIdentifierAsType_formalParameter_field() async {
Source source = addSource(r'''
class A {
var x;
A(static this.x);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
verify([source]);
}
- void test_builtInIdentifierAsType_formalParameter_simple() {
+ test_builtInIdentifierAsType_formalParameter_simple() async {
Source source = addSource(r'''
f(static x) {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
verify([source]);
}
- void test_builtInIdentifierAsType_variableDeclaration() {
+ test_builtInIdentifierAsType_variableDeclaration() async {
Source source = addSource(r'''
f() {
typedef x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
verify([source]);
}
- void test_builtInIdentifierAsTypedefName_functionTypeAlias() {
+ test_builtInIdentifierAsTypedefName_functionTypeAlias() async {
Source source = addSource("typedef bool as();");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
verify([source]);
}
- void test_builtInIdentifierAsTypeName() {
+ test_builtInIdentifierAsTypeName() async {
Source source = addSource("class as {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]);
verify([source]);
}
- void test_builtInIdentifierAsTypeParameterName() {
+ test_builtInIdentifierAsTypeParameterName() async {
Source source = addSource("class A<as> {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME]);
verify([source]);
}
- void test_caseExpressionTypeImplementsEquals() {
+ test_caseExpressionTypeImplementsEquals() async {
Source source = addSource(r'''
class IntWrapper {
final int value;
@@ -693,37 +695,37 @@
default: return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
- void test_conflictingConstructorNameAndMember_field() {
+ test_conflictingConstructorNameAndMember_field() async {
Source source = addSource(r'''
class A {
int x;
A.x() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]);
verify([source]);
}
- void test_conflictingConstructorNameAndMember_method() {
+ test_conflictingConstructorNameAndMember_method() async {
Source source = addSource(r'''
class A {
const A.x();
void x() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]);
verify([source]);
}
- void test_conflictingGetterAndMethod_field_method() {
+ test_conflictingGetterAndMethod_field_method() async {
Source source = addSource(r'''
class A {
final int m = 0;
@@ -731,12 +733,12 @@
class B extends A {
m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
verify([source]);
}
- void test_conflictingGetterAndMethod_getter_method() {
+ test_conflictingGetterAndMethod_getter_method() async {
Source source = addSource(r'''
class A {
get m => 0;
@@ -744,12 +746,12 @@
class B extends A {
m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
verify([source]);
}
- void test_conflictingGetterAndMethod_method_field() {
+ test_conflictingGetterAndMethod_method_field() async {
Source source = addSource(r'''
class A {
m() {}
@@ -757,12 +759,12 @@
class B extends A {
int m;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
verify([source]);
}
- void test_conflictingGetterAndMethod_method_getter() {
+ test_conflictingGetterAndMethod_method_getter() async {
Source source = addSource(r'''
class A {
m() {}
@@ -770,77 +772,77 @@
class B extends A {
get m => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
verify([source]);
}
- void test_conflictingTypeVariableAndClass() {
+ test_conflictingTypeVariableAndClass() async {
Source source = addSource(r'''
class T<T> {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLASS]);
verify([source]);
}
- void test_conflictingTypeVariableAndMember_field() {
+ test_conflictingTypeVariableAndMember_field() async {
Source source = addSource(r'''
class A<T> {
var T;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
verify([source]);
}
- void test_conflictingTypeVariableAndMember_getter() {
+ test_conflictingTypeVariableAndMember_getter() async {
Source source = addSource(r'''
class A<T> {
get T => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
verify([source]);
}
- void test_conflictingTypeVariableAndMember_method() {
+ test_conflictingTypeVariableAndMember_method() async {
Source source = addSource(r'''
class A<T> {
T() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
verify([source]);
}
- void test_conflictingTypeVariableAndMember_method_static() {
+ test_conflictingTypeVariableAndMember_method_static() async {
Source source = addSource(r'''
class A<T> {
static T() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
verify([source]);
}
- void test_conflictingTypeVariableAndMember_setter() {
+ test_conflictingTypeVariableAndMember_setter() async {
Source source = addSource(r'''
class A<T> {
set T(x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER]);
verify([source]);
}
- void test_consistentCaseExpressionTypes_dynamic() {
+ test_consistentCaseExpressionTypes_dynamic() async {
// Even though A.S and S have a static type of "dynamic", we should see
// that they match 'abc', because they are constant strings.
Source source = addSource(r'''
@@ -860,12 +862,12 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constConstructorWithFieldInitializedByNonConst() {
+ test_constConstructorWithFieldInitializedByNonConst() async {
Source source = addSource(r'''
class A {
final int i = f();
@@ -874,9 +876,9 @@
int f() {
return 3;
}''');
- computeLibrarySourceErrors(source);
// TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is
// redundant and ought to be suppressed.
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode
.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
@@ -885,7 +887,7 @@
verify([source]);
}
- void test_constConstructorWithFieldInitializedByNonConst_static() {
+ test_constConstructorWithFieldInitializedByNonConst_static() async {
Source source = addSource(r'''
class A {
static final int i = f();
@@ -894,24 +896,24 @@
int f() {
return 3;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constConstructorWithMixin() {
+ test_constConstructorWithMixin() async {
Source source = addSource(r'''
class M {
}
class A extends Object with M {
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]);
verify([source]);
}
- void test_constConstructorWithNonConstSuper_explicit() {
+ test_constConstructorWithNonConstSuper_explicit() async {
Source source = addSource(r'''
class A {
A();
@@ -919,13 +921,13 @@
class B extends A {
const B(): super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]);
verify([source]);
}
- void test_constConstructorWithNonConstSuper_implicit() {
+ test_constConstructorWithNonConstSuper_implicit() async {
Source source = addSource(r'''
class A {
A();
@@ -933,13 +935,13 @@
class B extends A {
const B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]);
verify([source]);
}
- void test_constConstructorWithNonFinalField_mixin() {
+ test_constConstructorWithNonFinalField_mixin() async {
Source source = addSource(r'''
class A {
var a;
@@ -947,7 +949,7 @@
class B extends Object with A {
const B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN,
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
@@ -955,7 +957,7 @@
verify([source]);
}
- void test_constConstructorWithNonFinalField_super() {
+ test_constConstructorWithNonFinalField_super() async {
Source source = addSource(r'''
class A {
var a;
@@ -963,7 +965,7 @@
class B extends A {
const B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD,
CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
@@ -971,20 +973,20 @@
verify([source]);
}
- void test_constConstructorWithNonFinalField_this() {
+ test_constConstructorWithNonFinalField_this() async {
Source source = addSource(r'''
class A {
int x;
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
verify([source]);
}
- void test_constDeferredClass() {
- resolveWithErrors(<String>[
+ test_constDeferredClass() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {
@@ -1001,8 +1003,8 @@
]);
}
- void test_constDeferredClass_namedConstructor() {
- resolveWithErrors(<String>[
+ test_constDeferredClass_namedConstructor() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {
@@ -1019,19 +1021,19 @@
]);
}
- void test_constEval_newInstance_constConstructor() {
+ test_constEval_newInstance_constConstructor() async {
Source source = addSource(r'''
class A {
const A();
}
const a = new A();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
verify([source]);
}
- void test_constEval_newInstance_externalFactoryConstConstructor() {
+ test_constEval_newInstance_externalFactoryConstConstructor() async {
// We can't evaluate "const A()" because its constructor is external. But
// the code is correct--we shouldn't report an error.
Source source = addSource(r'''
@@ -1039,12 +1041,12 @@
external factory const A();
}
const x = const A();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constEval_nonStaticField_inGenericClass() {
+ test_constEval_nonStaticField_inGenericClass() async {
Source source = addSource('''
class C<T> {
const C();
@@ -1052,13 +1054,13 @@
}
const x = const C().t;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
verify([source]);
}
- void test_constEval_propertyExtraction_targetNotConst() {
+ test_constEval_propertyExtraction_targetNotConst() async {
Source source = addSource(r'''
class A {
const A();
@@ -1066,30 +1068,30 @@
}
final a = const A();
const C = a.m;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
verify([source]);
}
- void test_constEvalThrowsException_binaryMinus_null() {
- _check_constEvalThrowsException_binary_null("null - 5", false);
- _check_constEvalThrowsException_binary_null("5 - null", true);
+ test_constEvalThrowsException_binaryMinus_null() async {
+ await _check_constEvalThrowsException_binary_null("null - 5", false);
+ await _check_constEvalThrowsException_binary_null("5 - null", true);
}
- void test_constEvalThrowsException_binaryPlus_null() {
- _check_constEvalThrowsException_binary_null("null + 5", false);
- _check_constEvalThrowsException_binary_null("5 + null", true);
+ test_constEvalThrowsException_binaryPlus_null() async {
+ await _check_constEvalThrowsException_binary_null("null + 5", false);
+ await _check_constEvalThrowsException_binary_null("5 + null", true);
}
- void test_constEvalThrowsException_divisionByZero() {
+ test_constEvalThrowsException_divisionByZero() async {
Source source = addSource("const C = 1 ~/ 0;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]);
verify([source]);
}
- void test_constEvalThrowsException_finalAlreadySet_initializer() {
+ test_constEvalThrowsException_finalAlreadySet_initializer() async {
// If a final variable has an initializer at the site of its declaration,
// and at the site of the constructor, then invoking that constructor would
// produce a runtime error; hence invoking that constructor via the "const"
@@ -1101,7 +1103,7 @@
}
var x = const C();
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION
@@ -1109,7 +1111,7 @@
verify([source]);
}
- void test_constEvalThrowsException_finalAlreadySet_initializing_formal() {
+ test_constEvalThrowsException_finalAlreadySet_initializing_formal() async {
// If a final variable has an initializer at the site of its declaration,
// and it is initialized using an initializing formal at the site of the
// constructor, then invoking that constructor would produce a runtime
@@ -1122,7 +1124,7 @@
}
var x = const C(2);
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
@@ -1130,35 +1132,35 @@
verify([source]);
}
- void test_constEvalThrowsException_unaryBitNot_null() {
+ test_constEvalThrowsException_unaryBitNot_null() async {
Source source = addSource("const C = ~null;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
// no verify(), '~null' is not resolved
}
- void test_constEvalThrowsException_unaryNegated_null() {
+ test_constEvalThrowsException_unaryNegated_null() async {
Source source = addSource("const C = -null;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
// no verify(), '-null' is not resolved
}
- void test_constEvalThrowsException_unaryNot_null() {
+ test_constEvalThrowsException_unaryNot_null() async {
Source source = addSource("const C = !null;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
verify([source]);
}
- void test_constEvalTypeBool_binary() {
- _check_constEvalTypeBool_withParameter_binary("p && ''");
- _check_constEvalTypeBool_withParameter_binary("p || ''");
+ test_constEvalTypeBool_binary() async {
+ await _check_constEvalTypeBool_withParameter_binary("p && ''");
+ await _check_constEvalTypeBool_withParameter_binary("p || ''");
}
- void test_constEvalTypeBool_binary_leftTrue() {
+ test_constEvalTypeBool_binary_leftTrue() async {
Source source = addSource("const C = (true || 0);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
StaticTypeWarningCode.NON_BOOL_OPERAND,
@@ -1167,7 +1169,7 @@
verify([source]);
}
- void test_constEvalTypeBoolNumString_equal() {
+ test_constEvalTypeBoolNumString_equal() async {
Source source = addSource(r'''
class A {
const A();
@@ -1176,13 +1178,13 @@
final a;
const B(num p) : a = p == const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
verify([source]);
}
- void test_constEvalTypeBoolNumString_notEqual() {
+ test_constEvalTypeBoolNumString_notEqual() async {
Source source = addSource(r'''
class A {
const A();
@@ -1191,63 +1193,63 @@
final a;
const B(String p) : a = p != const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
verify([source]);
}
- void test_constEvalTypeInt_binary() {
- _check_constEvalTypeInt_withParameter_binary("p ^ ''");
- _check_constEvalTypeInt_withParameter_binary("p & ''");
- _check_constEvalTypeInt_withParameter_binary("p | ''");
- _check_constEvalTypeInt_withParameter_binary("p >> ''");
- _check_constEvalTypeInt_withParameter_binary("p << ''");
+ test_constEvalTypeInt_binary() async {
+ await _check_constEvalTypeInt_withParameter_binary("p ^ ''");
+ await _check_constEvalTypeInt_withParameter_binary("p & ''");
+ await _check_constEvalTypeInt_withParameter_binary("p | ''");
+ await _check_constEvalTypeInt_withParameter_binary("p >> ''");
+ await _check_constEvalTypeInt_withParameter_binary("p << ''");
}
- void test_constEvalTypeNum_binary() {
- _check_constEvalTypeNum_withParameter_binary("p + ''");
- _check_constEvalTypeNum_withParameter_binary("p - ''");
- _check_constEvalTypeNum_withParameter_binary("p * ''");
- _check_constEvalTypeNum_withParameter_binary("p / ''");
- _check_constEvalTypeNum_withParameter_binary("p ~/ ''");
- _check_constEvalTypeNum_withParameter_binary("p > ''");
- _check_constEvalTypeNum_withParameter_binary("p < ''");
- _check_constEvalTypeNum_withParameter_binary("p >= ''");
- _check_constEvalTypeNum_withParameter_binary("p <= ''");
- _check_constEvalTypeNum_withParameter_binary("p % ''");
+ test_constEvalTypeNum_binary() async {
+ await _check_constEvalTypeNum_withParameter_binary("p + ''");
+ await _check_constEvalTypeNum_withParameter_binary("p - ''");
+ await _check_constEvalTypeNum_withParameter_binary("p * ''");
+ await _check_constEvalTypeNum_withParameter_binary("p / ''");
+ await _check_constEvalTypeNum_withParameter_binary("p ~/ ''");
+ await _check_constEvalTypeNum_withParameter_binary("p > ''");
+ await _check_constEvalTypeNum_withParameter_binary("p < ''");
+ await _check_constEvalTypeNum_withParameter_binary("p >= ''");
+ await _check_constEvalTypeNum_withParameter_binary("p <= ''");
+ await _check_constEvalTypeNum_withParameter_binary("p % ''");
}
- void test_constFormalParameter_fieldFormalParameter() {
+ test_constFormalParameter_fieldFormalParameter() async {
Source source = addSource(r'''
class A {
var x;
A(const this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
verify([source]);
}
- void test_constFormalParameter_simpleFormalParameter() {
+ test_constFormalParameter_simpleFormalParameter() async {
Source source = addSource("f(const x) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
verify([source]);
}
- void test_constInitializedWithNonConstValue() {
+ test_constInitializedWithNonConstValue() async {
Source source = addSource(r'''
f(p) {
const C = p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
verify([source]);
}
- void test_constInitializedWithNonConstValue_finalField() {
+ test_constInitializedWithNonConstValue_finalField() async {
// Regression test for bug #25526 which previously
// caused two errors to be reported.
Source source = addSource(r'''
@@ -1256,29 +1258,29 @@
foo([int x = field]) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
- void test_constInitializedWithNonConstValue_missingConstInListLiteral() {
+ test_constInitializedWithNonConstValue_missingConstInListLiteral() async {
Source source = addSource("const List L = [0];");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
verify([source]);
}
- void test_constInitializedWithNonConstValue_missingConstInMapLiteral() {
+ test_constInitializedWithNonConstValue_missingConstInMapLiteral() async {
Source source = addSource("const Map M = {'a' : 0};");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
verify([source]);
}
- void test_constInitializedWithNonConstValueFromDeferredClass() {
- resolveWithErrors(<String>[
+ test_constInitializedWithNonConstValueFromDeferredClass() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const V = 1;''',
@@ -1292,8 +1294,8 @@
]);
}
- void test_constInitializedWithNonConstValueFromDeferredClass_nested() {
- resolveWithErrors(<String>[
+ test_constInitializedWithNonConstValueFromDeferredClass_nested() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const V = 1;''',
@@ -1307,17 +1309,17 @@
]);
}
- void test_constInstanceField() {
+ test_constInstanceField() async {
Source source = addSource(r'''
class C {
const int f = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]);
verify([source]);
}
- void test_constMapKeyTypeImplementsEquals_direct() {
+ test_constMapKeyTypeImplementsEquals_direct() async {
Source source = addSource(r'''
class A {
const A();
@@ -1326,13 +1328,13 @@
main() {
const {const A() : 0};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
- void test_constMapKeyTypeImplementsEquals_dynamic() {
+ test_constMapKeyTypeImplementsEquals_dynamic() async {
// Note: static type of B.a is "dynamic", but actual type of the const
// object is A. We need to make sure we examine the actual type when
// deciding whether there is a problem with operator==.
@@ -1347,13 +1349,13 @@
main() {
const {B.a : 0};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
- void test_constMapKeyTypeImplementsEquals_factory() {
+ test_constMapKeyTypeImplementsEquals_factory() async {
Source source = addSource(r'''
class A { const factory A() = B; }
@@ -1366,13 +1368,13 @@
main() {
var m = const { const A(): 42 };
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
- void test_constMapKeyTypeImplementsEquals_super() {
+ test_constMapKeyTypeImplementsEquals_super() async {
Source source = addSource(r'''
class A {
const A();
@@ -1384,25 +1386,25 @@
main() {
const {const B() : 0};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
- void test_constWithInvalidTypeParameters() {
+ test_constWithInvalidTypeParameters() async {
Source source = addSource(r'''
class A {
const A();
}
f() { return const A<A>(); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
- void test_constWithInvalidTypeParameters_tooFew() {
+ test_constWithInvalidTypeParameters_tooFew() async {
Source source = addSource(r'''
class A {}
class C<K, V> {
@@ -1411,13 +1413,13 @@
f(p) {
return const C<A>();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
- void test_constWithInvalidTypeParameters_tooMany() {
+ test_constWithInvalidTypeParameters_tooMany() async {
Source source = addSource(r'''
class A {}
class C<E> {
@@ -1426,24 +1428,24 @@
f(p) {
return const C<A, A>();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
- void test_constWithNonConst() {
+ test_constWithNonConst() async {
Source source = addSource(r'''
class T {
T(a, b, {c, d}) {}
}
f() { return const T(0, 1, c: 2, d: 3); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]);
verify([source]);
}
- void test_constWithNonConst_with() {
+ test_constWithNonConst_with() async {
Source source = addSource(r'''
class B {
const B();
@@ -1455,12 +1457,12 @@
print(x);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]);
verify([source]);
}
- void test_constWithNonConstantArgument_annotation() {
+ test_constWithNonConstantArgument_annotation() async {
Source source = addSource(r'''
class A {
const A(int p);
@@ -1469,21 +1471,21 @@
@A(v)
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]);
verify([source]);
}
- void test_constWithNonConstantArgument_instanceCreation() {
+ test_constWithNonConstantArgument_instanceCreation() async {
Source source = addSource(r'''
class A {
const A(a);
}
f(p) { return const A(p); }''');
- computeLibrarySourceErrors(source);
// TODO(paulberry): the error INVALID_CONSTAT is redundant and ought to be
// suppressed.
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT,
CompileTimeErrorCode.INVALID_CONSTANT
@@ -1491,18 +1493,18 @@
verify([source]);
}
- void test_constWithNonType() {
+ test_constWithNonType() async {
Source source = addSource(r'''
int A;
f() {
return const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
verify([source]);
}
- void test_constWithNonType_fromLibrary() {
+ test_constWithNonType_fromLibrary() async {
Source source1 = addNamedSource("/lib.dart", "");
Source source2 = addNamedSource(
"/lib2.dart",
@@ -1511,19 +1513,19 @@
void f() {
const lib.A();
}''');
- computeLibrarySourceErrors(source1);
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source1);
+ await computeAnalysisResult(source2);
assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
verify([source1]);
}
- void test_constWithTypeParameters_direct() {
+ test_constWithTypeParameters_direct() async {
Source source = addSource(r'''
class A<T> {
static const V = const A<T>();
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC
@@ -1531,13 +1533,13 @@
verify([source]);
}
- void test_constWithTypeParameters_indirect() {
+ test_constWithTypeParameters_indirect() async {
Source source = addSource(r'''
class A<T> {
static const V = const A<List<T>>();
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC
@@ -1545,7 +1547,7 @@
verify([source]);
}
- void test_constWithUndefinedConstructor() {
+ test_constWithUndefinedConstructor() async {
Source source = addSource(r'''
class A {
const A();
@@ -1553,13 +1555,13 @@
f() {
return const A.noSuchConstructor();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
// no verify(), 'noSuchConstructor' is not resolved
}
- void test_constWithUndefinedConstructorDefault() {
+ test_constWithUndefinedConstructorDefault() async {
Source source = addSource(r'''
class A {
const A.name();
@@ -1567,37 +1569,37 @@
f() {
return const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]);
verify([source]);
}
- void test_defaultValueInFunctionTypeAlias() {
+ test_defaultValueInFunctionTypeAlias() async {
Source source = addSource("typedef F([x = 0]);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]);
verify([source]);
}
- void test_defaultValueInFunctionTypedParameter_named() {
+ test_defaultValueInFunctionTypedParameter_named() async {
Source source = addSource("f(g({p: null})) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER]);
verify([source]);
}
- void test_defaultValueInFunctionTypedParameter_optional() {
+ test_defaultValueInFunctionTypedParameter_optional() async {
Source source = addSource("f(g([p = null])) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER]);
verify([source]);
}
- void test_defaultValueInRedirectingFactoryConstructor() {
+ test_defaultValueInRedirectingFactoryConstructor() async {
Source source = addSource(r'''
class A {
factory A([int x = 0]) = B;
@@ -1606,20 +1608,20 @@
class B implements A {
B([int x = 1]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
]);
verify([source]);
}
- void test_duplicateConstructorName_named() {
+ test_duplicateConstructorName_named() async {
Source source = addSource(r'''
class A {
A.a() {}
A.a() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME,
CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME
@@ -1627,13 +1629,13 @@
verify([source]);
}
- void test_duplicateConstructorName_unnamed() {
+ test_duplicateConstructorName_unnamed() async {
Source source = addSource(r'''
class A {
A() {}
A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT,
CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT
@@ -1641,7 +1643,7 @@
verify([source]);
}
- void test_duplicateDefinition_acrossLibraries() {
+ test_duplicateDefinition_acrossLibraries() async {
Source librarySource = addNamedSource(
"/lib.dart",
r'''
@@ -1661,56 +1663,58 @@
part of lib;
class A {}''');
- computeLibrarySourceErrors(librarySource);
- assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
+ await computeAnalysisResult(librarySource);
+ await computeAnalysisResult(sourceA);
+ await computeAnalysisResult(sourceB);
assertNoErrors(librarySource);
+ assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([librarySource, sourceA, sourceB]);
}
- void test_duplicateDefinition_catch() {
+ test_duplicateDefinition_catch() async {
Source source = addSource(r'''
main() {
try {} catch (e, e) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_classMembers_fields() {
+ test_duplicateDefinition_classMembers_fields() async {
Source source = addSource(r'''
class A {
int a;
int a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_classMembers_fields_oneStatic() {
+ test_duplicateDefinition_classMembers_fields_oneStatic() async {
Source source = addSource(r'''
class A {
int x;
static int x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_classMembers_methods() {
+ test_duplicateDefinition_classMembers_methods() async {
Source source = addSource(r'''
class A {
m() {}
m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_inPart() {
+ test_duplicateDefinition_inPart() async {
Source librarySource = addNamedSource(
"/lib.dart",
r'''
@@ -1722,13 +1726,14 @@
r'''
part of test;
class A {}''');
- computeLibrarySourceErrors(librarySource);
- assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
+ await computeAnalysisResult(librarySource);
+ await computeAnalysisResult(sourceA);
assertNoErrors(librarySource);
+ assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([librarySource, sourceA]);
}
- void test_duplicateDefinition_locals_inCase() {
+ test_duplicateDefinition_locals_inCase() async {
Source source = addSource(r'''
main() {
switch(1) {
@@ -1737,23 +1742,23 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_locals_inFunctionBlock() {
+ test_duplicateDefinition_locals_inFunctionBlock() async {
Source source = addSource(r'''
main() {
int m = 0;
m(a) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_locals_inIf() {
+ test_duplicateDefinition_locals_inIf() async {
Source source = addSource(r'''
main(int p) {
if (p != 0) {
@@ -1761,12 +1766,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_locals_inMethodBlock() {
+ test_duplicateDefinition_locals_inMethodBlock() async {
Source source = addSource(r'''
class A {
m() {
@@ -1774,72 +1779,72 @@
int a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_parameters_inConstructor() {
+ test_duplicateDefinition_parameters_inConstructor() async {
Source source = addSource(r'''
class A {
int a;
A(int a, this.a);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_parameters_inFunctionTypeAlias() {
+ test_duplicateDefinition_parameters_inFunctionTypeAlias() async {
Source source = addSource(r'''
typedef F(int a, double a);
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_parameters_inLocalFunction() {
+ test_duplicateDefinition_parameters_inLocalFunction() async {
Source source = addSource(r'''
main() {
f(int a, double a) {
};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_parameters_inMethod() {
+ test_duplicateDefinition_parameters_inMethod() async {
Source source = addSource(r'''
class A {
m(int a, double a) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_parameters_inTopLevelFunction() {
+ test_duplicateDefinition_parameters_inTopLevelFunction() async {
Source source = addSource(r'''
f(int a, double a) {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinition_typeParameters() {
+ test_duplicateDefinition_typeParameters() async {
Source source = addSource(r'''
class A<T, T> {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
- void test_duplicateDefinitionInheritance_instanceGetter_staticGetter() {
+ test_duplicateDefinitionInheritance_instanceGetter_staticGetter() async {
Source source = addSource(r'''
class A {
int get x => 0;
@@ -1847,14 +1852,13 @@
class B extends A {
static int get x => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
verify([source]);
}
- void
- test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() {
+ test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() async {
Source source = addSource(r'''
abstract class A {
int get x;
@@ -1862,13 +1866,13 @@
class B extends A {
static int get x => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
verify([source]);
}
- void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() {
+ test_duplicateDefinitionInheritance_instanceMethod_staticMethod() async {
Source source = addSource(r'''
class A {
x() {}
@@ -1876,14 +1880,13 @@
class B extends A {
static x() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
verify([source]);
}
- void
- test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() {
+ test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() async {
Source source = addSource(r'''
abstract class A {
x();
@@ -1891,13 +1894,13 @@
abstract class B extends A {
static x() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
verify([source]);
}
- void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() {
+ test_duplicateDefinitionInheritance_instanceSetter_staticSetter() async {
Source source = addSource(r'''
class A {
set x(value) {}
@@ -1905,14 +1908,13 @@
class B extends A {
static set x(value) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
verify([source]);
}
- void
- test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() {
+ test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() async {
Source source = addSource(r'''
abstract class A {
set x(value);
@@ -1920,66 +1922,66 @@
class B extends A {
static set x(value) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
verify([source]);
}
- void test_duplicateNamedArgument() {
+ test_duplicateNamedArgument() async {
Source source = addSource(r'''
f({a, b}) {}
main() {
f(a: 1, a: 2);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
verify([source]);
}
- void test_duplicatePart_sameSource() {
+ test_duplicatePart_sameSource() async {
addNamedSource('/part.dart', 'part of lib;');
Source source = addSource(r'''
library lib;
part 'part.dart';
part 'foo/../part.dart';
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_PART]);
verify([source]);
}
- void test_duplicatePart_sameUri() {
+ test_duplicatePart_sameUri() async {
addNamedSource('/part.dart', 'part of lib;');
Source source = addSource(r'''
library lib;
part 'part.dart';
part 'part.dart';
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.DUPLICATE_PART]);
verify([source]);
}
- void test_exportInternalLibrary() {
+ test_exportInternalLibrary() async {
Source source = addSource("export 'dart:_interceptors';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]);
verify([source]);
}
- void test_exportOfNonLibrary() {
+ test_exportOfNonLibrary() async {
Source source = addSource(r'''
library L;
export 'lib1.dart';''');
addNamedSource("/lib1.dart", "part of lib;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
verify([source]);
}
- void test_extendsDeferredClass() {
- resolveWithErrors(<String>[
+ test_extendsDeferredClass() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -1992,8 +1994,8 @@
]);
}
- void test_extendsDeferredClass_classTypeAlias() {
- resolveWithErrors(<String>[
+ test_extendsDeferredClass_classTypeAlias() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -2007,9 +2009,9 @@
]);
}
- void test_extendsDisallowedClass_class_bool() {
+ test_extendsDisallowedClass_class_bool() async {
Source source = addSource("class A extends bool {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
@@ -2017,16 +2019,16 @@
verify([source]);
}
- void test_extendsDisallowedClass_class_double() {
+ test_extendsDisallowedClass_class_double() async {
Source source = addSource("class A extends double {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsDisallowedClass_class_int() {
+ test_extendsDisallowedClass_class_int() async {
Source source = addSource("class A extends int {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
@@ -2034,9 +2036,9 @@
verify([source]);
}
- void test_extendsDisallowedClass_class_Null() {
+ test_extendsDisallowedClass_class_Null() async {
Source source = addSource("class A extends Null {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
@@ -2044,16 +2046,16 @@
verify([source]);
}
- void test_extendsDisallowedClass_class_num() {
+ test_extendsDisallowedClass_class_num() async {
Source source = addSource("class A extends num {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsDisallowedClass_class_String() {
+ test_extendsDisallowedClass_class_String() async {
Source source = addSource("class A extends String {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
@@ -2061,86 +2063,86 @@
verify([source]);
}
- void test_extendsDisallowedClass_classTypeAlias_bool() {
+ test_extendsDisallowedClass_classTypeAlias_bool() async {
Source source = addSource(r'''
class M {}
class C = bool with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsDisallowedClass_classTypeAlias_double() {
+ test_extendsDisallowedClass_classTypeAlias_double() async {
Source source = addSource(r'''
class M {}
class C = double with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsDisallowedClass_classTypeAlias_int() {
+ test_extendsDisallowedClass_classTypeAlias_int() async {
Source source = addSource(r'''
class M {}
class C = int with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsDisallowedClass_classTypeAlias_Null() {
+ test_extendsDisallowedClass_classTypeAlias_Null() async {
Source source = addSource(r'''
class M {}
class C = Null with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsDisallowedClass_classTypeAlias_num() {
+ test_extendsDisallowedClass_classTypeAlias_num() async {
Source source = addSource(r'''
class M {}
class C = num with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsDisallowedClass_classTypeAlias_String() {
+ test_extendsDisallowedClass_classTypeAlias_String() async {
Source source = addSource(r'''
class M {}
class C = String with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_extendsEnum() {
+ test_extendsEnum() async {
Source source = addSource(r'''
enum E { ONE }
class A extends E {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_ENUM]);
verify([source]);
}
- void test_extendsNonClass_class() {
+ test_extendsNonClass_class() async {
Source source = addSource(r'''
int A;
class B extends A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]);
verify([source]);
}
- void test_extendsNonClass_dynamic() {
+ test_extendsNonClass_dynamic() async {
Source source = addSource("class B extends dynamic {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]);
verify([source]);
}
- void test_extraPositionalArguments_const() {
+ test_extraPositionalArguments_const() async {
Source source = addSource(r'''
class A {
const A();
@@ -2148,12 +2150,12 @@
main() {
const A(0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]);
verify([source]);
}
- void test_extraPositionalArguments_const_super() {
+ test_extraPositionalArguments_const_super() async {
Source source = addSource(r'''
class A {
const A();
@@ -2161,42 +2163,42 @@
class B extends A {
const B() : super(0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]);
verify([source]);
}
- void test_fieldFormalParameter_assignedInInitializer() {
+ test_fieldFormalParameter_assignedInInitializer() async {
Source source = addSource(r'''
class A {
int x;
A(this.x) : x = 3 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
verify([source]);
}
- void test_fieldInitializedByMultipleInitializers() {
+ test_fieldInitializedByMultipleInitializers() async {
Source source = addSource(r'''
class A {
int x;
A() : x = 0, x = 1 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
verify([source]);
}
- void test_fieldInitializedByMultipleInitializers_multipleInits() {
+ test_fieldInitializedByMultipleInitializers_multipleInits() async {
Source source = addSource(r'''
class A {
int x;
A() : x = 0, x = 1, x = 2 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS,
CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
@@ -2204,14 +2206,14 @@
verify([source]);
}
- void test_fieldInitializedByMultipleInitializers_multipleNames() {
+ test_fieldInitializedByMultipleInitializers_multipleNames() async {
Source source = addSource(r'''
class A {
int x;
int y;
A() : x = 0, x = 1, y = 0, y = 1 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS,
CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
@@ -2219,38 +2221,38 @@
verify([source]);
}
- void test_fieldInitializedInParameterAndInitializer() {
+ test_fieldInitializedInParameterAndInitializer() async {
Source source = addSource(r'''
class A {
int x;
A(this.x) : x = 1 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
verify([source]);
}
- void test_fieldInitializerFactoryConstructor() {
+ test_fieldInitializerFactoryConstructor() async {
Source source = addSource(r'''
class A {
int x;
factory A(this.x) => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR]);
verify([source]);
}
- void test_fieldInitializerOutsideConstructor() {
+ test_fieldInitializerOutsideConstructor() async {
// TODO(brianwilkerson) Fix the duplicate error messages.
Source source = addSource(r'''
class A {
int x;
m(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR,
CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
@@ -2258,76 +2260,76 @@
verify([source]);
}
- void test_fieldInitializerOutsideConstructor_defaultParameter() {
+ test_fieldInitializerOutsideConstructor_defaultParameter() async {
Source source = addSource(r'''
class A {
int x;
m([this.x]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
verify([source]);
}
- void test_fieldInitializerOutsideConstructor_inFunctionTypeParameter() {
+ test_fieldInitializerOutsideConstructor_inFunctionTypeParameter() async {
Source source = addSource(r'''
class A {
int x;
A(int p(this.x));
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
verify([source]);
}
- void test_fieldInitializerRedirectingConstructor_afterRedirection() {
+ test_fieldInitializerRedirectingConstructor_afterRedirection() async {
Source source = addSource(r'''
class A {
int x;
A.named() {}
A() : this.named(), x = 42;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]);
verify([source]);
}
- void test_fieldInitializerRedirectingConstructor_beforeRedirection() {
+ test_fieldInitializerRedirectingConstructor_beforeRedirection() async {
Source source = addSource(r'''
class A {
int x;
A.named() {}
A() : x = 42, this.named();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]);
verify([source]);
}
- void test_fieldInitializingFormalRedirectingConstructor() {
+ test_fieldInitializingFormalRedirectingConstructor() async {
Source source = addSource(r'''
class A {
int x;
A.named() {}
A(this.x) : this.named();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR]);
verify([source]);
}
- void test_finalInitializedMultipleTimes_initializers() {
+ test_finalInitializedMultipleTimes_initializers() async {
Source source = addSource(r'''
class A {
final x;
A() : x = 0, x = 0 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
verify([source]);
@@ -2341,26 +2343,26 @@
* Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of
* FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code
*/
- void test_finalInitializedMultipleTimes_initializingFormal_initializer() {
+ test_finalInitializedMultipleTimes_initializingFormal_initializer() async {
Source source = addSource(r'''
class A {
final x;
A(this.x) : x = 0 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
verify([source]);
}
- void test_finalInitializedMultipleTimes_initializingFormals() {
+ test_finalInitializedMultipleTimes_initializingFormals() async {
Source source = addSource(r'''
class A {
final x;
A(this.x, this.x) {}
}''');
- computeLibrarySourceErrors(source);
// TODO(brianwilkerson) There should only be one error here.
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.DUPLICATE_DEFINITION,
CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES
@@ -2368,38 +2370,38 @@
verify([source]);
}
- void test_finalNotInitialized_instanceField_const_static() {
+ test_finalNotInitialized_instanceField_const_static() async {
Source source = addSource(r'''
class A {
static const F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
verify([source]);
}
- void test_finalNotInitialized_library_const() {
+ test_finalNotInitialized_library_const() async {
Source source = addSource("const F;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
verify([source]);
}
- void test_finalNotInitialized_local_const() {
+ test_finalNotInitialized_local_const() async {
Source source = addSource(r'''
f() {
const int x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
verify([source]);
}
- void test_fromEnvironment_bool_badArgs() {
+ test_fromEnvironment_bool_badArgs() async {
Source source = addSource(r'''
var b1 = const bool.fromEnvironment(1);
var b2 = const bool.fromEnvironment('x', defaultValue: 1);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
@@ -2409,13 +2411,13 @@
verify([source]);
}
- void test_fromEnvironment_bool_badDefault_whenDefined() {
+ test_fromEnvironment_bool_badDefault_whenDefined() async {
// The type of the defaultValue needs to be correct even when the default
// value isn't used (because the variable is defined in the environment).
analysisContext2.declaredVariables.define("x", "true");
Source source =
addSource("var b = const bool.fromEnvironment('x', defaultValue: 1);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -2423,20 +2425,20 @@
verify([source]);
}
- void test_getterAndMethodWithSameName() {
+ test_getterAndMethodWithSameName() async {
Source source = addSource(r'''
class A {
x(y) {}
get x => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]);
verify([source]);
}
- void test_implementsDeferredClass() {
- resolveWithErrors(<String>[
+ test_implementsDeferredClass() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -2449,8 +2451,8 @@
]);
}
- void test_implementsDeferredClass_classTypeAlias() {
- resolveWithErrors(<String>[
+ test_implementsDeferredClass_classTypeAlias() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -2465,51 +2467,51 @@
]);
}
- void test_implementsDisallowedClass_class_bool() {
+ test_implementsDisallowedClass_class_bool() async {
Source source = addSource("class A implements bool {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_class_double() {
+ test_implementsDisallowedClass_class_double() async {
Source source = addSource("class A implements double {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_class_int() {
+ test_implementsDisallowedClass_class_int() async {
Source source = addSource("class A implements int {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_class_Null() {
+ test_implementsDisallowedClass_class_Null() async {
Source source = addSource("class A implements Null {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_class_num() {
+ test_implementsDisallowedClass_class_num() async {
Source source = addSource("class A implements num {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_class_String() {
+ test_implementsDisallowedClass_class_String() async {
Source source = addSource("class A implements String {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_class_String_num() {
+ test_implementsDisallowedClass_class_String_num() async {
Source source = addSource("class A implements String, num {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS,
CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS
@@ -2517,72 +2519,72 @@
verify([source]);
}
- void test_implementsDisallowedClass_classTypeAlias_bool() {
+ test_implementsDisallowedClass_classTypeAlias_bool() async {
Source source = addSource(r'''
class A {}
class M {}
class C = A with M implements bool;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_classTypeAlias_double() {
+ test_implementsDisallowedClass_classTypeAlias_double() async {
Source source = addSource(r'''
class A {}
class M {}
class C = A with M implements double;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_classTypeAlias_int() {
+ test_implementsDisallowedClass_classTypeAlias_int() async {
Source source = addSource(r'''
class A {}
class M {}
class C = A with M implements int;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_classTypeAlias_Null() {
+ test_implementsDisallowedClass_classTypeAlias_Null() async {
Source source = addSource(r'''
class A {}
class M {}
class C = A with M implements Null;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_classTypeAlias_num() {
+ test_implementsDisallowedClass_classTypeAlias_num() async {
Source source = addSource(r'''
class A {}
class M {}
class C = A with M implements num;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_classTypeAlias_String() {
+ test_implementsDisallowedClass_classTypeAlias_String() async {
Source source = addSource(r'''
class A {}
class M {}
class C = A with M implements String;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
- void test_implementsDisallowedClass_classTypeAlias_String_num() {
+ test_implementsDisallowedClass_classTypeAlias_String_num() async {
Source source = addSource(r'''
class A {}
class M {}
class C = A with M implements String, num;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS,
CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS
@@ -2590,56 +2592,56 @@
verify([source]);
}
- void test_implementsDynamic() {
+ test_implementsDynamic() async {
Source source = addSource("class A implements dynamic {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]);
verify([source]);
}
- void test_implementsEnum() {
+ test_implementsEnum() async {
Source source = addSource(r'''
enum E { ONE }
class A implements E {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_ENUM]);
verify([source]);
}
- void test_implementsNonClass_class() {
+ test_implementsNonClass_class() async {
Source source = addSource(r'''
int A;
class B implements A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
verify([source]);
}
- void test_implementsNonClass_typeAlias() {
+ test_implementsNonClass_typeAlias() async {
Source source = addSource(r'''
class A {}
class M {}
int B;
class C = A with M implements B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
verify([source]);
}
- void test_implementsRepeated() {
+ test_implementsRepeated() async {
Source source = addSource(r'''
class A {}
class B implements A, A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
verify([source]);
}
- void test_implementsRepeated_3times() {
+ test_implementsRepeated_3times() async {
Source source = addSource(r'''
class A {} class C{}
class B implements A, A, A, A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.IMPLEMENTS_REPEATED,
CompileTimeErrorCode.IMPLEMENTS_REPEATED,
@@ -2648,87 +2650,86 @@
verify([source]);
}
- void test_implementsSuperClass() {
+ test_implementsSuperClass() async {
Source source = addSource(r'''
class A {}
class B extends A implements A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
verify([source]);
}
- void test_implementsSuperClass_Object() {
+ test_implementsSuperClass_Object() async {
Source source = addSource("class A implements Object {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_field() {
+ test_implicitThisReferenceInInitializer_field() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f;
var f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_field2() {
+ test_implicitThisReferenceInInitializer_field2() async {
Source source = addSource(r'''
class A {
final x = 0;
final y = x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_invocation() {
+ test_implicitThisReferenceInInitializer_invocation() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f();
f() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_invocationInStatic() {
+ test_implicitThisReferenceInInitializer_invocationInStatic() async {
Source source = addSource(r'''
class A {
static var F = m();
m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
verify([source]);
}
- void
- test_implicitThisReferenceInInitializer_redirectingConstructorInvocation() {
+ test_implicitThisReferenceInInitializer_redirectingConstructorInvocation() async {
Source source = addSource(r'''
class A {
A(p) {}
A.named() : this(f);
var f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_superConstructorInvocation() {
+ test_implicitThisReferenceInInitializer_superConstructorInvocation() async {
Source source = addSource(r'''
class A {
A(p) {}
@@ -2737,39 +2738,39 @@
B() : super(f);
var f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
verify([source]);
}
- void test_importInternalLibrary() {
+ test_importInternalLibrary() async {
Source source = addSource("import 'dart:_interceptors';");
- computeLibrarySourceErrors(source);
// Note, in these error cases we may generate an UNUSED_IMPORT hint, while
// we could prevent the hint from being generated by testing the import
// directive for the error, this is such a minor corner case that we don't
// think we should add the additional computation time to figure out such
// cases.
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]);
verify([source]);
}
- void test_importInternalLibrary_js_helper() {
+ test_importInternalLibrary_js_helper() async {
Source source = addSource("import 'dart:_js_helper';");
- computeLibrarySourceErrors(source);
// Note, in these error cases we may generate an UNUSED_IMPORT hint, while
// we could prevent the hint from being generated by testing the import
// directive for the error, this is such a minor corner case that we don't
// think we should add the additional computation time to figure out such
// cases.
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]);
verify([source]);
}
- void test_importOfNonLibrary() {
+ test_importOfNonLibrary() async {
Source source = addSource(r'''
library lib;
import 'part.dart';
@@ -2779,12 +2780,12 @@
r'''
part of lib;
class A{}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]);
verify([source]);
}
- void test_inconsistentCaseExpressionTypes() {
+ test_inconsistentCaseExpressionTypes() async {
Source source = addSource(r'''
f(var p) {
switch (p) {
@@ -2794,13 +2795,13 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
verify([source]);
}
- void test_inconsistentCaseExpressionTypes_dynamic() {
+ test_inconsistentCaseExpressionTypes_dynamic() async {
// Even though A.S and S have a static type of "dynamic", we should see
// that they fail to match 3, because they are constant strings.
Source source = addSource(r'''
@@ -2820,7 +2821,7 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES
@@ -2828,7 +2829,7 @@
verify([source]);
}
- void test_inconsistentCaseExpressionTypes_repeated() {
+ test_inconsistentCaseExpressionTypes_repeated() async {
Source source = addSource(r'''
f(var p) {
switch (p) {
@@ -2840,7 +2841,7 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES
@@ -2848,7 +2849,7 @@
verify([source]);
}
- void test_initializerForNonExistent_const() {
+ test_initializerForNonExistent_const() async {
// Check that the absence of a matching field doesn't cause a
// crash during constant evaluation.
Source source = addSource(r'''
@@ -2856,44 +2857,44 @@
const A() : x = 'foo';
}
A a = const A();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD]);
}
- void test_initializerForNonExistent_initializer() {
+ test_initializerForNonExistent_initializer() async {
Source source = addSource(r'''
class A {
A() : x = 0 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD]);
}
- void test_initializerForStaticField() {
+ test_initializerForStaticField() async {
Source source = addSource(r'''
class A {
static int x;
A() : x = 0 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]);
verify([source]);
}
- void test_initializingFormalForNonExistentField() {
+ test_initializingFormalForNonExistentField() async {
Source source = addSource(r'''
class A {
A(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
verify([source]);
}
- void test_initializingFormalForNonExistentField_notInEnclosingClass() {
+ test_initializingFormalForNonExistentField_notInEnclosingClass() async {
Source source = addSource(r'''
class A {
int x;
@@ -2901,48 +2902,48 @@
class B extends A {
B(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
verify([source]);
}
- void test_initializingFormalForNonExistentField_optional() {
+ test_initializingFormalForNonExistentField_optional() async {
Source source = addSource(r'''
class A {
A([this.x]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
verify([source]);
}
- void test_initializingFormalForNonExistentField_synthetic() {
+ test_initializingFormalForNonExistentField_synthetic() async {
Source source = addSource(r'''
class A {
int get x => 1;
A(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD]);
verify([source]);
}
- void test_initializingFormalForStaticField() {
+ test_initializingFormalForStaticField() async {
Source source = addSource(r'''
class A {
static int x;
A([this.x]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]);
verify([source]);
}
- void test_instanceMemberAccessFromFactory_named() {
+ test_instanceMemberAccessFromFactory_named() async {
Source source = addSource(r'''
class A {
m() {}
@@ -2952,13 +2953,13 @@
return new A();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY]);
verify([source]);
}
- void test_instanceMemberAccessFromFactory_unnamed() {
+ test_instanceMemberAccessFromFactory_unnamed() async {
Source source = addSource(r'''
class A {
m() {}
@@ -2968,13 +2969,13 @@
return new A._();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY]);
verify([source]);
}
- void test_instanceMemberAccessFromStatic_field() {
+ test_instanceMemberAccessFromStatic_field() async {
Source source = addSource(r'''
class A {
int f;
@@ -2982,13 +2983,13 @@
f;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
verify([source]);
}
- void test_instanceMemberAccessFromStatic_getter() {
+ test_instanceMemberAccessFromStatic_getter() async {
Source source = addSource(r'''
class A {
get g => null;
@@ -2996,13 +2997,13 @@
g;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
verify([source]);
}
- void test_instanceMemberAccessFromStatic_method() {
+ test_instanceMemberAccessFromStatic_method() async {
Source source = addSource(r'''
class A {
m() {}
@@ -3010,46 +3011,46 @@
m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
verify([source]);
}
- void test_instantiateEnum_const() {
+ test_instantiateEnum_const() async {
Source source = addSource(r'''
enum E { ONE }
E e(String name) {
return const E();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]);
verify([source]);
}
- void test_instantiateEnum_new() {
+ test_instantiateEnum_new() async {
Source source = addSource(r'''
enum E { ONE }
E e(String name) {
return new E();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]);
verify([source]);
}
- void test_invalidAnnotation_getter() {
+ test_invalidAnnotation_getter() async {
Source source = addSource(r'''
get V => 0;
@V
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
verify([source]);
}
- void test_invalidAnnotation_importWithPrefix_getter() {
+ test_invalidAnnotation_importWithPrefix_getter() async {
addNamedSource(
"/lib.dart",
r'''
@@ -3060,12 +3061,12 @@
@p.V
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
verify([source]);
}
- void test_invalidAnnotation_importWithPrefix_notConstantVariable() {
+ test_invalidAnnotation_importWithPrefix_notConstantVariable() async {
addNamedSource(
"/lib.dart",
r'''
@@ -3076,13 +3077,12 @@
@p.V
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
verify([source]);
}
- void
- test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() {
+ test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() async {
addNamedSource(
"/lib.dart",
r'''
@@ -3093,34 +3093,34 @@
@p.V
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
verify([source]);
}
- void test_invalidAnnotation_notConstantVariable() {
+ test_invalidAnnotation_notConstantVariable() async {
Source source = addSource(r'''
final V = 0;
@V
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
verify([source]);
}
- void test_invalidAnnotation_notVariableOrConstructorInvocation() {
+ test_invalidAnnotation_notVariableOrConstructorInvocation() async {
Source source = addSource(r'''
typedef V();
@V
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
verify([source]);
}
- void test_invalidAnnotation_staticMethodReference() {
+ test_invalidAnnotation_staticMethodReference() async {
Source source = addSource(r'''
class A {
static f() {}
@@ -3128,52 +3128,52 @@
@A.f
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
verify([source]);
}
- void test_invalidAnnotation_unresolved_identifier() {
+ test_invalidAnnotation_unresolved_identifier() async {
Source source = addSource(r'''
@unresolved
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
}
- void test_invalidAnnotation_unresolved_invocation() {
+ test_invalidAnnotation_unresolved_invocation() async {
Source source = addSource(r'''
@Unresolved()
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
}
- void test_invalidAnnotation_unresolved_prefixedIdentifier() {
+ test_invalidAnnotation_unresolved_prefixedIdentifier() async {
Source source = addSource(r'''
import 'dart:math' as p;
@p.unresolved
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
}
- void test_invalidAnnotation_useLibraryScope() {
+ test_invalidAnnotation_useLibraryScope() async {
Source source = addSource(r'''
@foo
class A {
static const foo = null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
}
- void test_invalidAnnotationFromDeferredLibrary() {
+ test_invalidAnnotationFromDeferredLibrary() async {
// See test_invalidAnnotation_notConstantVariable
- resolveWithErrors(<String>[
+ await resolveWithErrors(<String>[
r'''
library lib1;
class V { const V(); }
@@ -3187,9 +3187,9 @@
]);
}
- void test_invalidAnnotationFromDeferredLibrary_constructor() {
+ test_invalidAnnotationFromDeferredLibrary_constructor() async {
// See test_invalidAnnotation_notConstantVariable
- resolveWithErrors(<String>[
+ await resolveWithErrors(<String>[
r'''
library lib1;
class C { const C(); }''',
@@ -3202,9 +3202,9 @@
]);
}
- void test_invalidAnnotationFromDeferredLibrary_namedConstructor() {
+ test_invalidAnnotationFromDeferredLibrary_namedConstructor() async {
// See test_invalidAnnotation_notConstantVariable
- resolveWithErrors(<String>[
+ await resolveWithErrors(<String>[
r'''
library lib1;
class C { const C.name(); }''',
@@ -3217,186 +3217,186 @@
]);
}
- void test_invalidConstructorName_notEnclosingClassName_defined() {
+ test_invalidConstructorName_notEnclosingClassName_defined() async {
Source source = addSource(r'''
class A {
B() : super();
}
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
// no verify() call, "B" is not resolved
}
- void test_invalidConstructorName_notEnclosingClassName_undefined() {
+ test_invalidConstructorName_notEnclosingClassName_undefined() async {
Source source = addSource(r'''
class A {
B() : super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
// no verify() call, "B" is not resolved
}
- void test_invalidFactoryNameNotAClass_notClassName() {
+ test_invalidFactoryNameNotAClass_notClassName() async {
Source source = addSource(r'''
int B;
class A {
factory B() => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
verify([source]);
}
- void test_invalidFactoryNameNotAClass_notEnclosingClassName() {
+ test_invalidFactoryNameNotAClass_notEnclosingClassName() async {
Source source = addSource(r'''
class A {
factory B() => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
// no verify() call, "B" is not resolved
}
- void test_invalidModifierOnConstructor_async() {
+ test_invalidModifierOnConstructor_async() async {
Source source = addSource(r'''
class A {
A() async {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]);
verify([source]);
}
- void test_invalidModifierOnConstructor_asyncStar() {
+ test_invalidModifierOnConstructor_asyncStar() async {
Source source = addSource(r'''
class A {
A() async* {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]);
verify([source]);
}
- void test_invalidModifierOnConstructor_syncStar() {
+ test_invalidModifierOnConstructor_syncStar() async {
Source source = addSource(r'''
class A {
A() sync* {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR]);
verify([source]);
}
- void test_invalidModifierOnSetter_member_async() {
+ test_invalidModifierOnSetter_member_async() async {
Source source = addSource(r'''
class A {
set x(v) async {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
verify([source]);
}
- void test_invalidModifierOnSetter_member_asyncStar() {
+ test_invalidModifierOnSetter_member_asyncStar() async {
Source source = addSource(r'''
class A {
set x(v) async* {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
verify([source]);
}
- void test_invalidModifierOnSetter_member_syncStar() {
+ test_invalidModifierOnSetter_member_syncStar() async {
Source source = addSource(r'''
class A {
set x(v) sync* {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
verify([source]);
}
- void test_invalidModifierOnSetter_topLevel_async() {
+ test_invalidModifierOnSetter_topLevel_async() async {
Source source = addSource("set x(v) async {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
verify([source]);
}
- void test_invalidModifierOnSetter_topLevel_asyncStar() {
+ test_invalidModifierOnSetter_topLevel_asyncStar() async {
Source source = addSource("set x(v) async* {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
verify([source]);
}
- void test_invalidModifierOnSetter_topLevel_syncStar() {
+ test_invalidModifierOnSetter_topLevel_syncStar() async {
Source source = addSource("set x(v) sync* {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER]);
verify([source]);
}
- void test_invalidReferenceToThis_factoryConstructor() {
+ test_invalidReferenceToThis_factoryConstructor() async {
Source source = addSource(r'''
class A {
factory A() { return this; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() {
+ test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() async {
Source source = addSource(r'''
class A {
var f;
A() : f = this;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() {
+ test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() async {
Source source = addSource(r'''
class A {
var f = this;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidReferenceToThis_staticMethod() {
+ test_invalidReferenceToThis_staticMethod() async {
Source source = addSource(r'''
class A {
static m() { return this; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidReferenceToThis_staticVariableInitializer() {
+ test_invalidReferenceToThis_staticVariableInitializer() async {
Source source = addSource(r'''
class A {
static A f = this;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidReferenceToThis_superInitializer() {
+ test_invalidReferenceToThis_superInitializer() async {
Source source = addSource(r'''
class A {
A(var x) {}
@@ -3404,72 +3404,72 @@
class B extends A {
B() : super(this);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidReferenceToThis_topLevelFunction() {
+ test_invalidReferenceToThis_topLevelFunction() async {
Source source = addSource("f() { return this; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidReferenceToThis_variableInitializer() {
+ test_invalidReferenceToThis_variableInitializer() async {
Source source = addSource("int x = this;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void test_invalidTypeArgumentInConstList() {
+ test_invalidTypeArgumentInConstList() async {
Source source = addSource(r'''
class A<E> {
m() {
return const <E>[];
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]);
verify([source]);
}
- void test_invalidTypeArgumentInConstMap() {
+ test_invalidTypeArgumentInConstMap() async {
Source source = addSource(r'''
class A<E> {
m() {
return const <String, E>{};
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]);
verify([source]);
}
- void test_invalidUri_export() {
+ test_invalidUri_export() async {
Source source = addSource("export 'ht:';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
}
- void test_invalidUri_import() {
+ test_invalidUri_import() async {
Source source = addSource("import 'ht:';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
}
- void test_invalidUri_part() {
+ test_invalidUri_part() async {
Source source = addSource(r'''
library lib;
part 'ht:';''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
}
- void test_isInConstInstanceCreation_restored() {
+ test_isInConstInstanceCreation_restored() async {
// If ErrorVerifier._isInConstInstanceCreation is not properly restored on
// exit from visitInstanceCreationExpression, the error at (1) will be
// treated as a warning rather than an error.
@@ -3480,13 +3480,13 @@
const x = const Foo<int>(const Foo<int>(0, 1),
const <Foo<String>>[]); // (1)
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
verify([source]);
}
- void test_isInInstanceVariableInitializer_restored() {
+ test_isInInstanceVariableInitializer_restored() async {
// If ErrorVerifier._isInInstanceVariableInitializer is not properly
// restored on exit from visitVariableDeclaration, the error at (1)
// won't be detected.
@@ -3502,13 +3502,13 @@
_foo() {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
verify([source]);
}
- void test_labelInOuterScope() {
+ test_labelInOuterScope() async {
Source source = addSource(r'''
class A {
void m(int i) {
@@ -3519,40 +3519,40 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]);
// We cannot verify resolution with unresolvable labels
}
- void test_labelUndefined_break() {
+ test_labelUndefined_break() async {
Source source = addSource(r'''
f() {
x: while (true) {
break y;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]);
// We cannot verify resolution with undefined labels
}
- void test_labelUndefined_continue() {
+ test_labelUndefined_continue() async {
Source source = addSource(r'''
f() {
x: while (true) {
continue y;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]);
// We cannot verify resolution with undefined labels
}
- void test_length_of_erroneous_constant() {
+ test_length_of_erroneous_constant() async {
// Attempting to compute the length of constant that couldn't be evaluated
// (due to an error) should not crash the analyzer (see dartbug.com/23383)
Source source = addSource("const int i = (1 ? 'alpha' : 'beta').length;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE,
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
@@ -3561,76 +3561,76 @@
verify([source]);
}
- void test_memberWithClassName_field() {
+ test_memberWithClassName_field() async {
Source source = addSource(r'''
class A {
int A = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
verify([source]);
}
- void test_memberWithClassName_field2() {
+ test_memberWithClassName_field2() async {
Source source = addSource(r'''
class A {
int z, A, b = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
verify([source]);
}
- void test_memberWithClassName_getter() {
+ test_memberWithClassName_getter() async {
Source source = addSource(r'''
class A {
get A => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
verify([source]);
}
- void test_memberWithClassName_method() {
+ test_memberWithClassName_method() async {
// no test because indistinguishable from constructor
}
- void test_methodAndGetterWithSameName() {
+ test_methodAndGetterWithSameName() async {
Source source = addSource(r'''
class A {
get x => 0;
x(y) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]);
verify([source]);
}
- void test_mixinDeclaresConstructor_classDeclaration() {
+ test_mixinDeclaresConstructor_classDeclaration() async {
Source source = addSource(r'''
class A {
A() {}
}
class B extends Object with A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
verify([source]);
}
- void test_mixinDeclaresConstructor_typeAlias() {
+ test_mixinDeclaresConstructor_typeAlias() async {
Source source = addSource(r'''
class A {
A() {}
}
class B = Object with A;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
verify([source]);
}
- void test_mixinDeferredClass() {
- resolveWithErrors(<String>[
+ test_mixinDeferredClass() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3643,8 +3643,8 @@
]);
}
- void test_mixinDeferredClass_classTypeAlias() {
- resolveWithErrors(<String>[
+ test_mixinDeferredClass_classTypeAlias() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3658,7 +3658,7 @@
]);
}
- void test_mixinHasNoConstructors_mixinApp() {
+ test_mixinHasNoConstructors_mixinApp() async {
Source source = addSource(r'''
class B {
B({x});
@@ -3666,12 +3666,12 @@
class M {}
class C = B with M;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
verify([source]);
}
- void test_mixinHasNoConstructors_mixinClass() {
+ test_mixinHasNoConstructors_mixinClass() async {
Source source = addSource(r'''
class B {
B({x});
@@ -3683,12 +3683,12 @@
// generate a further error (despite the fact that it's not forwarded),
// since CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job
// of explaining the probem to the user.
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
verify([source]);
}
- void test_mixinHasNoConstructors_mixinClass_explicitSuperCall() {
+ test_mixinHasNoConstructors_mixinClass_explicitSuperCall() async {
Source source = addSource(r'''
class B {
B({x});
@@ -3702,12 +3702,12 @@
// error (despite the fact that it's not forwarded), since
// CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of
// explaining the error to the user.
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
verify([source]);
}
- void test_mixinHasNoConstructors_mixinClass_implicitSuperCall() {
+ test_mixinHasNoConstructors_mixinClass_implicitSuperCall() async {
Source source = addSource(r'''
class B {
B({x});
@@ -3721,12 +3721,12 @@
// error (despite the fact that it's not forwarded), since
// CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of
// explaining the error to the user.
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
verify([source]);
}
- void test_mixinHasNoConstructors_mixinClass_namedSuperCall() {
+ test_mixinHasNoConstructors_mixinClass_namedSuperCall() async {
Source source = addSource(r'''
class B {
B.named({x});
@@ -3740,152 +3740,152 @@
// further error (despite the fact that it's not forwarded), since
// CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS does a better job of
// explaining the error to the user.
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
verify([source]);
}
- void test_mixinInheritsFromNotObject_classDeclaration_extends() {
+ test_mixinInheritsFromNotObject_classDeclaration_extends() async {
Source source = addSource(r'''
class A {}
class B extends A {}
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
verify([source]);
}
- void test_mixinInheritsFromNotObject_classDeclaration_with() {
+ test_mixinInheritsFromNotObject_classDeclaration_with() async {
Source source = addSource(r'''
class A {}
class B extends Object with A {}
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
verify([source]);
}
- void test_mixinInheritsFromNotObject_typeAlias_extends() {
+ test_mixinInheritsFromNotObject_typeAlias_extends() async {
Source source = addSource(r'''
class A {}
class B extends A {}
class C = Object with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
verify([source]);
}
- void test_mixinInheritsFromNotObject_typeAlias_with() {
+ test_mixinInheritsFromNotObject_typeAlias_with() async {
Source source = addSource(r'''
class A {}
class B extends Object with A {}
class C = Object with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
verify([source]);
}
- void test_mixinOfDisallowedClass_class_bool() {
+ test_mixinOfDisallowedClass_class_bool() async {
Source source = addSource("class A extends Object with bool {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_class_double() {
+ test_mixinOfDisallowedClass_class_double() async {
Source source = addSource("class A extends Object with double {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_class_int() {
+ test_mixinOfDisallowedClass_class_int() async {
Source source = addSource("class A extends Object with int {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_class_Null() {
+ test_mixinOfDisallowedClass_class_Null() async {
Source source = addSource("class A extends Object with Null {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_class_num() {
+ test_mixinOfDisallowedClass_class_num() async {
Source source = addSource("class A extends Object with num {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_class_String() {
+ test_mixinOfDisallowedClass_class_String() async {
Source source = addSource("class A extends Object with String {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_classTypeAlias_bool() {
+ test_mixinOfDisallowedClass_classTypeAlias_bool() async {
Source source = addSource(r'''
class A {}
class C = A with bool;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_classTypeAlias_double() {
+ test_mixinOfDisallowedClass_classTypeAlias_double() async {
Source source = addSource(r'''
class A {}
class C = A with double;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_classTypeAlias_int() {
+ test_mixinOfDisallowedClass_classTypeAlias_int() async {
Source source = addSource(r'''
class A {}
class C = A with int;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_classTypeAlias_Null() {
+ test_mixinOfDisallowedClass_classTypeAlias_Null() async {
Source source = addSource(r'''
class A {}
class C = A with Null;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_classTypeAlias_num() {
+ test_mixinOfDisallowedClass_classTypeAlias_num() async {
Source source = addSource(r'''
class A {}
class C = A with num;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_classTypeAlias_String() {
+ test_mixinOfDisallowedClass_classTypeAlias_String() async {
Source source = addSource(r'''
class A {}
class C = A with String;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
verify([source]);
}
- void test_mixinOfDisallowedClass_classTypeAlias_String_num() {
+ test_mixinOfDisallowedClass_classTypeAlias_String_num() async {
Source source = addSource(r'''
class A {}
class C = A with String, num;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS,
CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS
@@ -3893,113 +3893,113 @@
verify([source]);
}
- void test_mixinOfEnum() {
+ test_mixinOfEnum() async {
Source source = addSource(r'''
enum E { ONE }
class A extends Object with E {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_ENUM]);
verify([source]);
}
- void test_mixinOfNonClass_class() {
+ test_mixinOfNonClass_class() async {
Source source = addSource(r'''
int A;
class B extends Object with A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
verify([source]);
}
- void test_mixinOfNonClass_typeAlias() {
+ test_mixinOfNonClass_typeAlias() async {
Source source = addSource(r'''
class A {}
int B;
class C = A with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
verify([source]);
}
- void test_mixinReferencesSuper() {
+ test_mixinReferencesSuper() async {
Source source = addSource(r'''
class A {
toString() => super.toString();
}
class B extends Object with A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]);
verify([source]);
}
- void test_mixinWithNonClassSuperclass_class() {
+ test_mixinWithNonClassSuperclass_class() async {
Source source = addSource(r'''
int A;
class B {}
class C extends A with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
verify([source]);
}
- void test_mixinWithNonClassSuperclass_typeAlias() {
+ test_mixinWithNonClassSuperclass_typeAlias() async {
Source source = addSource(r'''
int A;
class B {}
class C = A with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
verify([source]);
}
- void test_multipleRedirectingConstructorInvocations() {
+ test_multipleRedirectingConstructorInvocations() async {
Source source = addSource(r'''
class A {
A() : this.a(), this.b();
A.a() {}
A.b() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS]);
verify([source]);
}
- void test_multipleSuperInitializers() {
+ test_multipleSuperInitializers() async {
Source source = addSource(r'''
class A {}
class B extends A {
B() : super(), super() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]);
verify([source]);
}
- void test_nativeClauseInNonSDKCode() {
+ test_nativeClauseInNonSDKCode() async {
// TODO(jwren) Move this test somewhere else: This test verifies a parser
// error code is generated through the ErrorVerifier, it is not a
// CompileTimeErrorCode.
Source source = addSource("class A native 'string' {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
verify([source]);
}
- void test_nativeFunctionBodyInNonSDKCode_function() {
+ test_nativeFunctionBodyInNonSDKCode_function() async {
// TODO(jwren) Move this test somewhere else: This test verifies a parser
// error code is generated through the ErrorVerifier, it is not a
// CompileTimeErrorCode.
Source source = addSource("int m(a) native 'string';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
verify([source]);
}
- void test_nativeFunctionBodyInNonSDKCode_method() {
+ test_nativeFunctionBodyInNonSDKCode_method() async {
// TODO(jwren) Move this test somewhere else: This test verifies a parser
// error code is generated through the ErrorVerifier, it is not a
// CompileTimeErrorCode.
@@ -4007,13 +4007,13 @@
class A{
static int m(a) native 'string';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
verify([source]);
}
- void test_noAnnotationConstructorArguments() {
+ test_noAnnotationConstructorArguments() async {
Source source = addSource(r'''
class A {
const A();
@@ -4021,13 +4021,13 @@
@A
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS]);
verify([source]);
}
- void test_noDefaultSuperConstructorExplicit() {
+ test_noDefaultSuperConstructorExplicit() async {
Source source = addSource(r'''
class A {
A(p);
@@ -4035,13 +4035,13 @@
class B extends A {
B() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorExplicit_MixinAppWithDirectSuperCall() {
+ test_noDefaultSuperConstructorExplicit_MixinAppWithDirectSuperCall() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4053,13 +4053,13 @@
C(x) : super();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
verify([source]);
}
- void test_noDefaultSuperConstructorExplicit_mixinAppWithNamedParam() {
+ test_noDefaultSuperConstructorExplicit_mixinAppWithNamedParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4071,13 +4071,13 @@
C();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
verify([source]);
}
- void test_noDefaultSuperConstructorExplicit_MixinAppWithNamedSuperCall() {
+ test_noDefaultSuperConstructorExplicit_MixinAppWithNamedSuperCall() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4089,13 +4089,13 @@
C(x) : super.named();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
// Don't verify since call to super.named() can't be resolved.
}
- void test_noDefaultSuperConstructorExplicit_mixinAppWithOptionalParam() {
+ test_noDefaultSuperConstructorExplicit_mixinAppWithOptionalParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4107,13 +4107,13 @@
C();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
verify([source]);
}
- void test_noDefaultSuperConstructorExplicit_MixinWithDirectSuperCall() {
+ test_noDefaultSuperConstructorExplicit_MixinWithDirectSuperCall() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4124,13 +4124,13 @@
C(x) : super();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
verify([source]);
}
- void test_noDefaultSuperConstructorExplicit_mixinWithNamedParam() {
+ test_noDefaultSuperConstructorExplicit_mixinWithNamedParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4141,13 +4141,13 @@
C();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorExplicit_MixinWithNamedSuperCall() {
+ test_noDefaultSuperConstructorExplicit_MixinWithNamedSuperCall() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4158,13 +4158,13 @@
C(x) : super.named();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
// Don't verify since call to super.named() can't be resolved.
}
- void test_noDefaultSuperConstructorExplicit_mixinWithOptionalParam() {
+ test_noDefaultSuperConstructorExplicit_mixinWithOptionalParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4175,13 +4175,13 @@
C();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorImplicit_mixinAppWithNamedParam() {
+ test_noDefaultSuperConstructorImplicit_mixinAppWithNamedParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4191,13 +4191,13 @@
class Mixed = B with M;
class C extends Mixed {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorImplicit_mixinAppWithOptionalParam() {
+ test_noDefaultSuperConstructorImplicit_mixinAppWithOptionalParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4207,13 +4207,13 @@
class Mixed = B with M;
class C extends Mixed {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorImplicit_mixinWithNamedParam() {
+ test_noDefaultSuperConstructorImplicit_mixinWithNamedParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4222,13 +4222,13 @@
}
class C extends B with M {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorImplicit_mixinWithOptionalParam() {
+ test_noDefaultSuperConstructorImplicit_mixinWithOptionalParam() async {
Source source = addSource(r'''
class M {}
class B {
@@ -4237,36 +4237,36 @@
}
class C extends B with M {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorImplicit_superHasParameters() {
+ test_noDefaultSuperConstructorImplicit_superHasParameters() async {
Source source = addSource(r'''
class A {
A(p);
}
class B extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
verify([source]);
}
- void test_noDefaultSuperConstructorImplicit_superOnlyNamed() {
+ test_noDefaultSuperConstructorImplicit_superOnlyNamed() async {
Source source = addSource(r'''
class A { A.named() {} }
class B extends A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
verify([source]);
}
- void test_nonConstantAnnotationConstructor_named() {
+ test_nonConstantAnnotationConstructor_named() async {
Source source = addSource(r'''
class A {
A.fromInt() {}
@@ -4274,13 +4274,13 @@
@A.fromInt()
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]);
verify([source]);
}
- void test_nonConstantAnnotationConstructor_unnamed() {
+ test_nonConstantAnnotationConstructor_unnamed() async {
Source source = addSource(r'''
class A {
A() {}
@@ -4288,76 +4288,76 @@
@A()
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]);
verify([source]);
}
- void test_nonConstantDefaultValue_function_named() {
+ test_nonConstantDefaultValue_function_named() async {
Source source = addSource(r'''
int y;
f({x : y}) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
- void test_nonConstantDefaultValue_function_positional() {
+ test_nonConstantDefaultValue_function_positional() async {
Source source = addSource(r'''
int y;
f([x = y]) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
- void test_nonConstantDefaultValue_inConstructor_named() {
+ test_nonConstantDefaultValue_inConstructor_named() async {
Source source = addSource(r'''
class A {
int y;
A({x : y}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
- void test_nonConstantDefaultValue_inConstructor_positional() {
+ test_nonConstantDefaultValue_inConstructor_positional() async {
Source source = addSource(r'''
class A {
int y;
A([x = y]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
- void test_nonConstantDefaultValue_method_named() {
+ test_nonConstantDefaultValue_method_named() async {
Source source = addSource(r'''
class A {
int y;
m({x : y}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
- void test_nonConstantDefaultValue_method_positional() {
+ test_nonConstantDefaultValue_method_positional() async {
Source source = addSource(r'''
class A {
int y;
m([x = y]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
- void test_nonConstantDefaultValueFromDeferredLibrary() {
- resolveWithErrors(<String>[
+ test_nonConstantDefaultValueFromDeferredLibrary() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const V = 1;''',
@@ -4370,8 +4370,8 @@
]);
}
- void test_nonConstantDefaultValueFromDeferredLibrary_nested() {
- resolveWithErrors(<String>[
+ test_nonConstantDefaultValueFromDeferredLibrary_nested() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const V = 1;''',
@@ -4384,7 +4384,7 @@
]);
}
- void test_nonConstCaseExpression() {
+ test_nonConstCaseExpression() async {
Source source = addSource(r'''
f(int p, int q) {
switch (p) {
@@ -4392,13 +4392,13 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]);
verify([source]);
}
- void test_nonConstCaseExpressionFromDeferredLibrary() {
- resolveWithErrors(<String>[
+ test_nonConstCaseExpressionFromDeferredLibrary() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4416,8 +4416,8 @@
]);
}
- void test_nonConstCaseExpressionFromDeferredLibrary_nested() {
- resolveWithErrors(<String>[
+ test_nonConstCaseExpressionFromDeferredLibrary_nested() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4435,18 +4435,18 @@
]);
}
- void test_nonConstListElement() {
+ test_nonConstListElement() async {
Source source = addSource(r'''
f(a) {
return const [a];
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
verify([source]);
}
- void test_nonConstListElementFromDeferredLibrary() {
- resolveWithErrors(<String>[
+ test_nonConstListElementFromDeferredLibrary() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4461,8 +4461,8 @@
]);
}
- void test_nonConstListElementFromDeferredLibrary_nested() {
- resolveWithErrors(<String>[
+ test_nonConstListElementFromDeferredLibrary_nested() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4477,40 +4477,40 @@
]);
}
- void test_nonConstMapAsExpressionStatement_begin() {
+ test_nonConstMapAsExpressionStatement_begin() async {
Source source = addSource(r'''
f() {
{'a' : 0, 'b' : 1}.length;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
verify([source]);
}
- void test_nonConstMapAsExpressionStatement_only() {
+ test_nonConstMapAsExpressionStatement_only() async {
Source source = addSource(r'''
f() {
{'a' : 0, 'b' : 1};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
verify([source]);
}
- void test_nonConstMapKey() {
+ test_nonConstMapKey() async {
Source source = addSource(r'''
f(a) {
return const {a : 0};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
verify([source]);
}
- void test_nonConstMapKeyFromDeferredLibrary() {
- resolveWithErrors(<String>[
+ test_nonConstMapKeyFromDeferredLibrary() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4525,8 +4525,8 @@
]);
}
- void test_nonConstMapKeyFromDeferredLibrary_nested() {
- resolveWithErrors(<String>[
+ test_nonConstMapKeyFromDeferredLibrary_nested() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4541,18 +4541,18 @@
]);
}
- void test_nonConstMapValue() {
+ test_nonConstMapValue() async {
Source source = addSource(r'''
f(a) {
return const {'a' : a};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
verify([source]);
}
- void test_nonConstMapValueFromDeferredLibrary() {
- resolveWithErrors(<String>[
+ test_nonConstMapValueFromDeferredLibrary() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4567,8 +4567,8 @@
]);
}
- void test_nonConstMapValueFromDeferredLibrary_nested() {
- resolveWithErrors(<String>[
+ test_nonConstMapValueFromDeferredLibrary_nested() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4583,37 +4583,39 @@
]);
}
- void test_nonConstValueInInitializer_assert_condition() {
- resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true);
+ test_nonConstValueInInitializer_assert_condition() async {
+ resetWith(
+ options: new AnalysisOptionsImpl()..enableAssertInitializer = true);
Source source = addSource(r'''
class A {
const A(int i) : assert(i.isNegative);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
verify([source]);
}
- void test_nonConstValueInInitializer_assert_message() {
- resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true);
+ test_nonConstValueInInitializer_assert_message() async {
+ resetWith(
+ options: new AnalysisOptionsImpl()..enableAssertInitializer = true);
Source source = addSource(r'''
class A {
const A(int i) : assert(i < 0, 'isNegative = ${i.isNegative}');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
verify([source]);
}
- void test_nonConstValueInInitializer_binary_notBool_left() {
+ test_nonConstValueInInitializer_binary_notBool_left() async {
Source source = addSource(r'''
class A {
final bool a;
const A(String p) : a = p && true;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
StaticTypeWarningCode.NON_BOOL_OPERAND
@@ -4621,13 +4623,13 @@
verify([source]);
}
- void test_nonConstValueInInitializer_binary_notBool_right() {
+ test_nonConstValueInInitializer_binary_notBool_right() async {
Source source = addSource(r'''
class A {
final bool a;
const A(String p) : a = true && p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
StaticTypeWarningCode.NON_BOOL_OPERAND
@@ -4635,13 +4637,13 @@
verify([source]);
}
- void test_nonConstValueInInitializer_binary_notInt() {
+ test_nonConstValueInInitializer_binary_notInt() async {
Source source = addSource(r'''
class A {
final int a;
const A(String p) : a = 5 & p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_INT,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -4649,13 +4651,13 @@
verify([source]);
}
- void test_nonConstValueInInitializer_binary_notNum() {
+ test_nonConstValueInInitializer_binary_notNum() async {
Source source = addSource(r'''
class A {
final int a;
const A(String p) : a = 5 + p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_NUM,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -4663,20 +4665,20 @@
verify([source]);
}
- void test_nonConstValueInInitializer_field() {
+ test_nonConstValueInInitializer_field() async {
Source source = addSource(r'''
class A {
static int C;
final int a;
const A() : a = C;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
verify([source]);
}
- void test_nonConstValueInInitializer_instanceCreation() {
+ test_nonConstValueInInitializer_instanceCreation() async {
Source source = addSource(r'''
class A {
A();
@@ -4686,9 +4688,9 @@
final a;
}
var b = const B();''');
- computeLibrarySourceErrors(source);
// TODO(paulberry): the error INVALID_CONSTAT is redundant and ought to be
// suppressed.
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER,
CompileTimeErrorCode.INVALID_CONSTANT
@@ -4696,20 +4698,20 @@
verify([source]);
}
- void test_nonConstValueInInitializer_redirecting() {
+ test_nonConstValueInInitializer_redirecting() async {
Source source = addSource(r'''
class A {
static var C;
const A.named(p);
const A() : this.named(C);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
verify([source]);
}
- void test_nonConstValueInInitializer_super() {
+ test_nonConstValueInInitializer_super() async {
Source source = addSource(r'''
class A {
const A(p);
@@ -4718,14 +4720,14 @@
static var C;
const B() : super(C);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
verify([source]);
}
- void test_nonConstValueInInitializerFromDeferredLibrary_field() {
- resolveWithErrors(<String>[
+ test_nonConstValueInInitializerFromDeferredLibrary_field() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4742,8 +4744,8 @@
]);
}
- void test_nonConstValueInInitializerFromDeferredLibrary_field_nested() {
- resolveWithErrors(<String>[
+ test_nonConstValueInInitializerFromDeferredLibrary_field_nested() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4760,8 +4762,8 @@
]);
}
- void test_nonConstValueInInitializerFromDeferredLibrary_redirecting() {
- resolveWithErrors(<String>[
+ test_nonConstValueInInitializerFromDeferredLibrary_redirecting() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4778,8 +4780,8 @@
]);
}
- void test_nonConstValueInInitializerFromDeferredLibrary_super() {
- resolveWithErrors(<String>[
+ test_nonConstValueInInitializerFromDeferredLibrary_super() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
const int c = 1;''',
@@ -4798,7 +4800,7 @@
]);
}
- void test_nonGenerativeConstructor_explicit() {
+ test_nonGenerativeConstructor_explicit() async {
Source source = addSource(r'''
class A {
factory A.named() => null;
@@ -4806,12 +4808,12 @@
class B extends A {
B() : super.named();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
verify([source]);
}
- void test_nonGenerativeConstructor_implicit() {
+ test_nonGenerativeConstructor_implicit() async {
Source source = addSource(r'''
class A {
factory A() => null;
@@ -4819,24 +4821,24 @@
class B extends A {
B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
verify([source]);
}
- void test_nonGenerativeConstructor_implicit2() {
+ test_nonGenerativeConstructor_implicit2() async {
Source source = addSource(r'''
class A {
factory A() => null;
}
class B extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
verify([source]);
}
- void test_notEnoughRequiredArguments_const() {
+ test_notEnoughRequiredArguments_const() async {
Source source = addSource(r'''
class A {
const A(int p);
@@ -4844,12 +4846,12 @@
main() {
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
verify([source]);
}
- void test_notEnoughRequiredArguments_const_super() {
+ test_notEnoughRequiredArguments_const_super() async {
Source source = addSource(r'''
class A {
const A(int p);
@@ -4857,51 +4859,51 @@
class B extends A {
const B() : super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
verify([source]);
}
- void test_optionalParameterInOperator_named() {
+ test_optionalParameterInOperator_named() async {
Source source = addSource(r'''
class A {
operator +({p}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
verify([source]);
}
- void test_optionalParameterInOperator_positional() {
+ test_optionalParameterInOperator_positional() async {
Source source = addSource(r'''
class A {
operator +([p]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
verify([source]);
}
- void test_partOfNonPart() {
+ test_partOfNonPart() async {
Source source = addSource(r'''
library l1;
part 'l2.dart';''');
addNamedSource("/l2.dart", "library l2;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]);
verify([source]);
}
- void test_partOfNonPart_self() {
+ test_partOfNonPart_self() async {
Source source = addSource(r'''
library lib;
part 'test.dart';''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]);
verify([source]);
}
- void test_prefix_assignment_compound_in_method() {
+ test_prefix_assignment_compound_in_method() async {
addNamedSource('/lib.dart', 'library lib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -4911,13 +4913,13 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_assignment_compound_not_in_method() {
+ test_prefix_assignment_compound_not_in_method() async {
addNamedSource('/lib.dart', 'library lib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -4925,13 +4927,13 @@
p += 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_assignment_in_method() {
+ test_prefix_assignment_in_method() async {
addNamedSource('/lib.dart', 'library lib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -4941,13 +4943,13 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_assignment_not_in_method() {
+ test_prefix_assignment_not_in_method() async {
addNamedSource('/lib.dart', 'library lib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -4955,13 +4957,13 @@
p = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_conditionalPropertyAccess_call() {
+ test_prefix_conditionalPropertyAccess_call() async {
addNamedSource(
'/lib.dart',
'''
@@ -4974,13 +4976,13 @@
p?.g();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_conditionalPropertyAccess_call_loadLibrary() {
+ test_prefix_conditionalPropertyAccess_call_loadLibrary() async {
addNamedSource(
'/lib.dart',
'''
@@ -4992,13 +4994,13 @@
p?.loadLibrary();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_conditionalPropertyAccess_get() {
+ test_prefix_conditionalPropertyAccess_get() async {
addNamedSource(
'/lib.dart',
'''
@@ -5011,13 +5013,13 @@
return p?.x;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_conditionalPropertyAccess_get_loadLibrary() {
+ test_prefix_conditionalPropertyAccess_get_loadLibrary() async {
addNamedSource(
'/lib.dart',
'''
@@ -5029,13 +5031,13 @@
return p?.loadLibrary;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_conditionalPropertyAccess_set() {
+ test_prefix_conditionalPropertyAccess_set() async {
addNamedSource(
'/lib.dart',
'''
@@ -5048,13 +5050,13 @@
p?.x = null;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_conditionalPropertyAccess_set_loadLibrary() {
+ test_prefix_conditionalPropertyAccess_set_loadLibrary() async {
addNamedSource(
'/lib.dart',
'''
@@ -5066,13 +5068,13 @@
p?.loadLibrary = null;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_unqualified_invocation_in_method() {
+ test_prefix_unqualified_invocation_in_method() async {
addNamedSource('/lib.dart', 'librarylib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -5082,13 +5084,13 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefix_unqualified_invocation_not_in_method() {
+ test_prefix_unqualified_invocation_not_in_method() async {
addNamedSource('/lib.dart', 'librarylib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -5096,13 +5098,13 @@
p();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() {
+ test_prefixCollidesWithTopLevelMembers_functionTypeAlias() async {
addNamedSource(
"/lib.dart",
r'''
@@ -5112,13 +5114,13 @@
import 'lib.dart' as p;
typedef p();
p.A a;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
verify([source]);
}
- void test_prefixCollidesWithTopLevelMembers_topLevelFunction() {
+ test_prefixCollidesWithTopLevelMembers_topLevelFunction() async {
addNamedSource(
"/lib.dart",
r'''
@@ -5128,13 +5130,13 @@
import 'lib.dart' as p;
p() {}
p.A a;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
verify([source]);
}
- void test_prefixCollidesWithTopLevelMembers_topLevelVariable() {
+ test_prefixCollidesWithTopLevelMembers_topLevelVariable() async {
addNamedSource(
"/lib.dart",
r'''
@@ -5144,13 +5146,13 @@
import 'lib.dart' as p;
var p = null;
p.A a;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
verify([source]);
}
- void test_prefixCollidesWithTopLevelMembers_type() {
+ test_prefixCollidesWithTopLevelMembers_type() async {
addNamedSource(
"/lib.dart",
r'''
@@ -5160,13 +5162,13 @@
import 'lib.dart' as p;
class p {}
p.A a;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
verify([source]);
}
- void test_prefixNotFollowedByDot() {
+ test_prefixNotFollowedByDot() async {
addNamedSource('/lib.dart', 'library lib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -5174,13 +5176,13 @@
return p;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefixNotFollowedByDot_compoundAssignment() {
+ test_prefixNotFollowedByDot_compoundAssignment() async {
addNamedSource('/lib.dart', 'library lib;');
Source source = addSource('''
import 'lib.dart' as p;
@@ -5188,13 +5190,13 @@
p += 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_prefixNotFollowedByDot_conditionalMethodInvocation() {
+ test_prefixNotFollowedByDot_conditionalMethodInvocation() async {
addNamedSource(
'/lib.dart',
'''
@@ -5207,54 +5209,54 @@
p?.g();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
verify([source]);
}
- void test_privateOptionalParameter() {
+ test_privateOptionalParameter() async {
Source source = addSource("f({var _p}) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
verify([source]);
}
- void test_privateOptionalParameter_fieldFormal() {
+ test_privateOptionalParameter_fieldFormal() async {
Source source = addSource(r'''
class A {
var _p;
A({this._p: 0});
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
verify([source]);
}
- void test_privateOptionalParameter_withDefaultValue() {
+ test_privateOptionalParameter_withDefaultValue() async {
Source source = addSource("f({_p : 0}) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
verify([source]);
}
- void test_recursiveCompileTimeConstant() {
+ test_recursiveCompileTimeConstant() async {
Source source = addSource(r'''
class A {
const A();
final m = const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
verify([source]);
}
- void test_recursiveCompileTimeConstant_cycle() {
+ test_recursiveCompileTimeConstant_cycle() async {
Source source = addSource(r'''
const x = y + 1;
const y = x + 1;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT,
CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT
@@ -5262,7 +5264,7 @@
verify([source]);
}
- void test_recursiveCompileTimeConstant_initializer_after_toplevel_var() {
+ test_recursiveCompileTimeConstant_initializer_after_toplevel_var() async {
Source source = addSource('''
const y = const C();
class C {
@@ -5270,29 +5272,29 @@
final x;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
verify([source]);
}
- void test_recursiveCompileTimeConstant_singleVariable() {
+ test_recursiveCompileTimeConstant_singleVariable() async {
Source source = addSource(r'''
const x = x;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
verify([source]);
}
- void test_recursiveConstructorRedirect() {
+ test_recursiveConstructorRedirect() async {
Source source = addSource(r'''
class A {
A.a() : this.b();
A.b() : this.a();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT,
CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT
@@ -5300,17 +5302,17 @@
verify([source]);
}
- void test_recursiveConstructorRedirect_directSelfReference() {
+ test_recursiveConstructorRedirect_directSelfReference() async {
Source source = addSource(r'''
class A {
A() : this();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]);
verify([source]);
}
- void test_recursiveFactoryRedirect() {
+ test_recursiveFactoryRedirect() async {
Source source = addSource(r'''
class A implements B {
factory A() = C;
@@ -5321,7 +5323,7 @@
class C implements A {
factory C() = B;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
@@ -5333,17 +5335,17 @@
verify([source]);
}
- void test_recursiveFactoryRedirect_directSelfReference() {
+ test_recursiveFactoryRedirect_directSelfReference() async {
Source source = addSource(r'''
class A {
factory A() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
verify([source]);
}
- void test_recursiveFactoryRedirect_diverging() {
+ test_recursiveFactoryRedirect_diverging() async {
// Analysis should terminate even though the redirections don't reach a
// fixed point. (C<int> redirects to C<C<int>>, then to C<C<C<int>>>, and
// so on).
@@ -5355,12 +5357,12 @@
const C<int>();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
verify([source]);
}
- void test_recursiveFactoryRedirect_generic() {
+ test_recursiveFactoryRedirect_generic() async {
Source source = addSource(r'''
class A<T> implements B<T> {
factory A() = C;
@@ -5371,7 +5373,7 @@
class C<T> implements A<T> {
factory C() = B;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
@@ -5383,7 +5385,7 @@
verify([source]);
}
- void test_recursiveFactoryRedirect_named() {
+ test_recursiveFactoryRedirect_named() async {
Source source = addSource(r'''
class A implements B {
factory A.nameA() = C.nameC;
@@ -5394,7 +5396,7 @@
class C implements A {
factory C.nameC() = B.nameB;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
@@ -5410,7 +5412,7 @@
* "A" references "C" which has cycle with "B". But we should not report problem for "A" - it is
* not the part of a cycle.
*/
- void test_recursiveFactoryRedirect_outsideCycle() {
+ test_recursiveFactoryRedirect_outsideCycle() async {
Source source = addSource(r'''
class A {
factory A() = C;
@@ -5421,7 +5423,7 @@
class C implements A, B {
factory C() = B;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
@@ -5431,11 +5433,11 @@
verify([source]);
}
- void test_recursiveInterfaceInheritance_extends() {
+ test_recursiveInterfaceInheritance_extends() async {
Source source = addSource(r'''
class A extends B {}
class B extends A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
@@ -5443,11 +5445,11 @@
verify([source]);
}
- void test_recursiveInterfaceInheritance_extends_implements() {
+ test_recursiveInterfaceInheritance_extends_implements() async {
Source source = addSource(r'''
class A extends B {}
class B implements A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
@@ -5455,11 +5457,11 @@
verify([source]);
}
- void test_recursiveInterfaceInheritance_implements() {
+ test_recursiveInterfaceInheritance_implements() async {
Source source = addSource(r'''
class A implements B {}
class B implements A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
@@ -5467,11 +5469,11 @@
verify([source]);
}
- void test_recursiveInterfaceInheritance_mixin() {
+ test_recursiveInterfaceInheritance_mixin() async {
Source source = addSource(r'''
class M1 = Object with M2;
class M2 = Object with M1;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
@@ -5479,7 +5481,7 @@
verify([source]);
}
- void test_recursiveInterfaceInheritance_mixin_superclass() {
+ test_recursiveInterfaceInheritance_mixin_superclass() async {
// Make sure we don't get CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS in
// addition--that would just be confusing.
Source source = addSource('''
@@ -5487,7 +5489,7 @@
class D = C with M;
class M {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
@@ -5495,23 +5497,23 @@
verify([source]);
}
- void test_recursiveInterfaceInheritance_tail() {
+ test_recursiveInterfaceInheritance_tail() async {
Source source = addSource(r'''
abstract class A implements A {}
class B implements A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS
]);
verify([source]);
}
- void test_recursiveInterfaceInheritance_tail2() {
+ test_recursiveInterfaceInheritance_tail2() async {
Source source = addSource(r'''
abstract class A implements B {}
abstract class B implements A {}
class C implements A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE
@@ -5519,13 +5521,13 @@
verify([source]);
}
- void test_recursiveInterfaceInheritance_tail3() {
+ test_recursiveInterfaceInheritance_tail3() async {
Source source = addSource(r'''
abstract class A implements B {}
abstract class B implements C {}
abstract class C implements A {}
class D implements A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
@@ -5534,23 +5536,23 @@
verify([source]);
}
- void test_recursiveInterfaceInheritanceBaseCaseExtends() {
+ test_recursiveInterfaceInheritanceBaseCaseExtends() async {
Source source = addSource("class A extends A {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS
]);
verify([source]);
}
- void test_recursiveInterfaceInheritanceBaseCaseExtends_abstract() {
+ test_recursiveInterfaceInheritanceBaseCaseExtends_abstract() async {
Source source = addSource(r'''
class C extends C {
var bar = 0;
m();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS,
StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER,
@@ -5559,59 +5561,59 @@
verify([source]);
}
- void test_recursiveInterfaceInheritanceBaseCaseImplements() {
+ test_recursiveInterfaceInheritanceBaseCaseImplements() async {
Source source = addSource("class A implements A {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS
]);
verify([source]);
}
- void test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias() {
+ test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias() async {
Source source = addSource(r'''
class A {}
class M {}
class B = A with M implements B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS
]);
verify([source]);
}
- void test_recursiveInterfaceInheritanceBaseCaseWith() {
+ test_recursiveInterfaceInheritanceBaseCaseWith() async {
Source source = addSource("class M = Object with M;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH]);
verify([source]);
}
- void test_redirectGenerativeToMissingConstructor() {
+ test_redirectGenerativeToMissingConstructor() async {
Source source = addSource(r'''
class A {
A() : this.noSuchConstructor();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]);
}
- void test_redirectGenerativeToNonGenerativeConstructor() {
+ test_redirectGenerativeToNonGenerativeConstructor() async {
Source source = addSource(r'''
class A {
A() : this.x();
factory A.x() => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR
]);
verify([source]);
}
- void test_redirectToMissingConstructor_named() {
+ test_redirectToMissingConstructor_named() async {
Source source = addSource(r'''
class A implements B{
A() {}
@@ -5619,12 +5621,12 @@
class B {
const factory B() = A.name;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
}
- void test_redirectToMissingConstructor_unnamed() {
+ test_redirectToMissingConstructor_unnamed() async {
Source source = addSource(r'''
class A implements B{
A.name() {}
@@ -5632,45 +5634,45 @@
class B {
const factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
}
- void test_redirectToNonClass_notAType() {
+ test_redirectToNonClass_notAType() async {
Source source = addSource(r'''
int A;
class B {
const factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]);
verify([source]);
}
- void test_redirectToNonClass_undefinedIdentifier() {
+ test_redirectToNonClass_undefinedIdentifier() async {
Source source = addSource(r'''
class B {
const factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]);
verify([source]);
}
- void test_redirectToNonConstConstructor() {
+ test_redirectToNonConstConstructor() async {
Source source = addSource(r'''
class A {
A.a() {}
const factory A.b() = A.a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR]);
verify([source]);
}
- void test_referencedBeforeDeclaration_hideInBlock_function() {
+ test_referencedBeforeDeclaration_hideInBlock_function() async {
Source source = addSource(r'''
var v = 1;
main() {
@@ -5678,11 +5680,11 @@
v() {}
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
}
- void test_referencedBeforeDeclaration_hideInBlock_local() {
+ test_referencedBeforeDeclaration_hideInBlock_local() async {
Source source = addSource(r'''
var v = 1;
main() {
@@ -5690,11 +5692,11 @@
var v = 2;
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
}
- void test_referencedBeforeDeclaration_hideInBlock_subBlock() {
+ test_referencedBeforeDeclaration_hideInBlock_subBlock() async {
Source source = addSource(r'''
var v = 1;
main() {
@@ -5704,104 +5706,104 @@
var v = 2;
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
}
- void test_referencedBeforeDeclaration_inInitializer_closure() {
+ test_referencedBeforeDeclaration_inInitializer_closure() async {
Source source = addSource(r'''
main() {
var v = () => v;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
}
- void test_referencedBeforeDeclaration_inInitializer_directly() {
+ test_referencedBeforeDeclaration_inInitializer_directly() async {
Source source = addSource(r'''
main() {
var v = v;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
}
- void test_referencedBeforeDeclaration_type_localFunction() {
+ test_referencedBeforeDeclaration_type_localFunction() async {
Source source = addSource(r'''
void testTypeRef() {
String s = '';
int String(int x) => x + 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
}
- void test_referencedBeforeDeclaration_type_localVariable() {
+ test_referencedBeforeDeclaration_type_localVariable() async {
Source source = addSource(r'''
void testTypeRef() {
String s = '';
var String = '';
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
}
- void test_rethrowOutsideCatch() {
+ test_rethrowOutsideCatch() async {
Source source = addSource(r'''
f() {
rethrow;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]);
verify([source]);
}
- void test_returnInGenerativeConstructor() {
+ test_returnInGenerativeConstructor() async {
Source source = addSource(r'''
class A {
A() { return 0; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]);
verify([source]);
}
- void test_returnInGenerativeConstructor_expressionFunctionBody() {
+ test_returnInGenerativeConstructor_expressionFunctionBody() async {
Source source = addSource(r'''
class A {
A() => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]);
verify([source]);
}
- void test_returnInGenerator_asyncStar() {
+ test_returnInGenerator_asyncStar() async {
Source source = addSource(r'''
f() async* {
return 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]);
verify([source]);
}
- void test_returnInGenerator_syncStar() {
+ test_returnInGenerator_syncStar() async {
Source source = addSource(r'''
f() sync* {
return 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]);
verify([source]);
}
- void test_sharedDeferredPrefix() {
- resolveWithErrors(<String>[
+ test_sharedDeferredPrefix() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
f1() {}''',
@@ -5818,14 +5820,14 @@
]);
}
- void test_superInInvalidContext_binaryExpression() {
+ test_superInInvalidContext_binaryExpression() async {
Source source = addSource("var v = super + 0;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.v' is not resolved
}
- void test_superInInvalidContext_constructorFieldInitializer() {
+ test_superInInvalidContext_constructorFieldInitializer() async {
Source source = addSource(r'''
class A {
m() {}
@@ -5834,12 +5836,12 @@
var f;
B() : f = super.m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.m' is not resolved
}
- void test_superInInvalidContext_factoryConstructor() {
+ test_superInInvalidContext_factoryConstructor() async {
Source source = addSource(r'''
class A {
m() {}
@@ -5850,12 +5852,12 @@
return null;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.m' is not resolved
}
- void test_superInInvalidContext_instanceVariableInitializer() {
+ test_superInInvalidContext_instanceVariableInitializer() async {
Source source = addSource(r'''
class A {
var a;
@@ -5863,12 +5865,12 @@
class B extends A {
var b = super.a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.a' is not resolved
}
- void test_superInInvalidContext_staticMethod() {
+ test_superInInvalidContext_staticMethod() async {
Source source = addSource(r'''
class A {
static m() {}
@@ -5876,12 +5878,12 @@
class B extends A {
static n() { return super.m(); }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.m' is not resolved
}
- void test_superInInvalidContext_staticVariableInitializer() {
+ test_superInInvalidContext_staticVariableInitializer() async {
Source source = addSource(r'''
class A {
static int a = 0;
@@ -5889,62 +5891,62 @@
class B extends A {
static int b = super.a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.a' is not resolved
}
- void test_superInInvalidContext_topLevelFunction() {
+ test_superInInvalidContext_topLevelFunction() async {
Source source = addSource(r'''
f() {
super.f();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.f' is not resolved
}
- void test_superInInvalidContext_topLevelVariableInitializer() {
+ test_superInInvalidContext_topLevelVariableInitializer() async {
Source source = addSource("var v = super.y;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
// no verify(), 'super.y' is not resolved
}
- void test_superInRedirectingConstructor_redirectionSuper() {
+ test_superInRedirectingConstructor_redirectionSuper() async {
Source source = addSource(r'''
class A {}
class B {
B() : this.name(), super();
B.name() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]);
verify([source]);
}
- void test_superInRedirectingConstructor_superRedirection() {
+ test_superInRedirectingConstructor_superRedirection() async {
Source source = addSource(r'''
class A {}
class B {
B() : super(), this.name();
B.name() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]);
verify([source]);
}
- void test_symbol_constructor_badArgs() {
+ test_symbol_constructor_badArgs() async {
Source source = addSource(r'''
var s1 = const Symbol('3');
var s2 = const Symbol(3);
var s3 = const Symbol();
var s4 = const Symbol('x', 'y');
var s5 = const Symbol('x', foo: 'x');''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
@@ -5956,14 +5958,14 @@
verify([source]);
}
- void test_typeAliasCannotReferenceItself_11987() {
+ test_typeAliasCannotReferenceItself_11987() async {
Source source = addSource(r'''
typedef void F(List<G> l);
typedef void G(List<F> l);
main() {
F foo(G g) => g;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
@@ -5971,7 +5973,7 @@
verify([source]);
}
- void test_typeAliasCannotReferenceItself_19459() {
+ test_typeAliasCannotReferenceItself_19459() async {
// A complex example involving multiple classes. This is legal, since
// typedef F references itself only via a class.
Source source = addSource(r'''
@@ -5982,44 +5984,44 @@
abstract class E extends A<dynamic, F> {}
typedef D F();
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_parameterType_named() {
+ test_typeAliasCannotReferenceItself_parameterType_named() async {
Source source = addSource("typedef A({A a});");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_parameterType_positional() {
+ test_typeAliasCannotReferenceItself_parameterType_positional() async {
Source source = addSource("typedef A([A a]);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_parameterType_required() {
+ test_typeAliasCannotReferenceItself_parameterType_required() async {
Source source = addSource("typedef A(A a);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_parameterType_typeArgument() {
+ test_typeAliasCannotReferenceItself_parameterType_typeArgument() async {
Source source = addSource("typedef A(List<A> a);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() {
+ test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() async {
// A typedef is allowed to indirectly reference itself via a class.
Source source = addSource(r'''
typedef C A();
@@ -6027,24 +6029,24 @@
class C {
B a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_returnType() {
+ test_typeAliasCannotReferenceItself_returnType() async {
Source source = addSource("typedef A A();");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_returnType_indirect() {
+ test_typeAliasCannotReferenceItself_returnType_indirect() async {
Source source = addSource(r'''
typedef B A();
typedef A B();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
@@ -6052,15 +6054,15 @@
verify([source]);
}
- void test_typeAliasCannotReferenceItself_typeVariableBounds() {
+ test_typeAliasCannotReferenceItself_typeVariableBounds() async {
Source source = addSource("typedef A<T extends A>();");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_const() {
+ test_typeArgumentNotMatchingBounds_const() async {
Source source = addSource(r'''
class A {}
class B {}
@@ -6068,35 +6070,35 @@
const G();
}
f() { return const G<B>(); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
verify([source]);
}
- void test_undefinedClass_const() {
+ test_undefinedClass_const() async {
Source source = addSource(r'''
f() {
return const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CLASS]);
verify([source]);
}
- void test_undefinedConstructorInInitializer_explicit_named() {
+ test_undefinedConstructorInInitializer_explicit_named() async {
Source source = addSource(r'''
class A {}
class B extends A {
B() : super.named();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
// no verify(), "super.named()" is not resolved
}
- void test_undefinedConstructorInInitializer_explicit_unnamed() {
+ test_undefinedConstructorInInitializer_explicit_unnamed() async {
Source source = addSource(r'''
class A {
A.named() {}
@@ -6104,13 +6106,13 @@
class B extends A {
B() : super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
verify([source]);
}
- void test_undefinedConstructorInInitializer_implicit() {
+ test_undefinedConstructorInInitializer_implicit() async {
Source source = addSource(r'''
class A {
A.named() {}
@@ -6118,13 +6120,13 @@
class B extends A {
B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
verify([source]);
}
- void test_undefinedNamedParameter() {
+ test_undefinedNamedParameter() async {
Source source = addSource(r'''
class A {
const A();
@@ -6132,41 +6134,42 @@
main() {
const A(p: 0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]);
// no verify(), 'p' is not resolved
}
- void test_uriDoesNotExist_export() {
+ test_uriDoesNotExist_export() async {
Source source = addSource("export 'unknown.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
}
- void test_uriDoesNotExist_import() {
+ test_uriDoesNotExist_import() async {
Source source = addSource("import 'unknown.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
}
- void test_uriDoesNotExist_import_appears_after_deleting_target() {
+ test_uriDoesNotExist_import_appears_after_deleting_target() async {
Source test = addSource("import 'target.dart';");
Source target = addNamedSource("/target.dart", "");
- computeLibrarySourceErrors(test);
+ await computeAnalysisResult(test);
assertErrors(test, [HintCode.UNUSED_IMPORT]);
// Remove the overlay in the same way as AnalysisServer.
+ resourceProvider.deleteFile(resourceProvider.convertPath('/target.dart'));
analysisContext2.setContents(target, null);
ChangeSet changeSet = new ChangeSet()..removedSource(target);
analysisContext2.applyChanges(changeSet);
- computeLibrarySourceErrors(test);
+ await computeAnalysisResult(test);
assertErrors(test, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
}
- void test_uriDoesNotExist_import_disappears_when_fixed() {
+ test_uriDoesNotExist_import_disappears_when_fixed() async {
Source source = addSource("import 'target.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
// Check that the file is represented as missing.
@@ -6181,21 +6184,21 @@
..handleContentsChanged(target, null, "", true);
// Make sure the error goes away.
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_IMPORT]);
}
- void test_uriDoesNotExist_part() {
+ test_uriDoesNotExist_part() async {
Source source = addSource(r'''
library lib;
part 'unknown.dart';''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
}
- void test_uriWithInterpolation_constant() {
+ test_uriWithInterpolation_constant() async {
Source source = addSource("import 'stuff_\$platform.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.URI_WITH_INTERPOLATION,
StaticWarningCode.UNDEFINED_IDENTIFIER
@@ -6204,179 +6207,182 @@
// URI: 'stuff_$platform.dart'
}
- void test_uriWithInterpolation_nonConstant() {
+ test_uriWithInterpolation_nonConstant() async {
Source source = addSource(r'''
library lib;
part '${'a'}.dart';''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_WITH_INTERPOLATION]);
// We cannot verify resolution with an unresolvable URI: '${'a'}.dart'
}
- void test_wrongNumberOfParametersForOperator1() {
- _check_wrongNumberOfParametersForOperator1("<");
- _check_wrongNumberOfParametersForOperator1(">");
- _check_wrongNumberOfParametersForOperator1("<=");
- _check_wrongNumberOfParametersForOperator1(">=");
- _check_wrongNumberOfParametersForOperator1("+");
- _check_wrongNumberOfParametersForOperator1("/");
- _check_wrongNumberOfParametersForOperator1("~/");
- _check_wrongNumberOfParametersForOperator1("*");
- _check_wrongNumberOfParametersForOperator1("%");
- _check_wrongNumberOfParametersForOperator1("|");
- _check_wrongNumberOfParametersForOperator1("^");
- _check_wrongNumberOfParametersForOperator1("&");
- _check_wrongNumberOfParametersForOperator1("<<");
- _check_wrongNumberOfParametersForOperator1(">>");
- _check_wrongNumberOfParametersForOperator1("[]");
+ test_wrongNumberOfParametersForOperator1() async {
+ await _check_wrongNumberOfParametersForOperator1("<");
+ await _check_wrongNumberOfParametersForOperator1(">");
+ await _check_wrongNumberOfParametersForOperator1("<=");
+ await _check_wrongNumberOfParametersForOperator1(">=");
+ await _check_wrongNumberOfParametersForOperator1("+");
+ await _check_wrongNumberOfParametersForOperator1("/");
+ await _check_wrongNumberOfParametersForOperator1("~/");
+ await _check_wrongNumberOfParametersForOperator1("*");
+ await _check_wrongNumberOfParametersForOperator1("%");
+ await _check_wrongNumberOfParametersForOperator1("|");
+ await _check_wrongNumberOfParametersForOperator1("^");
+ await _check_wrongNumberOfParametersForOperator1("&");
+ await _check_wrongNumberOfParametersForOperator1("<<");
+ await _check_wrongNumberOfParametersForOperator1(">>");
+ await _check_wrongNumberOfParametersForOperator1("[]");
}
- void test_wrongNumberOfParametersForOperator_minus() {
+ test_wrongNumberOfParametersForOperator_minus() async {
Source source = addSource(r'''
class A {
operator -(a, b) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS]);
verify([source]);
reset();
}
- void test_wrongNumberOfParametersForOperator_tilde() {
- _check_wrongNumberOfParametersForOperator("~", "a");
- _check_wrongNumberOfParametersForOperator("~", "a, b");
+ test_wrongNumberOfParametersForOperator_tilde() async {
+ await _check_wrongNumberOfParametersForOperator("~", "a");
+ await _check_wrongNumberOfParametersForOperator("~", "a, b");
}
- void test_wrongNumberOfParametersForSetter_function_named() {
+ test_wrongNumberOfParametersForSetter_function_named() async {
Source source = addSource("set x({p}) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_wrongNumberOfParametersForSetter_function_optional() {
+ test_wrongNumberOfParametersForSetter_function_optional() async {
Source source = addSource("set x([p]) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_wrongNumberOfParametersForSetter_function_tooFew() {
+ test_wrongNumberOfParametersForSetter_function_tooFew() async {
Source source = addSource("set x() {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_wrongNumberOfParametersForSetter_function_tooMany() {
+ test_wrongNumberOfParametersForSetter_function_tooMany() async {
Source source = addSource("set x(a, b) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_wrongNumberOfParametersForSetter_method_named() {
+ test_wrongNumberOfParametersForSetter_method_named() async {
Source source = addSource(r'''
class A {
set x({p}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_wrongNumberOfParametersForSetter_method_optional() {
+ test_wrongNumberOfParametersForSetter_method_optional() async {
Source source = addSource(r'''
class A {
set x([p]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_wrongNumberOfParametersForSetter_method_tooFew() {
+ test_wrongNumberOfParametersForSetter_method_tooFew() async {
Source source = addSource(r'''
class A {
set x() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_wrongNumberOfParametersForSetter_method_tooMany() {
+ test_wrongNumberOfParametersForSetter_method_tooMany() async {
Source source = addSource(r'''
class A {
set x(a, b) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
verify([source]);
}
- void test_yield_used_as_identifier_in_async_method() {
+ test_yield_used_as_identifier_in_async_method() async {
Source source = addSource('''
f() async {
var yield = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_yield_used_as_identifier_in_async_star_method() {
+ test_yield_used_as_identifier_in_async_star_method() async {
Source source = addSource('''
f() async* {
var yield = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void test_yield_used_as_identifier_in_sync_star_method() {
+ test_yield_used_as_identifier_in_sync_star_method() async {
Source source = addSource('''
f() sync* {
var yield = 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}
- void _check_constEvalThrowsException_binary_null(String expr, bool resolved) {
+ Future<Null> _check_constEvalThrowsException_binary_null(
+ String expr, bool resolved) async {
Source source = addSource("const C = $expr;");
- computeLibrarySourceErrors(source);
if (resolved) {
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
verify([source]);
} else {
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
// no verify(), 'null x' is not resolved
}
reset();
}
- void _check_constEvalTypeBool_withParameter_binary(String expr) {
+ Future<Null> _check_constEvalTypeBool_withParameter_binary(
+ String expr) async {
Source source = addSource('''
class A {
final a;
const A(bool p) : a = $expr;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
StaticTypeWarningCode.NON_BOOL_OPERAND
@@ -6385,13 +6391,13 @@
reset();
}
- void _check_constEvalTypeInt_withParameter_binary(String expr) {
+ Future<Null> _check_constEvalTypeInt_withParameter_binary(String expr) async {
Source source = addSource('''
class A {
final a;
const A(int p) : a = $expr;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_INT,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -6400,13 +6406,13 @@
reset();
}
- void _check_constEvalTypeNum_withParameter_binary(String expr) {
+ Future<Null> _check_constEvalTypeNum_withParameter_binary(String expr) async {
Source source = addSource('''
class A {
final a;
const A(num p) : a = $expr;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.CONST_EVAL_TYPE_NUM,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
@@ -6415,21 +6421,21 @@
reset();
}
- void _check_wrongNumberOfParametersForOperator(
- String name, String parameters) {
+ Future<Null> _check_wrongNumberOfParametersForOperator(
+ String name, String parameters) async {
Source source = addSource('''
class A {
operator $name($parameters) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
verify([source]);
reset();
}
- void _check_wrongNumberOfParametersForOperator1(String name) {
- _check_wrongNumberOfParametersForOperator(name, "");
- _check_wrongNumberOfParametersForOperator(name, "a, b");
+ Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async {
+ await _check_wrongNumberOfParametersForOperator(name, "");
+ await _check_wrongNumberOfParametersForOperator(name, "a, b");
}
}
diff --git a/pkg/analyzer/test/generated/declaration_resolver_test.dart b/pkg/analyzer/test/generated/declaration_resolver_test.dart
index eeaf82d..9ecac6a 100644
--- a/pkg/analyzer/test/generated/declaration_resolver_test.dart
+++ b/pkg/analyzer/test/generated/declaration_resolver_test.dart
@@ -4,6 +4,8 @@
library engine.declaration_resolver_test;
+import 'dart:async';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
@@ -59,50 +61,50 @@
}
}
- void setupCode(String code) {
+ Future<Null> setupCode(String code) async {
this.code = code;
- unit = resolveSource(code + ' const a = null;');
+ unit = await resolveSource(code + ' const a = null;');
unit2 = _cloneResolveUnit(unit);
}
- void test_metadata_classDeclaration() {
- setupCode('@a class C {}');
+ test_metadata_classDeclaration() async {
+ await setupCode('@a class C {}');
checkMetadata('C');
}
- void test_metadata_classTypeAlias() {
- setupCode('@a class C = D with E; class D {} class E {}');
+ test_metadata_classTypeAlias() async {
+ await setupCode('@a class C = D with E; class D {} class E {}');
checkMetadata('C');
}
- void test_metadata_constructorDeclaration_named() {
- setupCode('class C { @a C.x(); }');
+ test_metadata_constructorDeclaration_named() async {
+ await setupCode('class C { @a C.x(); }');
checkMetadata('x');
}
- void test_metadata_constructorDeclaration_unnamed() {
- setupCode('class C { @a C(); }');
+ test_metadata_constructorDeclaration_unnamed() async {
+ await setupCode('class C { @a C(); }');
checkMetadata('C()');
}
- void test_metadata_declaredIdentifier() {
- setupCode('f(x, y) { for (@a var x in y) {} }');
+ test_metadata_declaredIdentifier() async {
+ await setupCode('f(x, y) { for (@a var x in y) {} }');
checkMetadata('var', expectDifferent: true);
}
- void test_metadata_enumDeclaration() {
- setupCode('@a enum E { v }');
+ test_metadata_enumDeclaration() async {
+ await setupCode('@a enum E { v }');
checkMetadata('E');
}
- void test_metadata_exportDirective() {
+ test_metadata_exportDirective() async {
addNamedSource('/foo.dart', 'class C {}');
- setupCode('@a export "foo.dart";');
+ await setupCode('@a export "foo.dart";');
checkMetadata('export');
}
- void test_metadata_exportDirective_resynthesized() {
- CompilationUnit unit = resolveSource(r'''
+ test_metadata_exportDirective_resynthesized() async {
+ CompilationUnit unit = await resolveSource(r'''
@a
export "dart:async";
@@ -128,58 +130,58 @@
expect(unit.directives[1].metadata.single.name.name, 'b');
}
- void test_metadata_fieldDeclaration() {
- setupCode('class C { @a int x; }');
+ test_metadata_fieldDeclaration() async {
+ await setupCode('class C { @a int x; }');
checkMetadata('x');
}
- void test_metadata_fieldFormalParameter() {
- setupCode('class C { var x; C(@a this.x); }');
+ test_metadata_fieldFormalParameter() async {
+ await setupCode('class C { var x; C(@a this.x); }');
checkMetadata('this');
}
- void test_metadata_fieldFormalParameter_withDefault() {
- setupCode('class C { var x; C([@a this.x = null]); }');
+ test_metadata_fieldFormalParameter_withDefault() async {
+ await setupCode('class C { var x; C([@a this.x = null]); }');
checkMetadata('this');
}
- void test_metadata_functionDeclaration_function() {
- setupCode('@a f() {}');
+ test_metadata_functionDeclaration_function() async {
+ await setupCode('@a f() {}');
checkMetadata('f');
}
- void test_metadata_functionDeclaration_getter() {
- setupCode('@a get f() => null;');
+ test_metadata_functionDeclaration_getter() async {
+ await setupCode('@a get f() => null;');
checkMetadata('f');
}
- void test_metadata_functionDeclaration_setter() {
- setupCode('@a set f(value) {}');
+ test_metadata_functionDeclaration_setter() async {
+ await setupCode('@a set f(value) {}');
checkMetadata('f');
}
- void test_metadata_functionTypeAlias() {
- setupCode('@a typedef F();');
+ test_metadata_functionTypeAlias() async {
+ await setupCode('@a typedef F();');
checkMetadata('F');
}
- void test_metadata_functionTypedFormalParameter() {
- setupCode('f(@a g()) {}');
+ test_metadata_functionTypedFormalParameter() async {
+ await setupCode('f(@a g()) {}');
checkMetadata('g');
}
- void test_metadata_functionTypedFormalParameter_withDefault() {
- setupCode('f([@a g() = null]) {}');
+ test_metadata_functionTypedFormalParameter_withDefault() async {
+ await setupCode('f([@a g() = null]) {}');
checkMetadata('g');
}
- void test_metadata_importDirective() {
+ test_metadata_importDirective() async {
addNamedSource('/foo.dart', 'class C {}');
- setupCode('@a import "foo.dart";');
+ await setupCode('@a import "foo.dart";');
checkMetadata('import');
}
- void test_metadata_importDirective_partiallyResolved() {
+ test_metadata_importDirective_partiallyResolved() async {
addNamedSource('/foo.dart', 'class C {}');
this.code = 'const a = null; @a import "foo.dart";';
Source source = addNamedSource('/test.dart', code);
@@ -190,8 +192,8 @@
checkMetadata('import');
}
- void test_metadata_importDirective_resynthesized() {
- CompilationUnit unit = resolveSource(r'''
+ test_metadata_importDirective_resynthesized() async {
+ CompilationUnit unit = await resolveSource(r'''
@a
import "dart:async";
@@ -217,13 +219,14 @@
expect(unit.directives[1].metadata.single.name.name, 'b');
}
- void test_metadata_libraryDirective() {
- setupCode('@a library L;');
+ test_metadata_libraryDirective() async {
+ await setupCode('@a library L;');
checkMetadata('L');
}
- void test_metadata_libraryDirective_resynthesized() {
- CompilationUnit unit = resolveSource('@a library L; const a = null;');
+ test_metadata_libraryDirective_resynthesized() async {
+ CompilationUnit unit =
+ await resolveSource('@a library L; const a = null;');
expect(unit.directives.single.metadata.single.name.name, 'a');
var unitElement = unit.element as CompilationUnitElementImpl;
// Damage the unit element - as if "setAnnotations" were not called.
@@ -236,8 +239,8 @@
expect(clonedUnit.directives.single.metadata.single.name.name, 'a');
}
- void test_metadata_localFunctionDeclaration() {
- setupCode('f() { @a g() {} }');
+ test_metadata_localFunctionDeclaration() async {
+ await setupCode('f() { @a g() {} }');
// Note: metadata on local function declarations is ignored by the
// analyzer. TODO(paulberry): is this a bug?
FunctionDeclaration node = EngineTestCase.findNode(
@@ -245,64 +248,64 @@
expect((node as FunctionDeclarationImpl).metadata, isEmpty);
}
- void test_metadata_localVariableDeclaration() {
- setupCode('f() { @a int x; }');
+ test_metadata_localVariableDeclaration() async {
+ await setupCode('f() { @a int x; }');
checkMetadata('x', expectDifferent: true);
}
- void test_metadata_methodDeclaration_getter() {
- setupCode('class C { @a get m => null; }');
+ test_metadata_methodDeclaration_getter() async {
+ await setupCode('class C { @a get m => null; }');
checkMetadata('m');
}
- void test_metadata_methodDeclaration_method() {
- setupCode('class C { @a m() {} }');
+ test_metadata_methodDeclaration_method() async {
+ await setupCode('class C { @a m() {} }');
checkMetadata('m');
}
- void test_metadata_methodDeclaration_setter() {
- setupCode('class C { @a set m(value) {} }');
+ test_metadata_methodDeclaration_setter() async {
+ await setupCode('class C { @a set m(value) {} }');
checkMetadata('m');
}
- void test_metadata_partDirective() {
+ test_metadata_partDirective() async {
addNamedSource('/foo.dart', 'part of L;');
- setupCode('library L; @a part "foo.dart";');
+ await setupCode('library L; @a part "foo.dart";');
checkMetadata('part');
}
- void test_metadata_simpleFormalParameter() {
- setupCode('f(@a x) {}) {}');
+ test_metadata_simpleFormalParameter() async {
+ await setupCode('f(@a x) {}) {}');
checkMetadata('x');
}
- void test_metadata_simpleFormalParameter_withDefault() {
- setupCode('f([@a x = null]) {}');
+ test_metadata_simpleFormalParameter_withDefault() async {
+ await setupCode('f([@a x = null]) {}');
checkMetadata('x');
}
- void test_metadata_topLevelVariableDeclaration() {
- setupCode('@a int x;');
+ test_metadata_topLevelVariableDeclaration() async {
+ await setupCode('@a int x;');
checkMetadata('x');
}
- void test_metadata_typeParameter_ofClass() {
- setupCode('class C<@a T> {}');
+ test_metadata_typeParameter_ofClass() async {
+ await setupCode('class C<@a T> {}');
checkMetadata('T');
}
- void test_metadata_typeParameter_ofClassTypeAlias() {
- setupCode('class C<@a T> = D with E; class D {} class E {}');
+ test_metadata_typeParameter_ofClassTypeAlias() async {
+ await setupCode('class C<@a T> = D with E; class D {} class E {}');
checkMetadata('T');
}
- void test_metadata_typeParameter_ofFunction() {
- setupCode('f<@a T>() {}');
+ test_metadata_typeParameter_ofFunction() async {
+ await setupCode('f<@a T>() {}');
checkMetadata('T');
}
- void test_metadata_typeParameter_ofTypedef() {
- setupCode('typedef F<@a T>();');
+ test_metadata_typeParameter_ofTypedef() async {
+ await setupCode('typedef F<@a T>();');
checkMetadata('T');
}
@@ -330,7 +333,7 @@
super.setUp();
}
- void test_closure_inside_catch_block() {
+ test_closure_inside_catch_block() async {
String code = '''
f() {
try {
@@ -339,13 +342,13 @@
}
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_closure_inside_labeled_statement() {
+ test_closure_inside_labeled_statement() async {
String code = '''
f(b) {
foo: while (true) {
@@ -356,13 +359,13 @@
}
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_closure_inside_switch_case() {
+ test_closure_inside_switch_case() async {
String code = '''
void f(k, m) {
switch (k) {
@@ -372,13 +375,13 @@
}
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_closure_inside_switch_default() {
+ test_closure_inside_switch_default() async {
String code = '''
void f(k, m) {
switch (k) {
@@ -388,13 +391,13 @@
}
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_enumConstant_partiallyResolved() {
+ test_enumConstant_partiallyResolved() async {
String code = r'''
enum Fruit {apple, pear}
''';
@@ -406,11 +409,11 @@
_cloneResolveUnit(unit);
}
- void test_functionDeclaration_getter() {
+ test_functionDeclaration_getter() async {
String code = r'''
int get zzz => 42;
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
PropertyAccessorElement getterElement =
_findSimpleIdentifier(unit, code, 'zzz =>').staticElement;
expect(getterElement.isGetter, isTrue);
@@ -420,11 +423,11 @@
expect(getterName.staticElement, same(getterElement));
}
- void test_functionDeclaration_setter() {
+ test_functionDeclaration_setter() async {
String code = r'''
void set zzz(_) {}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
PropertyAccessorElement setterElement =
_findSimpleIdentifier(unit, code, 'zzz(_)').staticElement;
expect(setterElement.isSetter, isTrue);
@@ -434,7 +437,7 @@
expect(getterName.staticElement, same(setterElement));
}
- void test_invalid_functionDeclaration_getter_inFunction() {
+ test_invalid_functionDeclaration_getter_inFunction() async {
String code = r'''
var v = (() {
main() {
@@ -442,7 +445,7 @@
}
});
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
FunctionElement getterElement =
_findSimpleIdentifier(unit, code, 'zzz =>').staticElement;
// re-resolve
@@ -451,7 +454,7 @@
expect(getterName.staticElement, same(getterElement));
}
- void test_invalid_functionDeclaration_setter_inFunction() {
+ test_invalid_functionDeclaration_setter_inFunction() async {
String code = r'''
var v = (() {
main() {
@@ -459,7 +462,7 @@
}
});
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
FunctionElement setterElement =
_findSimpleIdentifier(unit, code, 'zzz(x)').staticElement;
// re-resolve
@@ -468,66 +471,66 @@
expect(setterName.staticElement, same(setterElement));
}
- void test_visitExportDirective_notExistingSource() {
+ test_visitExportDirective_notExistingSource() async {
String code = r'''
export 'foo.dart';
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_visitExportDirective_unresolvedUri() {
+ test_visitExportDirective_unresolvedUri() async {
String code = r'''
export 'package:foo/bar.dart';
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_visitFunctionExpression() {
+ test_visitFunctionExpression() async {
String code = r'''
main(List<String> items) {
items.forEach((item) {});
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_visitImportDirective_notExistingSource() {
+ test_visitImportDirective_notExistingSource() async {
String code = r'''
import 'foo.dart';
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_visitImportDirective_unresolvedUri() {
+ test_visitImportDirective_unresolvedUri() async {
String code = r'''
import 'package:foo/bar.dart';
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_visitMethodDeclaration_getter_duplicate() {
+ test_visitMethodDeclaration_getter_duplicate() async {
String code = r'''
class C {
int get zzz => 1;
String get zzz => null;
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
PropertyAccessorElement firstElement =
_findSimpleIdentifier(unit, code, 'zzz => 1').staticElement;
PropertyAccessorElement secondElement =
@@ -541,7 +544,7 @@
expect(secondName.staticElement, same(secondElement));
}
- void test_visitMethodDeclaration_getterSetter() {
+ test_visitMethodDeclaration_getterSetter() async {
String code = r'''
class C {
int _field = 0;
@@ -549,7 +552,7 @@
void set field(value) {_field = value;}
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
FieldElement getterElement =
_findSimpleIdentifier(unit, code, 'field =').staticElement;
PropertyAccessorElement setterElement =
@@ -562,14 +565,14 @@
expect(setterName.staticElement, same(setterElement));
}
- void test_visitMethodDeclaration_method_duplicate() {
+ test_visitMethodDeclaration_method_duplicate() async {
String code = r'''
class C {
void zzz(x) {}
void zzz(y) {}
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
MethodElement firstElement =
_findSimpleIdentifier(unit, code, 'zzz(x)').staticElement;
MethodElement secondElement =
@@ -582,7 +585,7 @@
expect(secondName.staticElement, same(secondElement));
}
- void test_visitMethodDeclaration_setter_duplicate() {
+ test_visitMethodDeclaration_setter_duplicate() async {
// https://github.com/dart-lang/sdk/issues/25601
String code = r'''
class C {
@@ -590,7 +593,7 @@
set zzz(y) {}
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
PropertyAccessorElement firstElement =
_findSimpleIdentifier(unit, code, 'zzz(x)').staticElement;
PropertyAccessorElement secondElement =
@@ -603,24 +606,24 @@
expect(secondName.staticElement, same(secondElement));
}
- void test_visitMethodDeclaration_unaryMinus() {
+ test_visitMethodDeclaration_unaryMinus() async {
String code = r'''
class C {
C operator -() => null;
C operator -(C other) => null;
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
}
- void test_visitPartDirective_notExistingSource() {
+ test_visitPartDirective_notExistingSource() async {
String code = r'''
part 'foo.bar';
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
// re-resolve
_cloneResolveUnit(unit);
// no other validations than built into DeclarationResolver
@@ -634,14 +637,14 @@
class StrongModeDeclarationResolverTest extends ResolverTestCase {
@override
void setUp() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
}
- void test_genericFunction_typeParameter() {
+ test_genericFunction_typeParameter() async {
String code = r'''
/*=T*/ max/*<T>*/(/*=T*/ x, /*=T*/ y) => null;
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
FunctionDeclaration node = _findSimpleIdentifier(unit, code, 'max').parent;
TypeParameter t = node.functionExpression.typeParameters.typeParameters[0];
@@ -659,13 +662,13 @@
expect(t.element, same(tElement));
}
- void test_genericMethod_typeParameter() {
+ test_genericMethod_typeParameter() async {
String code = r'''
class C {
/*=T*/ max/*<T>*/(/*=T*/ x, /*=T*/ y) => null;
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
MethodDeclaration node = _findSimpleIdentifier(unit, code, 'max').parent;
TypeParameter t = node.typeParameters.typeParameters[0];
diff --git a/pkg/analyzer/test/generated/element_resolver_test.dart b/pkg/analyzer/test/generated/element_resolver_test.dart
index 277a2c7..26c6ab0 100644
--- a/pkg/analyzer/test/generated/element_resolver_test.dart
+++ b/pkg/analyzer/test/generated/element_resolver_test.dart
@@ -4,9 +4,11 @@
library analyzer.test.generated.element_resolver_test;
+import 'dart:async';
+
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/ast/standard_ast_factory.dart';
+import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
@@ -36,7 +38,7 @@
@reflectiveTest
class ElementResolverCodeTest extends ResolverTestCase {
- void test_annotation_class_namedConstructor() {
+ test_annotation_class_namedConstructor() async {
addNamedSource(
'/a.dart',
r'''
@@ -44,7 +46,7 @@
const A.named();
}
''');
- _validateAnnotation('', '@A.named()', (SimpleIdentifier name1,
+ await _validateAnnotation('', '@A.named()', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -68,7 +70,7 @@
});
}
- void test_annotation_class_prefixed_namedConstructor() {
+ test_annotation_class_prefixed_namedConstructor() async {
addNamedSource(
'/a.dart',
r'''
@@ -76,7 +78,7 @@
const A.named();
}
''');
- _validateAnnotation('as p', '@p.A.named()', (SimpleIdentifier name1,
+ await _validateAnnotation('as p', '@p.A.named()', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -102,7 +104,7 @@
});
}
- void test_annotation_class_prefixed_staticConstField() {
+ test_annotation_class_prefixed_staticConstField() async {
addNamedSource(
'/a.dart',
r'''
@@ -110,7 +112,7 @@
static const V = 0;
}
''');
- _validateAnnotation('as p', '@p.A.V', (SimpleIdentifier name1,
+ await _validateAnnotation('as p', '@p.A.V', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -134,7 +136,7 @@
});
}
- void test_annotation_class_prefixed_unnamedConstructor() {
+ test_annotation_class_prefixed_unnamedConstructor() async {
addNamedSource(
'/a.dart',
r'''
@@ -142,7 +144,7 @@
const A();
}
''');
- _validateAnnotation('as p', '@p.A', (SimpleIdentifier name1,
+ await _validateAnnotation('as p', '@p.A', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -164,7 +166,7 @@
});
}
- void test_annotation_class_staticConstField() {
+ test_annotation_class_staticConstField() async {
addNamedSource(
'/a.dart',
r'''
@@ -172,7 +174,7 @@
static const V = 0;
}
''');
- _validateAnnotation('', '@A.V', (SimpleIdentifier name1,
+ await _validateAnnotation('', '@A.V', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -194,7 +196,7 @@
});
}
- void test_annotation_class_unnamedConstructor() {
+ test_annotation_class_unnamedConstructor() async {
addNamedSource(
'/a.dart',
r'''
@@ -202,7 +204,7 @@
const A();
}
''');
- _validateAnnotation('', '@A', (SimpleIdentifier name1,
+ await _validateAnnotation('', '@A', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -222,13 +224,13 @@
});
}
- void test_annotation_topLevelVariable() {
+ test_annotation_topLevelVariable() async {
addNamedSource(
'/a.dart',
r'''
const V = 0;
''');
- _validateAnnotation('', '@V', (SimpleIdentifier name1,
+ await _validateAnnotation('', '@V', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -249,13 +251,13 @@
});
}
- void test_annotation_topLevelVariable_prefixed() {
+ test_annotation_topLevelVariable_prefixed() async {
addNamedSource(
'/a.dart',
r'''
const V = 0;
''');
- _validateAnnotation('as p', '@p.V', (SimpleIdentifier name1,
+ await _validateAnnotation('as p', '@p.V', (SimpleIdentifier name1,
SimpleIdentifier name2,
SimpleIdentifier name3,
Element annotationElement) {
@@ -278,12 +280,12 @@
});
}
- void _validateAnnotation(
+ Future<Null> _validateAnnotation(
String annotationPrefix,
String annotationText,
validator(SimpleIdentifier name1, SimpleIdentifier name2,
- SimpleIdentifier name3, Element annotationElement)) {
- CompilationUnit unit = resolveSource('''
+ SimpleIdentifier name3, Element annotationElement)) async {
+ CompilationUnit unit = await resolveSource('''
import 'a.dart' $annotationPrefix;
$annotationText
class C {}
@@ -387,7 +389,7 @@
_resolver = _createResolver();
}
- void test_lookUpMethodInInterfaces() {
+ test_lookUpMethodInInterfaces() async {
InterfaceType intType = _typeProvider.intType;
//
// abstract class A { int operator[](int index); }
@@ -422,7 +424,7 @@
_listener.assertNoErrors();
}
- void test_visitAssignmentExpression_compound() {
+ test_visitAssignmentExpression_compound() async {
InterfaceType intType = _typeProvider.intType;
SimpleIdentifier leftHandSide = AstTestFactory.identifier3("a");
leftHandSide.staticType = intType;
@@ -434,7 +436,7 @@
_listener.assertNoErrors();
}
- void test_visitAssignmentExpression_simple() {
+ test_visitAssignmentExpression_simple() async {
AssignmentExpression expression = AstTestFactory.assignmentExpression(
AstTestFactory.identifier3("x"),
TokenType.EQ,
@@ -444,7 +446,7 @@
_listener.assertNoErrors();
}
- void test_visitBinaryExpression_bangEq() {
+ test_visitBinaryExpression_bangEq() async {
// String i;
// var j;
// i == j
@@ -464,7 +466,7 @@
_listener.assertNoErrors();
}
- void test_visitBinaryExpression_eq() {
+ test_visitBinaryExpression_eq() async {
// String i;
// var j;
// i == j
@@ -483,7 +485,7 @@
_listener.assertNoErrors();
}
- void test_visitBinaryExpression_plus() {
+ test_visitBinaryExpression_plus() async {
// num i;
// var j;
// i + j
@@ -498,7 +500,7 @@
_listener.assertNoErrors();
}
- void test_visitBinaryExpression_plus_propagatedElement() {
+ test_visitBinaryExpression_plus_propagatedElement() async {
// var i = 1;
// var j;
// i + j
@@ -513,7 +515,7 @@
_listener.assertNoErrors();
}
- void test_visitBreakStatement_withLabel() {
+ test_visitBreakStatement_withLabel() async {
// loop: while (true) {
// break loop;
// }
@@ -530,13 +532,13 @@
_listener.assertNoErrors();
}
- void test_visitBreakStatement_withoutLabel() {
+ test_visitBreakStatement_withoutLabel() async {
BreakStatement statement = AstTestFactory.breakStatement();
_resolveStatement(statement, null, null);
_listener.assertNoErrors();
}
- void test_visitCommentReference_prefixedIdentifier_class_getter() {
+ test_visitCommentReference_prefixedIdentifier_class_getter() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
// set accessors
String propName = "p";
@@ -559,7 +561,7 @@
_listener.assertNoErrors();
}
- void test_visitCommentReference_prefixedIdentifier_class_method() {
+ test_visitCommentReference_prefixedIdentifier_class_method() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
// set method
MethodElement method =
@@ -579,7 +581,7 @@
_listener.assertNoErrors();
}
- void test_visitCommentReference_prefixedIdentifier_class_operator() {
+ test_visitCommentReference_prefixedIdentifier_class_operator() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
// set method
MethodElement method =
@@ -599,7 +601,7 @@
_listener.assertNoErrors();
}
- void test_visitConstructorName_named() {
+ test_visitConstructorName_named() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String constructorName = "a";
ConstructorElement constructor =
@@ -612,7 +614,7 @@
_listener.assertNoErrors();
}
- void test_visitConstructorName_unnamed() {
+ test_visitConstructorName_unnamed() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String constructorName = null;
ConstructorElement constructor =
@@ -625,7 +627,7 @@
_listener.assertNoErrors();
}
- void test_visitContinueStatement_withLabel() {
+ test_visitContinueStatement_withLabel() async {
// loop: while (true) {
// continue loop;
// }
@@ -643,13 +645,13 @@
_listener.assertNoErrors();
}
- void test_visitContinueStatement_withoutLabel() {
+ test_visitContinueStatement_withoutLabel() async {
ContinueStatement statement = AstTestFactory.continueStatement();
_resolveStatement(statement, null, null);
_listener.assertNoErrors();
}
- void test_visitEnumDeclaration() {
+ test_visitEnumDeclaration() async {
CompilationUnitElementImpl compilationUnitElement =
ElementFactory.compilationUnit('foo.dart');
EnumElementImpl enumElement =
@@ -670,7 +672,7 @@
expect(metadata[0].element, annotationNode.element);
}
- void test_visitExportDirective_noCombinators() {
+ test_visitExportDirective_noCombinators() async {
ExportDirective directive = AstTestFactory.exportDirective2(null);
directive.element = ElementFactory
.exportFor(ElementFactory.library(_definingLibrary.context, "lib"));
@@ -678,7 +680,7 @@
_listener.assertNoErrors();
}
- void test_visitFieldFormalParameter() {
+ test_visitFieldFormalParameter() async {
String fieldName = "f";
InterfaceType intType = _typeProvider.intType;
FieldElementImpl fieldElement =
@@ -697,7 +699,7 @@
same(intType));
}
- void test_visitImportDirective_noCombinators_noPrefix() {
+ test_visitImportDirective_noCombinators_noPrefix() async {
ImportDirective directive = AstTestFactory.importDirective3(null, null);
directive.element = ElementFactory.importFor(
ElementFactory.library(_definingLibrary.context, "lib"), null);
@@ -705,7 +707,7 @@
_listener.assertNoErrors();
}
- void test_visitImportDirective_noCombinators_prefix() {
+ test_visitImportDirective_noCombinators_prefix() async {
String prefixName = "p";
ImportElement importElement = ElementFactory.importFor(
ElementFactory.library(_definingLibrary.context, "lib"),
@@ -718,7 +720,7 @@
_listener.assertNoErrors();
}
- void test_visitImportDirective_withCombinators() {
+ test_visitImportDirective_withCombinators() async {
ShowCombinator combinator = AstTestFactory.showCombinator2(["A", "B", "C"]);
ImportDirective directive =
AstTestFactory.importDirective3(null, null, [combinator]);
@@ -747,7 +749,7 @@
_listener.assertNoErrors();
}
- void test_visitIndexExpression_get() {
+ test_visitIndexExpression_get() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
InterfaceType intType = _typeProvider.intType;
MethodElement getter =
@@ -761,7 +763,7 @@
_listener.assertNoErrors();
}
- void test_visitIndexExpression_set() {
+ test_visitIndexExpression_set() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
InterfaceType intType = _typeProvider.intType;
MethodElement setter =
@@ -777,7 +779,7 @@
_listener.assertNoErrors();
}
- void test_visitInstanceCreationExpression_named() {
+ test_visitInstanceCreationExpression_named() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String constructorName = "a";
ConstructorElement constructor =
@@ -793,7 +795,7 @@
_listener.assertNoErrors();
}
- void test_visitInstanceCreationExpression_unnamed() {
+ test_visitInstanceCreationExpression_unnamed() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String constructorName = null;
ConstructorElement constructor =
@@ -809,7 +811,7 @@
_listener.assertNoErrors();
}
- void test_visitInstanceCreationExpression_unnamed_namedParameter() {
+ test_visitInstanceCreationExpression_unnamed_namedParameter() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String constructorName = null;
ConstructorElementImpl constructor =
@@ -836,7 +838,7 @@
_listener.assertNoErrors();
}
- void test_visitMethodInvocation() {
+ test_visitMethodInvocation() async {
InterfaceType numType = _typeProvider.numType;
SimpleIdentifier left = AstTestFactory.identifier3("i");
left.staticType = numType;
@@ -849,7 +851,7 @@
_listener.assertNoErrors();
}
- void test_visitMethodInvocation_namedParameter() {
+ test_visitMethodInvocation_namedParameter() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String methodName = "m";
String parameterName = "p";
@@ -874,7 +876,7 @@
_listener.assertNoErrors();
}
- void test_visitPostfixExpression() {
+ test_visitPostfixExpression() async {
InterfaceType numType = _typeProvider.numType;
SimpleIdentifier operand = AstTestFactory.identifier3("i");
operand.staticType = numType;
@@ -885,7 +887,7 @@
_listener.assertNoErrors();
}
- void test_visitPrefixedIdentifier_dynamic() {
+ test_visitPrefixedIdentifier_dynamic() async {
DartType dynamicType = _typeProvider.dynamicType;
SimpleIdentifier target = AstTestFactory.identifier3("a");
VariableElementImpl variable = ElementFactory.localVariableElement(target);
@@ -900,7 +902,7 @@
_listener.assertNoErrors();
}
- void test_visitPrefixedIdentifier_nonDynamic() {
+ test_visitPrefixedIdentifier_nonDynamic() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String getterName = "b";
PropertyAccessorElement getter =
@@ -919,7 +921,7 @@
_listener.assertNoErrors();
}
- void test_visitPrefixedIdentifier_staticClassMember_getter() {
+ test_visitPrefixedIdentifier_staticClassMember_getter() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
// set accessors
String propName = "b";
@@ -941,7 +943,7 @@
_listener.assertNoErrors();
}
- void test_visitPrefixedIdentifier_staticClassMember_method() {
+ test_visitPrefixedIdentifier_staticClassMember_method() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
// set methods
String propName = "m";
@@ -963,7 +965,7 @@
_listener.assertNoErrors();
}
- void test_visitPrefixedIdentifier_staticClassMember_setter() {
+ test_visitPrefixedIdentifier_staticClassMember_setter() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
// set accessors
String propName = "b";
@@ -987,7 +989,7 @@
_listener.assertNoErrors();
}
- void test_visitPrefixExpression() {
+ test_visitPrefixExpression() async {
InterfaceType numType = _typeProvider.numType;
SimpleIdentifier operand = AstTestFactory.identifier3("i");
operand.staticType = numType;
@@ -998,7 +1000,7 @@
_listener.assertNoErrors();
}
- void test_visitPropertyAccess_getter_identifier() {
+ test_visitPropertyAccess_getter_identifier() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String getterName = "b";
PropertyAccessorElement getter =
@@ -1012,7 +1014,7 @@
_listener.assertNoErrors();
}
- void test_visitPropertyAccess_getter_super() {
+ test_visitPropertyAccess_getter_super() async {
//
// class A {
// int get b;
@@ -1042,7 +1044,7 @@
_listener.assertNoErrors();
}
- void test_visitPropertyAccess_setter_this() {
+ test_visitPropertyAccess_setter_this() async {
ClassElementImpl classA = ElementFactory.classElement2("A");
String setterName = "b";
PropertyAccessorElement setter =
@@ -1058,7 +1060,7 @@
_listener.assertNoErrors();
}
- void test_visitSimpleIdentifier_classScope() {
+ test_visitSimpleIdentifier_classScope() async {
InterfaceType doubleType = _typeProvider.doubleType;
String fieldName = "NAN";
SimpleIdentifier node = AstTestFactory.identifier3(fieldName);
@@ -1067,7 +1069,7 @@
_listener.assertNoErrors();
}
- void test_visitSimpleIdentifier_dynamic() {
+ test_visitSimpleIdentifier_dynamic() async {
SimpleIdentifier node = AstTestFactory.identifier3("dynamic");
_resolveIdentifier(node);
expect(node.staticElement, same(_typeProvider.dynamicType.element));
@@ -1075,14 +1077,14 @@
_listener.assertNoErrors();
}
- void test_visitSimpleIdentifier_lexicalScope() {
+ test_visitSimpleIdentifier_lexicalScope() async {
SimpleIdentifier node = AstTestFactory.identifier3("i");
VariableElementImpl element = ElementFactory.localVariableElement(node);
expect(_resolveIdentifier(node, [element]), same(element));
_listener.assertNoErrors();
}
- void test_visitSimpleIdentifier_lexicalScope_field_setter() {
+ test_visitSimpleIdentifier_lexicalScope_field_setter() async {
InterfaceType intType = _typeProvider.intType;
ClassElementImpl classA = ElementFactory.classElement2("A");
String fieldName = "a";
@@ -1101,7 +1103,7 @@
_listener.assertNoErrors();
}
- void test_visitSuperConstructorInvocation() {
+ test_visitSuperConstructorInvocation() async {
ClassElementImpl superclass = ElementFactory.classElement2("A");
ConstructorElementImpl superConstructor =
ElementFactory.constructorElement2(superclass, null);
@@ -1121,7 +1123,7 @@
_listener.assertNoErrors();
}
- void test_visitSuperConstructorInvocation_namedParameter() {
+ test_visitSuperConstructorInvocation_namedParameter() async {
ClassElementImpl superclass = ElementFactory.classElement2("A");
ConstructorElementImpl superConstructor =
ElementFactory.constructorElement2(superclass, null);
diff --git a/pkg/analyzer/test/generated/error_suppression_test.dart b/pkg/analyzer/test/generated/error_suppression_test.dart
index 20a3312..ea353b2 100644
--- a/pkg/analyzer/test/generated/error_suppression_test.dart
+++ b/pkg/analyzer/test/generated/error_suppression_test.dart
@@ -12,187 +12,194 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(ErrorSuppressionTest);
+ defineReflectiveTests(ErrorSuppressionTest_Driver);
});
}
@reflectiveTest
class ErrorSuppressionTest extends ResolverTestCase {
- void test_error_code_mismatch() {
+ test_error_code_mismatch() async {
Source source = addSource('''
// ignore: const_initialized_with_non_constant_value
int x = '';
const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticTypeWarningCode.INVALID_ASSIGNMENT,
CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]);
}
- void test_ignore_first() {
+ test_ignore_first() async {
Source source = addSource('''
// ignore: invalid_assignment
int x = '';
// ... but no ignore here ...
const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
}
- void test_ignore_first_trailing() {
+ test_ignore_first_trailing() async {
Source source = addSource('''
int x = ''; // ignore: invalid_assignment
// ... but no ignore here ...
const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
}
- void test_ignore_only_trailing() {
+ test_ignore_only_trailing() async {
Source source = addSource('''
int x = ''; // ignore: invalid_assignment
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
}
- void test_ignore_second() {
+ test_ignore_second() async {
Source source = addSource('''
//INVALID_ASSIGNMENT
int x = '';
// ignore: const_initialized_with_non_constant_value
const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_ignore_second_trailing() {
+ test_ignore_second_trailing() async {
Source source = addSource('''
//INVALID_ASSIGNMENT
int x = '';
const y = x; // ignore: const_initialized_with_non_constant_value
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_ignore_upper_case() {
+ test_ignore_upper_case() async {
Source source = addSource('''
int x = ''; // ignore: INVALID_ASSIGNMENT
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
}
- void test_invalid_error_code() {
+ test_invalid_error_code() async {
Source source = addSource('''
// ignore: right_format_wrong_code
int x = '';
const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticTypeWarningCode.INVALID_ASSIGNMENT,
CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]);
}
- void test_missing_error_codes() {
+ test_missing_error_codes() async {
Source source = addSource('''
int x = 3;
// ignore:
const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticTypeWarningCode.INVALID_ASSIGNMENT,
CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]);
}
- void test_missing_metadata_suffix() {
+ test_missing_metadata_suffix() async {
Source source = addSource('''
// ignore invalid_assignment
String y = 3; //INVALID_ASSIGNMENT
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_multiple_comments() {
+ test_multiple_comments() async {
Source source = addSource('''
int x = ''; //This is the first comment...
// ignore: const_initialized_with_non_constant_value
const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_multiple_ignores() {
+ test_multiple_ignores() async {
Source source = addSource('''
int x = 3;
// ignore: invalid_assignment, const_initialized_with_non_constant_value
const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
}
- void test_multiple_ignores_traling() {
+ test_multiple_ignores_traling() async {
Source source = addSource('''
int x = 3;
const String y = x; // ignore: invalid_assignment, const_initialized_with_non_constant_value
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
}
- void test_multiple_ignores_whitespace_variant_1() {
+ test_multiple_ignores_whitespace_variant_1() async {
Source source = addSource('''
int x = 3;
//ignore:invalid_assignment,const_initialized_with_non_constant_value
const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
}
- void test_multiple_ignores_whitespace_variant_2() {
+ test_multiple_ignores_whitespace_variant_2() async {
Source source = addSource('''
int x = 3;
//ignore: invalid_assignment,const_initialized_with_non_constant_value
const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
}
- void test_multiple_ignores_whitespace_variant_3() {
+ test_multiple_ignores_whitespace_variant_3() async {
Source source = addSource('''
int x = 3;
// ignore: invalid_assignment,const_initialized_with_non_constant_value
const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
}
- void test_no_ignores() {
+ test_no_ignores() async {
Source source = addSource('''
int x = ''; //INVALID_ASSIGNMENT
const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticTypeWarningCode.INVALID_ASSIGNMENT,
CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]);
}
}
+
+@reflectiveTest
+class ErrorSuppressionTest_Driver extends ErrorSuppressionTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
diff --git a/pkg/analyzer/test/generated/hint_code_driver_test.dart b/pkg/analyzer/test/generated/hint_code_driver_test.dart
new file mode 100644
index 0000000..c7a7758
--- /dev/null
+++ b/pkg/analyzer/test/generated/hint_code_driver_test.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2017, 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:test_reflective_loader/test_reflective_loader.dart';
+
+import 'hint_code_test.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(HintCodeTest_Driver);
+ });
+}
+
+@reflectiveTest
+class HintCodeTest_Driver extends HintCodeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart
index 4e5009f..52b0feb 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -12,7 +12,6 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'analysis_context_factory.dart';
import 'resolver_test_case.dart';
main() {
@@ -25,8 +24,10 @@
class HintCodeTest extends ResolverTestCase {
@override
void reset() {
- analysisContext2 = AnalysisContextFactory.contextWithCoreAndPackages({
- 'package:meta/meta.dart': r'''
+ super.resetWith(packages: [
+ [
+ 'meta',
+ r'''
library meta;
const _Factory factory = const _Factory();
@@ -55,17 +56,21 @@
final String reason;
const _Required([this.reason]));
}
-''',
- 'package:js/js.dart': r'''
+'''
+ ],
+ [
+ 'js',
+ r'''
library js;
class JS {
const JS([String js]) { }
}
'''
- }, resourceProvider: resourceProvider);
+ ]
+ ]);
}
- void test_abstractSuperMemberReference_getter() {
+ test_abstractSuperMemberReference_getter() async {
Source source = addSource(r'''
abstract class A {
int get test;
@@ -77,12 +82,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.ABSTRACT_SUPER_MEMBER_REFERENCE]);
verify([source]);
}
- void test_abstractSuperMemberReference_method_invocation() {
+ test_abstractSuperMemberReference_method_invocation() async {
Source source = addSource(r'''
abstract class A {
void test();
@@ -93,12 +98,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.ABSTRACT_SUPER_MEMBER_REFERENCE]);
verify([source]);
}
- void test_abstractSuperMemberReference_method_reference() {
+ test_abstractSuperMemberReference_method_reference() async {
Source source = addSource(r'''
abstract class A {
void test();
@@ -109,12 +114,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.ABSTRACT_SUPER_MEMBER_REFERENCE]);
verify([source]);
}
- void test_abstractSuperMemberReference_setter() {
+ test_abstractSuperMemberReference_setter() async {
Source source = addSource(r'''
abstract class A {
void set test(int v);
@@ -125,12 +130,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.ABSTRACT_SUPER_MEMBER_REFERENCE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_functionType() {
+ test_argumentTypeNotAssignable_functionType() async {
Source source = addSource(r'''
m() {
var a = new A();
@@ -139,42 +144,42 @@
class A {
n(void f(int i)) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_message() {
+ test_argumentTypeNotAssignable_message() async {
// The implementation of HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE assumes that
// StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE has the same message.
expect(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE.message,
HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE.message);
}
- void test_argumentTypeNotAssignable_type() {
+ test_argumentTypeNotAssignable_type() async {
Source source = addSource(r'''
m() {
var i = '';
n(i);
}
n(int i) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_canBeNullAfterNullAware_false_methodInvocation() {
+ test_canBeNullAfterNullAware_false_methodInvocation() async {
Source source = addSource(r'''
m(x) {
x?.a()?.b();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_canBeNullAfterNullAware_false_null() {
+ test_canBeNullAfterNullAware_false_null() async {
Source source = addSource(r'''
m(x) {
x?.a.hashCode;
@@ -185,217 +190,217 @@
x?.b().toString();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_canBeNullAfterNullAware_false_propertyAccess() {
+ test_canBeNullAfterNullAware_false_propertyAccess() async {
Source source = addSource(r'''
m(x) {
x?.a?.b;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_canBeNullAfterNullAware_methodInvocation() {
+ test_canBeNullAfterNullAware_methodInvocation() async {
Source source = addSource(r'''
m(x) {
x?.a.b();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
verify([source]);
}
- void test_canBeNullAfterNullAware_parenthesized() {
+ test_canBeNullAfterNullAware_parenthesized() async {
Source source = addSource(r'''
m(x) {
(x?.a).b;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
verify([source]);
}
- void test_canBeNullAfterNullAware_propertyAccess() {
+ test_canBeNullAfterNullAware_propertyAccess() async {
Source source = addSource(r'''
m(x) {
x?.a.b;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
verify([source]);
}
- void test_deadCode_deadBlock_conditionalElse() {
+ test_deadCode_deadBlock_conditionalElse() async {
Source source = addSource(r'''
f() {
true ? 1 : 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_conditionalElse_nested() {
+ test_deadCode_deadBlock_conditionalElse_nested() async {
// test that a dead else-statement can't generate additional violations
Source source = addSource(r'''
f() {
true ? true : false && false;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_conditionalIf() {
+ test_deadCode_deadBlock_conditionalIf() async {
Source source = addSource(r'''
f() {
false ? 1 : 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_conditionalIf_nested() {
+ test_deadCode_deadBlock_conditionalIf_nested() async {
// test that a dead then-statement can't generate additional violations
Source source = addSource(r'''
f() {
false ? false && false : true;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_else() {
+ test_deadCode_deadBlock_else() async {
Source source = addSource(r'''
f() {
if(true) {} else {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_else_nested() {
+ test_deadCode_deadBlock_else_nested() async {
// test that a dead else-statement can't generate additional violations
Source source = addSource(r'''
f() {
if(true) {} else {if (false) {}}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_if() {
+ test_deadCode_deadBlock_if() async {
Source source = addSource(r'''
f() {
if(false) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_if_nested() {
+ test_deadCode_deadBlock_if_nested() async {
// test that a dead then-statement can't generate additional violations
Source source = addSource(r'''
f() {
if(false) {if(false) {}}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_while() {
+ test_deadCode_deadBlock_while() async {
Source source = addSource(r'''
f() {
while(false) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadBlock_while_nested() {
+ test_deadCode_deadBlock_while_nested() async {
// test that a dead while body can't generate additional violations
Source source = addSource(r'''
f() {
while(false) {if(false) {}}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadCatch_catchFollowingCatch() {
+ test_deadCode_deadCatch_catchFollowingCatch() async {
Source source = addSource(r'''
class A {}
f() {
try {} catch (e) {} catch (e) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
verify([source]);
}
- void test_deadCode_deadCatch_catchFollowingCatch_nested() {
+ test_deadCode_deadCatch_catchFollowingCatch_nested() async {
// test that a dead catch clause can't generate additional violations
Source source = addSource(r'''
class A {}
f() {
try {} catch (e) {} catch (e) {if(false) {}}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
verify([source]);
}
- void test_deadCode_deadCatch_catchFollowingCatch_object() {
+ test_deadCode_deadCatch_catchFollowingCatch_object() async {
Source source = addSource(r'''
f() {
try {} on Object catch (e) {} catch (e) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
verify([source]);
}
- void test_deadCode_deadCatch_catchFollowingCatch_object_nested() {
+ test_deadCode_deadCatch_catchFollowingCatch_object_nested() async {
// test that a dead catch clause can't generate additional violations
Source source = addSource(r'''
f() {
try {} on Object catch (e) {} catch (e) {if(false) {}}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
verify([source]);
}
- void test_deadCode_deadCatch_onCatchSubtype() {
+ test_deadCode_deadCatch_onCatchSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {}
f() {
try {} on A catch (e) {} on B catch (e) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]);
verify([source]);
}
- void test_deadCode_deadCatch_onCatchSubtype_nested() {
+ test_deadCode_deadCatch_onCatchSubtype_nested() async {
// test that a dead catch clause can't generate additional violations
Source source = addSource(r'''
class A {}
@@ -403,12 +408,12 @@
f() {
try {} on A catch (e) {} on B catch (e) {if(false) {}}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]);
verify([source]);
}
- void test_deadCode_deadFinalReturnInCase() {
+ test_deadCode_deadFinalReturnInCase() async {
Source source = addSource(r'''
f() {
switch (true) {
@@ -423,12 +428,12 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadFinalStatementInCase() {
+ test_deadCode_deadFinalStatementInCase() async {
Source source = addSource(r'''
f() {
switch (true) {
@@ -443,55 +448,55 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
// A single dead statement at the end of a switch case that is not a
// terminating statement will yield two errors.
+ await computeAnalysisResult(source);
assertErrors(source,
[HintCode.DEAD_CODE, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
verify([source]);
}
- void test_deadCode_deadOperandLHS_and() {
+ test_deadCode_deadOperandLHS_and() async {
Source source = addSource(r'''
f() {
bool b = false && false;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadOperandLHS_and_nested() {
+ test_deadCode_deadOperandLHS_and_nested() async {
Source source = addSource(r'''
f() {
bool b = false && (false && false);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadOperandLHS_or() {
+ test_deadCode_deadOperandLHS_or() async {
Source source = addSource(r'''
f() {
bool b = true || true;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_deadOperandLHS_or_nested() {
+ test_deadCode_deadOperandLHS_or_nested() async {
Source source = addSource(r'''
f() {
bool b = true || (false && false);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterBreak_inDefaultCase() {
+ test_deadCode_statementAfterBreak_inDefaultCase() async {
Source source = addSource(r'''
f(v) {
switch(v) {
@@ -501,12 +506,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterBreak_inForEachStatement() {
+ test_deadCode_statementAfterBreak_inForEachStatement() async {
Source source = addSource(r'''
f() {
var list;
@@ -515,12 +520,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterBreak_inForStatement() {
+ test_deadCode_statementAfterBreak_inForStatement() async {
Source source = addSource(r'''
f() {
for(;;) {
@@ -528,12 +533,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterBreak_inSwitchCase() {
+ test_deadCode_statementAfterBreak_inSwitchCase() async {
Source source = addSource(r'''
f(v) {
switch(v) {
@@ -542,12 +547,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterBreak_inWhileStatement() {
+ test_deadCode_statementAfterBreak_inWhileStatement() async {
Source source = addSource(r'''
f(v) {
while(v) {
@@ -555,12 +560,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterContinue_inForEachStatement() {
+ test_deadCode_statementAfterContinue_inForEachStatement() async {
Source source = addSource(r'''
f() {
var list;
@@ -569,12 +574,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterContinue_inForStatement() {
+ test_deadCode_statementAfterContinue_inForStatement() async {
Source source = addSource(r'''
f() {
for(;;) {
@@ -582,12 +587,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterContinue_inWhileStatement() {
+ test_deadCode_statementAfterContinue_inWhileStatement() async {
Source source = addSource(r'''
f(v) {
while(v) {
@@ -595,12 +600,12 @@
var a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterExitingIf_returns() {
+ test_deadCode_statementAfterExitingIf_returns() async {
Source source = addSource(r'''
f() {
if (1 > 2) {
@@ -610,12 +615,12 @@
}
var one = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterRethrow() {
+ test_deadCode_statementAfterRethrow() async {
Source source = addSource(r'''
f() {
try {
@@ -625,24 +630,24 @@
var two = 2;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterReturn_function() {
+ test_deadCode_statementAfterReturn_function() async {
Source source = addSource(r'''
f() {
var one = 1;
return;
var two = 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterReturn_ifStatement() {
+ test_deadCode_statementAfterReturn_ifStatement() async {
Source source = addSource(r'''
f(bool b) {
if(b) {
@@ -651,12 +656,12 @@
var two = 2;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterReturn_method() {
+ test_deadCode_statementAfterReturn_method() async {
Source source = addSource(r'''
class A {
m() {
@@ -665,24 +670,24 @@
var two = 2;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterReturn_nested() {
+ test_deadCode_statementAfterReturn_nested() async {
Source source = addSource(r'''
f() {
var one = 1;
return;
if(false) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterReturn_twoReturns() {
+ test_deadCode_statementAfterReturn_twoReturns() async {
Source source = addSource(r'''
f() {
var one = 1;
@@ -691,24 +696,24 @@
return;
var three = 3;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deadCode_statementAfterThrow() {
+ test_deadCode_statementAfterThrow() async {
Source source = addSource(r'''
f() {
var one = 1;
throw 'Stop here';
var two = 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_assignment() {
+ test_deprecatedAnnotationUse_assignment() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -718,12 +723,12 @@
A b;
a += b;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_call() {
+ test_deprecatedAnnotationUse_call() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -733,36 +738,36 @@
a();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_deprecated() {
+ test_deprecatedAnnotationUse_deprecated() async {
Source source = addSource(r'''
class A {
@deprecated
m() {}
n() {m();}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_Deprecated() {
+ test_deprecatedAnnotationUse_Deprecated() async {
Source source = addSource(r'''
class A {
@Deprecated('0.9')
m() {}
n() {m();}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_export() {
+ test_deprecatedAnnotationUse_export() async {
Source source = addSource("export 'deprecated_library.dart';");
addNamedSource(
"/deprecated_library.dart",
@@ -770,12 +775,12 @@
@deprecated
library deprecated_library;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_field() {
+ test_deprecatedAnnotationUse_field() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -784,12 +789,12 @@
f(A a) {
return a.x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_getter() {
+ test_deprecatedAnnotationUse_getter() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -798,12 +803,12 @@
f(A a) {
return a.m;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_import() {
+ test_deprecatedAnnotationUse_import() async {
Source source = addSource(r'''
import 'deprecated_library.dart';
f(A a) {}''');
@@ -813,12 +818,12 @@
@deprecated
library deprecated_library;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_indexExpression() {
+ test_deprecatedAnnotationUse_indexExpression() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -827,12 +832,12 @@
f(A a) {
return a[1];
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_instanceCreation() {
+ test_deprecatedAnnotationUse_instanceCreation() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -841,12 +846,12 @@
f() {
A a = new A(1);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_instanceCreation_namedConstructor() {
+ test_deprecatedAnnotationUse_instanceCreation_namedConstructor() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -855,23 +860,23 @@
f() {
A a = new A.named(1);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_named() {
+ test_deprecatedAnnotationUse_named() async {
Source source = addSource(r'''
class A {
m({@deprecated int x}) {}
n() {m(x: 1);}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_operator() {
+ test_deprecatedAnnotationUse_operator() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -881,23 +886,23 @@
A b;
return a + b;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_positional() {
+ test_deprecatedAnnotationUse_positional() async {
Source source = addSource(r'''
class A {
m([@deprecated int x]) {}
n() {m(1);}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_setter() {
+ test_deprecatedAnnotationUse_setter() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -906,12 +911,12 @@
f(A a) {
return a.s = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_superConstructor() {
+ test_deprecatedAnnotationUse_superConstructor() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -920,12 +925,12 @@
class B extends A {
B() : super() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_deprecatedAnnotationUse_superConstructor_namedConstructor() {
+ test_deprecatedAnnotationUse_superConstructor_namedConstructor() async {
Source source = addSource(r'''
class A {
@deprecated
@@ -934,32 +939,32 @@
class B extends A {
B() : super.named() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
verify([source]);
}
- void test_divisionOptimization_double() {
+ test_divisionOptimization_double() async {
Source source = addSource(r'''
f(double x, double y) {
var v = (x / y).toInt();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
verify([source]);
}
- void test_divisionOptimization_int() {
+ test_divisionOptimization_int() async {
Source source = addSource(r'''
f(int x, int y) {
var v = (x / y).toInt();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
verify([source]);
}
- void test_divisionOptimization_propagatedType() {
+ test_divisionOptimization_propagatedType() async {
// Tests the propagated type information of the '/' method
Source source = addSource(r'''
f(x, y) {
@@ -967,22 +972,22 @@
y = 1;
var v = (x / y).toInt();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
verify([source]);
}
- void test_divisionOptimization_wrappedBinaryExpression() {
+ test_divisionOptimization_wrappedBinaryExpression() async {
Source source = addSource(r'''
f(int x, int y) {
var v = (((x / y))).toInt();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
verify([source]);
}
- void test_duplicateImport() {
+ test_duplicateImport() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -993,12 +998,12 @@
r'''
library lib1;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DUPLICATE_IMPORT]);
verify([source]);
}
- void test_duplicateImport2() {
+ test_duplicateImport2() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -1010,13 +1015,13 @@
r'''
library lib1;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT]);
verify([source]);
}
- void test_duplicateImport3() {
+ test_duplicateImport3() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' as M show A hide B;
@@ -1028,12 +1033,12 @@
library lib1;
class A {}
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DUPLICATE_IMPORT]);
verify([source]);
}
- void test_factory__expr_return_null_OK() {
+ test_factory__expr_return_null_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1044,12 +1049,12 @@
class State { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_factory_abstract_OK() {
+ test_factory_abstract_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1060,12 +1065,12 @@
class State { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_factory_bad_return() {
+ test_factory_bad_return() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1078,12 +1083,12 @@
class State { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.INVALID_FACTORY_METHOD_IMPL]);
verify([source]);
}
- void test_factory_block_OK() {
+ test_factory_block_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1096,12 +1101,12 @@
class State { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_factory_block_return_null_OK() {
+ test_factory_block_return_null_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1114,12 +1119,12 @@
class State { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_factory_expr_OK() {
+ test_factory_expr_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1130,12 +1135,12 @@
class State { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_factory_misplaced_annotation() {
+ test_factory_misplaced_annotation() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1148,7 +1153,7 @@
@factory
main() { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
HintCode.INVALID_FACTORY_ANNOTATION,
HintCode.INVALID_FACTORY_ANNOTATION,
@@ -1157,7 +1162,7 @@
verify([source]);
}
- void test_factory_no_return_type_OK() {
+ test_factory_no_return_type_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1168,13 +1173,13 @@
}
}
''');
- computeLibrarySourceErrors(source);
// Null return types will get flagged elsewhere, no need to pile-on here.
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_factory_subclass_OK() {
+ test_factory_subclass_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1194,12 +1199,12 @@
class State { }
class MyState extends State { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_factory_void_return() {
+ test_factory_void_return() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1208,13 +1213,13 @@
void createState() {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.INVALID_FACTORY_METHOD_DECL]);
verify([source]);
}
- void test_importDeferredLibraryWithLoadFunction() {
- resolveWithErrors(<String>[
+ test_importDeferredLibraryWithLoadFunction() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
loadLibrary() {}
@@ -1228,7 +1233,7 @@
]);
}
- void test_invalidAssignment_instanceVariable() {
+ test_invalidAssignment_instanceVariable() async {
Source source = addSource(r'''
class A {
int x;
@@ -1239,31 +1244,31 @@
a.x = y;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.INVALID_ASSIGNMENT]);
verify([source]);
}
- void test_invalidAssignment_localVariable() {
+ test_invalidAssignment_localVariable() async {
Source source = addSource(r'''
f(var y) {
if(y is String) {
int x = y;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.INVALID_ASSIGNMENT]);
verify([source]);
}
- void test_invalidAssignment_message() {
+ test_invalidAssignment_message() async {
// The implementation of HintCode.INVALID_ASSIGNMENT assumes that
// StaticTypeWarningCode.INVALID_ASSIGNMENT has the same message.
expect(StaticTypeWarningCode.INVALID_ASSIGNMENT.message,
HintCode.INVALID_ASSIGNMENT.message);
}
- void test_invalidAssignment_staticVariable() {
+ test_invalidAssignment_staticVariable() async {
Source source = addSource(r'''
class A {
static int x;
@@ -1273,12 +1278,12 @@
A.x = y;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.INVALID_ASSIGNMENT]);
verify([source]);
}
- void test_invalidAssignment_variableDeclaration() {
+ test_invalidAssignment_variableDeclaration() async {
// 17971
Source source = addSource(r'''
class Point {
@@ -1293,12 +1298,12 @@
var p2 = new Point(10, 10);
int n = p1 + p2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.INVALID_ASSIGNMENT]);
verify([source]);
}
- void test_invalidUseOfProtectedMember_closure() {
+ test_invalidUseOfProtectedMember_closure() async {
Source source = addNamedSource(
'/lib1.dart',
r'''
@@ -1319,13 +1324,14 @@
print(leak);
}
''');
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
assertNoErrors(source);
verify([source, source2]);
}
- void test_invalidUseOfProtectedMember_field() {
+ test_invalidUseOfProtectedMember_field() async {
Source source = addNamedSource(
'/lib1.dart',
r'''
@@ -1344,13 +1350,14 @@
int b() => new A().a;
}
''');
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
assertNoErrors(source);
verify([source, source2]);
}
- void test_invalidUseOfProtectedMember_field_OK() {
+ test_invalidUseOfProtectedMember_field_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1360,12 +1367,12 @@
abstract class B implements A {
int b() => a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_function() {
+ test_invalidUseOfProtectedMember_function() async {
Source source = addNamedSource(
'/lib1.dart',
r'''
@@ -1384,13 +1391,14 @@
new A().a();
}
''');
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
assertNoErrors(source);
verify([source, source2]);
}
- void test_invalidUseOfProtectedMember_function_OK() {
+ test_invalidUseOfProtectedMember_function_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1401,12 +1409,12 @@
abstract class B implements A {
int b() => a();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_function_OK2() {
+ test_invalidUseOfProtectedMember_function_OK2() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1416,12 +1424,12 @@
main() {
new A().a();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_getter() {
+ test_invalidUseOfProtectedMember_getter() async {
Source source = addNamedSource(
'/lib1.dart',
r'''
@@ -1441,13 +1449,14 @@
int b() => a.a;
}
''');
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
assertNoErrors(source);
verify([source, source2]);
}
- void test_invalidUseOfProtectedMember_getter_OK() {
+ test_invalidUseOfProtectedMember_getter_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1457,12 +1466,12 @@
abstract class B implements A {
int b() => a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_in_docs_OK() {
+ test_invalidUseOfProtectedMember_in_docs_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1478,12 +1487,12 @@
/// OK: [A.a], [A.b], [A.c].
f() {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_message() {
+ test_invalidUseOfProtectedMember_message() async {
Source source = addNamedSource(
'/lib1.dart',
r'''
@@ -1502,13 +1511,13 @@
void b() => new A().a();
}
''');
- List<AnalysisError> errors = analysisContext2.computeErrors(source2);
- expect(errors, hasLength(1));
- expect(errors[0].errorCode, HintCode.INVALID_USE_OF_PROTECTED_MEMBER);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
+ assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
verify([source, source2]);
}
- void test_invalidUseOfProtectedMember_method_1() {
+ test_invalidUseOfProtectedMember_method_1() async {
Source source = addNamedSource(
'/lib1.dart',
r'''
@@ -1528,13 +1537,14 @@
}
''');
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
assertNoErrors(source);
verify([source, source2]);
}
- void test_invalidUseOfProtectedMember_method_OK() {
+ test_invalidUseOfProtectedMember_method_OK() async {
// https://github.com/dart-lang/linter/issues/257
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -1552,12 +1562,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_1() {
+ test_invalidUseOfProtectedMember_OK_1() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1567,12 +1577,12 @@
class B extends A {
void b() => a();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_2() {
+ test_invalidUseOfProtectedMember_OK_2() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1582,12 +1592,12 @@
class B extends Object with A {
void b() => a();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_3() {
+ test_invalidUseOfProtectedMember_OK_3() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1596,12 +1606,12 @@
class B extends A {
static m2(A a) => a.m1();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_4() {
+ test_invalidUseOfProtectedMember_OK_4() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1614,12 +1624,12 @@
main() {
new B().a();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_field() {
+ test_invalidUseOfProtectedMember_OK_field() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1630,12 +1640,12 @@
int b() => a;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_getter() {
+ test_invalidUseOfProtectedMember_OK_getter() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1646,12 +1656,12 @@
int b() => a;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_setter() {
+ test_invalidUseOfProtectedMember_OK_setter() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1664,12 +1674,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_OK_setter_2() {
+ test_invalidUseOfProtectedMember_OK_setter_2() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1681,12 +1691,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_setter() {
+ test_invalidUseOfProtectedMember_setter() async {
Source source = addNamedSource(
'/lib1.dart',
r'''
@@ -1708,13 +1718,14 @@
}
}
''');
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
assertNoErrors(source);
verify([source, source2]);
}
- void test_invalidUseOfProtectedMember_setter_OK() {
+ test_invalidUseOfProtectedMember_setter_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1726,12 +1737,12 @@
a = i;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidUseOfProtectedMember_topLevelVariable() {
+ test_invalidUseOfProtectedMember_topLevelVariable() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@protected
@@ -1739,50 +1750,50 @@
main() {
print(x);
}''');
- computeLibrarySourceErrors(source);
// TODO(brianwilkerson) This should produce a hint because the annotation is
// being applied to the wrong kind of declaration.
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_isDouble() {
+ test_isDouble() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.dart2jsHint = true;
- resetWithOptions(options);
+ resetWith(options: options);
Source source = addSource("var v = 1 is double;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.IS_DOUBLE]);
verify([source]);
}
@failingTest
- void test_isInt() {
+ test_isInt() async {
Source source = addSource("var v = 1 is int;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.IS_INT]);
verify([source]);
}
- void test_isNotDouble() {
+ test_isNotDouble() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.dart2jsHint = true;
- resetWithOptions(options);
+ resetWith(options: options);
Source source = addSource("var v = 1 is! double;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.IS_NOT_DOUBLE]);
verify([source]);
}
@failingTest
- void test_isNotInt() {
+ test_isNotInt() async {
Source source = addSource("var v = 1 is! int;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.IS_NOT_INT]);
verify([source]);
}
- void test_js_lib_OK() {
+ test_js_lib_OK() async {
Source source = addSource(r'''
@JS()
library foo;
@@ -1792,12 +1803,12 @@
@JS()
class A { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_missingJsLibAnnotation_class() {
+ test_missingJsLibAnnotation_class() async {
Source source = addSource(r'''
library foo;
@@ -1806,12 +1817,12 @@
@JS()
class A { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
verify([source]);
}
- void test_missingJsLibAnnotation_externalField() {
+ test_missingJsLibAnnotation_externalField() async {
// https://github.com/dart-lang/sdk/issues/26987
Source source = addSource(r'''
import 'package:js/js.dart';
@@ -1819,13 +1830,13 @@
@JS()
external dynamic exports;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[ParserErrorCode.EXTERNAL_FIELD, HintCode.MISSING_JS_LIB_ANNOTATION]);
verify([source]);
}
- void test_missingJsLibAnnotation_function() {
+ test_missingJsLibAnnotation_function() async {
Source source = addSource(r'''
library foo;
@@ -1834,12 +1845,12 @@
@JS('acxZIndex')
set _currentZIndex(int value) { }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
verify([source]);
}
- void test_missingJsLibAnnotation_method() {
+ test_missingJsLibAnnotation_method() async {
Source source = addSource(r'''
library foo;
@@ -1850,62 +1861,62 @@
void a() { }
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
verify([source]);
}
- void test_missingJsLibAnnotation_variable() {
+ test_missingJsLibAnnotation_variable() async {
Source source = addSource(r'''
import 'package:js/js.dart';
@JS()
dynamic variable;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
verify([source]);
}
- void test_missingReturn_async() {
+ test_missingReturn_async() async {
Source source = addSource('''
import 'dart:async';
Future<int> f() async {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_RETURN]);
verify([source]);
}
- void test_missingReturn_factory() {
+ test_missingReturn_factory() async {
Source source = addSource(r'''
class A {
factory A() {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_RETURN]);
verify([source]);
}
- void test_missingReturn_function() {
+ test_missingReturn_function() async {
Source source = addSource("int f() {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_RETURN]);
verify([source]);
}
- void test_missingReturn_method() {
+ test_missingReturn_method() async {
Source source = addSource(r'''
class A {
int m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_RETURN]);
verify([source]);
}
- void test_mustCallSuper() {
+ test_mustCallSuper() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1918,12 +1929,12 @@
{}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MUST_CALL_SUPER]);
verify([source]);
}
- void test_mustCallSuper_fromInterface() {
+ test_mustCallSuper_fromInterface() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1935,12 +1946,12 @@
void a() {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
verify([source]);
}
- void test_mustCallSuper_indirect() {
+ test_mustCallSuper_indirect() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1958,12 +1969,12 @@
void a() {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MUST_CALL_SUPER]);
verify([source]);
}
- void test_mustCallSuper_overridden() {
+ test_mustCallSuper_overridden() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -1977,177 +1988,177 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, []);
verify([source]);
}
- void test_nullAwareInCondition_assert() {
+ test_nullAwareInCondition_assert() async {
Source source = addSource(r'''
m(x) {
assert (x?.a);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_conditionalExpression() {
+ test_nullAwareInCondition_conditionalExpression() async {
Source source = addSource(r'''
m(x) {
return x?.a ? 0 : 1;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_do() {
+ test_nullAwareInCondition_do() async {
Source source = addSource(r'''
m(x) {
do {} while (x?.a);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_for() {
+ test_nullAwareInCondition_for() async {
Source source = addSource(r'''
m(x) {
for (var v = x; v?.a; v = v.next) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if() {
+ test_nullAwareInCondition_if() async {
Source source = addSource(r'''
m(x) {
if (x?.a) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_conditionalAnd_first() {
+ test_nullAwareInCondition_if_conditionalAnd_first() async {
Source source = addSource(r'''
m(x) {
if (x?.a && x.b) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_conditionalAnd_second() {
+ test_nullAwareInCondition_if_conditionalAnd_second() async {
Source source = addSource(r'''
m(x) {
if (x.a && x?.b) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_conditionalAnd_third() {
+ test_nullAwareInCondition_if_conditionalAnd_third() async {
Source source = addSource(r'''
m(x) {
if (x.a && x.b && x?.c) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_conditionalOr_first() {
+ test_nullAwareInCondition_if_conditionalOr_first() async {
Source source = addSource(r'''
m(x) {
if (x?.a || x.b) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_conditionalOr_second() {
+ test_nullAwareInCondition_if_conditionalOr_second() async {
Source source = addSource(r'''
m(x) {
if (x.a || x?.b) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_conditionalOr_third() {
+ test_nullAwareInCondition_if_conditionalOr_third() async {
Source source = addSource(r'''
m(x) {
if (x.a || x.b || x?.c) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_not() {
+ test_nullAwareInCondition_if_not() async {
Source source = addSource(r'''
m(x) {
if (!x?.a) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_if_parenthesized() {
+ test_nullAwareInCondition_if_parenthesized() async {
Source source = addSource(r'''
m(x) {
if ((x?.a)) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
- void test_nullAwareInCondition_while() {
+ test_nullAwareInCondition_while() async {
Source source = addSource(r'''
m(x) {
while (x?.a) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
verify([source]);
}
@failingTest
- void test_overrideEqualsButNotHashCode() {
+ test_overrideEqualsButNotHashCode() async {
Source source = addSource(r'''
class A {
bool operator ==(x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE]);
verify([source]);
}
- void test_overrideOnNonOverridingField_invalid() {
+ test_overrideOnNonOverridingField_invalid() async {
Source source = addSource(r'''
class A {
}
@@ -2155,12 +2166,12 @@
@override
final int m = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD]);
verify([source]);
}
- void test_overrideOnNonOverridingGetter_invalid() {
+ test_overrideOnNonOverridingGetter_invalid() async {
Source source = addSource(r'''
class A {
}
@@ -2168,12 +2179,12 @@
@override
int get m => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER]);
verify([source]);
}
- void test_overrideOnNonOverridingMethod_invalid() {
+ test_overrideOnNonOverridingMethod_invalid() async {
Source source = addSource(r'''
class A {
}
@@ -2181,12 +2192,12 @@
@override
int m() => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD]);
verify([source]);
}
- void test_overrideOnNonOverridingSetter_invalid() {
+ test_overrideOnNonOverridingSetter_invalid() async {
Source source = addSource(r'''
class A {
}
@@ -2194,12 +2205,12 @@
@override
set m(int x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER]);
verify([source]);
}
- void test_required_constructor_param() {
+ test_required_constructor_param() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2211,12 +2222,12 @@
new C();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]);
verify([source]);
}
- void test_required_constructor_param_no_reason() {
+ test_required_constructor_param_no_reason() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2228,12 +2239,12 @@
new C();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]);
verify([source]);
}
- void test_required_constructor_param_null_reason() {
+ test_required_constructor_param_null_reason() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2245,12 +2256,12 @@
new C();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]);
verify([source]);
}
- void test_required_constructor_param_OK() {
+ test_required_constructor_param_OK() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2262,12 +2273,12 @@
new C(a: 2);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_required_constructor_param_redirecting_cons_call() {
+ test_required_constructor_param_redirecting_cons_call() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2276,12 +2287,12 @@
C.named() : this();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]);
verify([source]);
}
- void test_required_constructor_param_super_call() {
+ test_required_constructor_param_super_call() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2293,12 +2304,12 @@
D() : super();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]);
verify([source]);
}
- void test_required_function_param() {
+ test_required_function_param() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2308,12 +2319,12 @@
f();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]);
verify([source]);
}
- void test_required_method_param() {
+ test_required_method_param() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
class A {
@@ -2323,12 +2334,12 @@
new A().m();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]);
verify([source]);
}
- void test_required_method_param_in_other_lib() {
+ test_required_method_param_in_other_lib() async {
addNamedSource(
'/a_lib.dart',
r'''
@@ -2346,12 +2357,12 @@
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]);
verify([source]);
}
- void test_required_typedef_function_param() {
+ test_required_typedef_function_param() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@@ -2363,32 +2374,32 @@
F m() => ({@required String x}) => null;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]);
verify([source]);
}
- void test_typeCheck_type_is_Null() {
+ test_typeCheck_type_is_Null() async {
Source source = addSource(r'''
m(i) {
bool b = i is Null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]);
verify([source]);
}
- void test_typeCheck_type_not_Null() {
+ test_typeCheck_type_not_Null() async {
Source source = addSource(r'''
m(i) {
bool b = i is! Null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]);
verify([source]);
}
- void test_undefinedGetter() {
+ test_undefinedGetter() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2396,11 +2407,11 @@
return a.m;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_message() {
+ test_undefinedGetter_message() async {
// The implementation of HintCode.UNDEFINED_SETTER assumes that
// UNDEFINED_SETTER in StaticTypeWarningCode and StaticWarningCode are the
// same, this verifies that assumption.
@@ -2408,59 +2419,59 @@
StaticTypeWarningCode.UNDEFINED_GETTER.message);
}
- void test_undefinedIdentifier_exportHide() {
+ test_undefinedIdentifier_exportHide() async {
Source source = addSource(r'''
library L;
export 'lib1.dart' hide a;''');
addNamedSource("/lib1.dart", "library lib1;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_HIDDEN_NAME]);
verify([source]);
}
- void test_undefinedIdentifier_exportShow() {
+ test_undefinedIdentifier_exportShow() async {
Source source = addSource(r'''
library L;
export 'lib1.dart' show a;''');
addNamedSource("/lib1.dart", "library lib1;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_SHOWN_NAME]);
verify([source]);
}
- void test_undefinedIdentifier_importHide() {
+ test_undefinedIdentifier_importHide() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' hide a;''');
addNamedSource("/lib1.dart", "library lib1;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_HIDDEN_NAME]);
verify([source]);
}
- void test_undefinedIdentifier_importShow() {
+ test_undefinedIdentifier_importShow() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' show a;''');
addNamedSource("/lib1.dart", "library lib1;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_SHOWN_NAME]);
verify([source]);
}
- void test_undefinedMethod() {
+ test_undefinedMethod() async {
Source source = addSource(r'''
f() {
var a = 'str';
a.notAMethodOnString();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_assignmentExpression() {
+ test_undefinedMethod_assignmentExpression() async {
Source source = addSource(r'''
class A {}
class B {
@@ -2470,11 +2481,11 @@
a += a2;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_METHOD]);
}
- void test_undefinedOperator_binaryExpression() {
+ test_undefinedOperator_binaryExpression() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2482,11 +2493,11 @@
a + 1;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_indexBoth() {
+ test_undefinedOperator_indexBoth() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2494,11 +2505,11 @@
a[0]++;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_indexGetter() {
+ test_undefinedOperator_indexGetter() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2506,11 +2517,11 @@
a[0];
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_indexSetter() {
+ test_undefinedOperator_indexSetter() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2518,11 +2529,11 @@
a[0] = 1;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_postfixExpression() {
+ test_undefinedOperator_postfixExpression() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2530,11 +2541,11 @@
a++;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_prefixExpression() {
+ test_undefinedOperator_prefixExpression() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2542,11 +2553,11 @@
++a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedSetter() {
+ test_undefinedSetter() async {
Source source = addSource(r'''
class A {}
f(var a) {
@@ -2554,11 +2565,11 @@
a.m = 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_SETTER]);
}
- void test_undefinedSetter_message() {
+ test_undefinedSetter_message() async {
// The implementation of HintCode.UNDEFINED_SETTER assumes that
// UNDEFINED_SETTER in StaticTypeWarningCode and StaticWarningCode are the
// same, this verifies that assumption.
@@ -2566,27 +2577,27 @@
StaticTypeWarningCode.UNDEFINED_SETTER.message);
}
- void test_unnecessaryCast_type_supertype() {
+ test_unnecessaryCast_type_supertype() async {
Source source = addSource(r'''
m(int i) {
var b = i as Object;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_CAST]);
verify([source]);
}
- void test_unnecessaryCast_type_type() {
+ test_unnecessaryCast_type_type() async {
Source source = addSource(r'''
m(num i) {
var b = i as num;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_CAST]);
verify([source]);
}
- void test_unnecessaryNoSuchMethod_blockBody() {
+ test_unnecessaryNoSuchMethod_blockBody() async {
Source source = addSource(r'''
class A {
noSuchMethod(x) => super.noSuchMethod(x);
@@ -2597,12 +2608,12 @@
return super.noSuchMethod(y);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
verify([source]);
}
- void test_unnecessaryNoSuchMethod_expressionBody() {
+ test_unnecessaryNoSuchMethod_expressionBody() async {
Source source = addSource(r'''
class A {
noSuchMethod(x) => super.noSuchMethod(x);
@@ -2611,77 +2622,77 @@
mmm();
noSuchMethod(y) => super.noSuchMethod(y);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
verify([source]);
}
- void test_unnecessaryTypeCheck_null_is_Null() {
+ test_unnecessaryTypeCheck_null_is_Null() async {
Source source = addSource("bool b = null is Null;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
verify([source]);
}
- void test_unnecessaryTypeCheck_null_not_Null() {
+ test_unnecessaryTypeCheck_null_not_Null() async {
Source source = addSource("bool b = null is! Null;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
verify([source]);
}
- void test_unnecessaryTypeCheck_type_is_dynamic() {
+ test_unnecessaryTypeCheck_type_is_dynamic() async {
Source source = addSource(r'''
m(i) {
bool b = i is dynamic;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
verify([source]);
}
- void test_unnecessaryTypeCheck_type_is_object() {
+ test_unnecessaryTypeCheck_type_is_object() async {
Source source = addSource(r'''
m(i) {
bool b = i is Object;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
verify([source]);
}
- void test_unnecessaryTypeCheck_type_not_dynamic() {
+ test_unnecessaryTypeCheck_type_not_dynamic() async {
Source source = addSource(r'''
m(i) {
bool b = i is! dynamic;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
verify([source]);
}
- void test_unnecessaryTypeCheck_type_not_object() {
+ test_unnecessaryTypeCheck_type_not_object() async {
Source source = addSource(r'''
m(i) {
bool b = i is! Object;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
verify([source]);
}
- void test_unusedElement_class_isUsed_extends() {
+ test_unusedElement_class_isUsed_extends() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {}
class B extends _A {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_class_isUsed_fieldDeclaration() {
+ test_unusedElement_class_isUsed_fieldDeclaration() async {
enableUnusedElement = true;
var src = r'''
class Foo {
@@ -2692,35 +2703,35 @@
}
''';
Source source = addSource(src);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_class_isUsed_implements() {
+ test_unusedElement_class_isUsed_implements() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {}
class B implements _A {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_class_isUsed_instanceCreation() {
+ test_unusedElement_class_isUsed_instanceCreation() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {}
main() {
new _A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_class_isUsed_staticFieldAccess() {
+ test_unusedElement_class_isUsed_staticFieldAccess() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {
@@ -2729,12 +2740,12 @@
main() {
_A.F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_class_isUsed_staticMethodInvocation() {
+ test_unusedElement_class_isUsed_staticMethodInvocation() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {
@@ -2743,12 +2754,12 @@
main() {
_A.m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_class_isUsed_typeArgument() {
+ test_unusedElement_class_isUsed_typeArgument() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {}
@@ -2756,12 +2767,12 @@
var v = new List<_A>();
print(v);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_class_notUsed_inClassMember() {
+ test_unusedElement_class_notUsed_inClassMember() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {
@@ -2773,12 +2784,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_class_notUsed_inConstructorName() {
+ test_unusedElement_class_notUsed_inConstructorName() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {
@@ -2786,12 +2797,12 @@
_A.named() {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_class_notUsed_isExpression() {
+ test_unusedElement_class_notUsed_isExpression() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {}
@@ -2800,23 +2811,23 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_class_notUsed_noReference() {
+ test_unusedElement_class_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {}
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_class_notUsed_variableDeclaration() {
+ test_unusedElement_class_notUsed_variableDeclaration() async {
enableUnusedElement = true;
Source source = addSource(r'''
class _A {}
@@ -2826,35 +2837,35 @@
}
print(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_enum_isUsed_fieldReference() {
+ test_unusedElement_enum_isUsed_fieldReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
enum _MyEnum {A, B, C}
main() {
print(_MyEnum.B);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_enum_notUsed_noReference() {
+ test_unusedElement_enum_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
enum _MyEnum {A, B, C}
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_functionLocal_isUsed_closure() {
+ test_unusedElement_functionLocal_isUsed_closure() async {
enableUnusedElement = true;
Source source = addSource(r'''
main() {
@@ -2862,24 +2873,24 @@
}
print(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionLocal_isUsed_invocation() {
+ test_unusedElement_functionLocal_isUsed_invocation() async {
enableUnusedElement = true;
Source source = addSource(r'''
main() {
f() {}
f();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionLocal_isUsed_reference() {
+ test_unusedElement_functionLocal_isUsed_reference() async {
enableUnusedElement = true;
Source source = addSource(r'''
main() {
@@ -2888,23 +2899,23 @@
}
print(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionLocal_notUsed_noReference() {
+ test_unusedElement_functionLocal_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
main() {
f() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_functionLocal_notUsed_referenceFromItself() {
+ test_unusedElement_functionLocal_notUsed_referenceFromItself() async {
enableUnusedElement = true;
Source source = addSource(r'''
main() {
@@ -2912,24 +2923,24 @@
_f(p - 1);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_functionTop_isUsed_invocation() {
+ test_unusedElement_functionTop_isUsed_invocation() async {
enableUnusedElement = true;
Source source = addSource(r'''
_f() {}
main() {
_f();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionTop_isUsed_reference() {
+ test_unusedElement_functionTop_isUsed_reference() async {
enableUnusedElement = true;
Source source = addSource(r'''
_f() {}
@@ -2938,23 +2949,23 @@
}
print(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionTop_notUsed_noReference() {
+ test_unusedElement_functionTop_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
_f() {}
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_functionTop_notUsed_referenceFromItself() {
+ test_unusedElement_functionTop_notUsed_referenceFromItself() async {
enableUnusedElement = true;
Source source = addSource(r'''
_f(int p) {
@@ -2962,12 +2973,12 @@
}
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_functionTypeAlias_isUsed_isExpression() {
+ test_unusedElement_functionTypeAlias_isUsed_isExpression() async {
enableUnusedElement = true;
Source source = addSource(r'''
typedef _F(a, b);
@@ -2976,23 +2987,23 @@
print('F');
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionTypeAlias_isUsed_reference() {
+ test_unusedElement_functionTypeAlias_isUsed_reference() async {
enableUnusedElement = true;
Source source = addSource(r'''
typedef _F(a, b);
main(_F f) {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionTypeAlias_isUsed_typeArgument() {
+ test_unusedElement_functionTypeAlias_isUsed_typeArgument() async {
enableUnusedElement = true;
Source source = addSource(r'''
typedef _F(a, b);
@@ -3000,35 +3011,35 @@
var v = new List<_F>();
print(v);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionTypeAlias_isUsed_variableDeclaration() {
+ test_unusedElement_functionTypeAlias_isUsed_variableDeclaration() async {
enableUnusedElement = true;
Source source = addSource(r'''
typedef _F(a, b);
class A {
_F f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_functionTypeAlias_notUsed_noReference() {
+ test_unusedElement_functionTypeAlias_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
typedef _F(a, b);
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_getter_isUsed_invocation_implicitThis() {
+ test_unusedElement_getter_isUsed_invocation_implicitThis() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3037,12 +3048,12 @@
var v = _g;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_getter_isUsed_invocation_PrefixedIdentifier() {
+ test_unusedElement_getter_isUsed_invocation_PrefixedIdentifier() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3052,12 +3063,12 @@
var v = a._g;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_getter_isUsed_invocation_PropertyAccess() {
+ test_unusedElement_getter_isUsed_invocation_PropertyAccess() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3067,23 +3078,23 @@
var v = new A()._g;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_getter_notUsed_noReference() {
+ test_unusedElement_getter_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
get _g => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_getter_notUsed_referenceFromItself() {
+ test_unusedElement_getter_notUsed_referenceFromItself() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3091,12 +3102,12 @@
return _g;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_method_isUsed_hasReference_implicitThis() {
+ test_unusedElement_method_isUsed_hasReference_implicitThis() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3107,12 +3118,12 @@
}
print(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_hasReference_implicitThis_subclass() {
+ test_unusedElement_method_isUsed_hasReference_implicitThis_subclass() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3126,12 +3137,12 @@
}
print(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_hasReference_PrefixedIdentifier() {
+ test_unusedElement_method_isUsed_hasReference_PrefixedIdentifier() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3140,12 +3151,12 @@
main(A a) {
a._m;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_hasReference_PropertyAccess() {
+ test_unusedElement_method_isUsed_hasReference_PropertyAccess() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3154,12 +3165,12 @@
main() {
new A()._m;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_invocation_implicitThis() {
+ test_unusedElement_method_isUsed_invocation_implicitThis() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3168,12 +3179,12 @@
_m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_invocation_implicitThis_subclass() {
+ test_unusedElement_method_isUsed_invocation_implicitThis_subclass() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3185,12 +3196,12 @@
class B extends A {
_m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_invocation_MemberElement() {
+ test_unusedElement_method_isUsed_invocation_MemberElement() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A<T> {
@@ -3199,12 +3210,12 @@
main(A<int> a) {
a._m(0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_invocation_propagated() {
+ test_unusedElement_method_isUsed_invocation_propagated() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3214,12 +3225,12 @@
var a = new A();
a._m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_invocation_static() {
+ test_unusedElement_method_isUsed_invocation_static() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3229,12 +3240,12 @@
A a = new A();
a._m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_invocation_subclass() {
+ test_unusedElement_method_isUsed_invocation_subclass() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3246,12 +3257,12 @@
main(A a) {
a._m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_notPrivate() {
+ test_unusedElement_method_isUsed_notPrivate() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3259,12 +3270,12 @@
}
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_isUsed_staticInvocation() {
+ test_unusedElement_method_isUsed_staticInvocation() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3273,23 +3284,23 @@
main() {
A._m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_method_notUsed_noReference() {
+ test_unusedElement_method_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
static _m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_method_notUsed_referenceFromItself() {
+ test_unusedElement_method_notUsed_referenceFromItself() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3297,12 +3308,12 @@
_m(p - 1);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_setter_isUsed_invocation_implicitThis() {
+ test_unusedElement_setter_isUsed_invocation_implicitThis() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3311,12 +3322,12 @@
_s = 42;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_setter_isUsed_invocation_PrefixedIdentifier() {
+ test_unusedElement_setter_isUsed_invocation_PrefixedIdentifier() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3326,12 +3337,12 @@
a._s = 42;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_setter_isUsed_invocation_PropertyAccess() {
+ test_unusedElement_setter_isUsed_invocation_PropertyAccess() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3341,23 +3352,23 @@
new A()._s = 42;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedElement_setter_notUsed_noReference() {
+ test_unusedElement_setter_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
set _s(x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedElement_setter_notUsed_referenceFromItself() {
+ test_unusedElement_setter_notUsed_referenceFromItself() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3367,12 +3378,12 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_ELEMENT]);
verify([source]);
}
- void test_unusedField_isUsed_argument() {
+ test_unusedField_isUsed_argument() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3382,12 +3393,12 @@
}
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedField_isUsed_reference_implicitThis() {
+ test_unusedField_isUsed_reference_implicitThis() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3397,24 +3408,24 @@
}
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedField_isUsed_reference_implicitThis_expressionFunctionBody() {
+ test_unusedField_isUsed_reference_implicitThis_expressionFunctionBody() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
int _f;
m() => _f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedField_isUsed_reference_implicitThis_subclass() {
+ test_unusedField_isUsed_reference_implicitThis_subclass() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3427,12 +3438,12 @@
int _f;
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedField_isUsed_reference_qualified_propagatedElement() {
+ test_unusedField_isUsed_reference_qualified_propagatedElement() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3443,12 +3454,12 @@
print(a._f);
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedField_isUsed_reference_qualified_staticElement() {
+ test_unusedField_isUsed_reference_qualified_staticElement() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3459,12 +3470,12 @@
print(a._f);
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedField_isUsed_reference_qualified_unresolved() {
+ test_unusedField_isUsed_reference_qualified_unresolved() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3474,12 +3485,12 @@
print(a._f);
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedField_notUsed_compoundAssign() {
+ test_unusedField_notUsed_compoundAssign() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3488,48 +3499,48 @@
_f += 2;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_FIELD]);
verify([source]);
}
- void test_unusedField_notUsed_constructorFieldInitializers() {
+ test_unusedField_notUsed_constructorFieldInitializers() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
int _f;
A() : _f = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_FIELD]);
verify([source]);
}
- void test_unusedField_notUsed_fieldFormalParameter() {
+ test_unusedField_notUsed_fieldFormalParameter() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
int _f;
A(this._f);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_FIELD]);
verify([source]);
}
- void test_unusedField_notUsed_noReference() {
+ test_unusedField_notUsed_noReference() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
int _f;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_FIELD]);
verify([source]);
}
- void test_unusedField_notUsed_postfixExpr() {
+ test_unusedField_notUsed_postfixExpr() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3538,12 +3549,12 @@
_f++;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_FIELD]);
verify([source]);
}
- void test_unusedField_notUsed_prefixExpr() {
+ test_unusedField_notUsed_prefixExpr() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3552,12 +3563,12 @@
++_f;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_FIELD]);
verify([source]);
}
- void test_unusedField_notUsed_simpleAssignment() {
+ test_unusedField_notUsed_simpleAssignment() async {
enableUnusedElement = true;
Source source = addSource(r'''
class A {
@@ -3570,23 +3581,24 @@
a._f = 2;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_FIELD]);
verify([source]);
}
- void test_unusedImport() {
+ test_unusedImport() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';''');
Source source2 = addNamedSource("/lib1.dart", "library lib1;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source, [HintCode.UNUSED_IMPORT]);
assertNoErrors(source2);
verify([source, source2]);
}
- void test_unusedImport_as() {
+ test_unusedImport_as() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -3597,14 +3609,15 @@
r'''
library lib1;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source, [HintCode.UNUSED_IMPORT]);
assertNoErrors(source2);
verify([source, source2]);
}
@failingTest
- void test_unusedImport_as_equalPrefixes() {
+ test_unusedImport_as_equalPrefixes() async {
// See todo at ImportsVerifier.prefixElementMap.
Source source = addSource(r'''
library L;
@@ -3621,14 +3634,16 @@
r'''
library lib2;
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
+ await computeAnalysisResult(source3);
assertErrors(source, [HintCode.UNUSED_IMPORT]);
assertNoErrors(source2);
assertNoErrors(source3);
verify([source, source2, source3]);
}
- void test_unusedImport_hide() {
+ test_unusedImport_hide() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -3639,22 +3654,24 @@
r'''
library lib1;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source, [HintCode.UNUSED_IMPORT]);
assertNoErrors(source2);
verify([source, source2]);
}
- void test_unusedImport_inComment_libraryDirective() {
+ test_unusedImport_inComment_libraryDirective() async {
Source source = addSource(r'''
/// Use [Future] class.
library L;
import 'dart:async';
''');
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_unusedImport_show() {
+ test_unusedImport_show() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' show A;
@@ -3666,13 +3683,14 @@
library lib1;
class A {}
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source, [HintCode.UNUSED_IMPORT]);
assertNoErrors(source2);
verify([source, source2]);
}
- void test_unusedLocalVariable_inCatch_exception() {
+ test_unusedLocalVariable_inCatch_exception() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
@@ -3680,12 +3698,12 @@
} on String catch (exception) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_CATCH_CLAUSE]);
verify([source]);
}
- void test_unusedLocalVariable_inCatch_exception_hasStack() {
+ test_unusedLocalVariable_inCatch_exception_hasStack() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
@@ -3694,12 +3712,12 @@
print(stack);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedLocalVariable_inCatch_exception_noOnClause() {
+ test_unusedLocalVariable_inCatch_exception_noOnClause() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
@@ -3707,12 +3725,12 @@
} catch (exception) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedLocalVariable_inCatch_stackTrace() {
+ test_unusedLocalVariable_inCatch_stackTrace() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
@@ -3720,12 +3738,12 @@
} catch (exception, stackTrace) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_CATCH_STACK]);
verify([source]);
}
- void test_unusedLocalVariable_inCatch_stackTrace_used() {
+ test_unusedLocalVariable_inCatch_stackTrace_used() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
@@ -3735,12 +3753,12 @@
}
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedLocalVariable_inFor_underscore_ignored() {
+ test_unusedLocalVariable_inFor_underscore_ignored() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
@@ -3750,24 +3768,24 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedLocalVariable_inFunction() {
+ test_unusedLocalVariable_inFunction() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
var v = 1;
v = 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
verify([source]);
}
- void test_unusedLocalVariable_inMethod() {
+ test_unusedLocalVariable_inMethod() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
class A {
@@ -3776,12 +3794,12 @@
v = 2;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
verify([source]);
}
- void test_unusedLocalVariable_isInvoked() {
+ test_unusedLocalVariable_isInvoked() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
typedef Foo();
@@ -3789,48 +3807,48 @@
Foo foo;
foo();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedLocalVariable_isRead_notUsed_compoundAssign() {
+ test_unusedLocalVariable_isRead_notUsed_compoundAssign() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
var v = 1;
v += 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
verify([source]);
}
- void test_unusedLocalVariable_isRead_notUsed_postfixExpr() {
+ test_unusedLocalVariable_isRead_notUsed_postfixExpr() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
var v = 1;
v++;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
verify([source]);
}
- void test_unusedLocalVariable_isRead_notUsed_prefixExpr() {
+ test_unusedLocalVariable_isRead_notUsed_prefixExpr() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
var v = 1;
++v;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
verify([source]);
}
- void test_unusedLocalVariable_isRead_usedArgument() {
+ test_unusedLocalVariable_isRead_usedArgument() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
main() {
@@ -3838,12 +3856,12 @@
print(++v);
}
print(x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedLocalVariable_isRead_usedInvocationTarget() {
+ test_unusedLocalVariable_isRead_usedInvocationTarget() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
class A {
@@ -3854,12 +3872,12 @@
a.foo();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_unusedShownName() {
+ test_unusedShownName() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' show A, B;
@@ -3870,13 +3888,14 @@
library lib1;
class A {}
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
assertNoErrors(source2);
verify([source, source2]);
}
- void test_unusedShownName_as() {
+ test_unusedShownName_as() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' as p show A, B;
@@ -3887,13 +3906,14 @@
library lib1;
class A {}
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
assertNoErrors(source2);
verify([source, source2]);
}
- void test_unusedShownName_duplicates() {
+ test_unusedShownName_duplicates() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' show A, B;
@@ -3908,14 +3928,15 @@
class B {}
class C {}
class D {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(
source, [HintCode.UNUSED_SHOWN_NAME, HintCode.UNUSED_SHOWN_NAME]);
assertNoErrors(source2);
verify([source, source2]);
}
- void test_unusedShownName_topLevelVariable() {
+ test_unusedShownName_topLevelVariable() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' show var1, var2;
@@ -3931,13 +3952,14 @@
const int var2 = 2;
const int var3 = 3;
const int var4 = 4;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
assertNoErrors(source2);
verify([source, source2]);
}
- void test_useOfVoidResult_assignmentExpression_function() {
+ test_useOfVoidResult_assignmentExpression_function() async {
Source source = addSource(r'''
void f() {}
class A {
@@ -3946,12 +3968,12 @@
a = f();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
- void test_useOfVoidResult_assignmentExpression_method() {
+ test_useOfVoidResult_assignmentExpression_method() async {
Source source = addSource(r'''
class A {
void m() {}
@@ -3960,12 +3982,12 @@
a = m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
- void test_useOfVoidResult_inForLoop() {
+ test_useOfVoidResult_inForLoop() async {
Source source = addSource(r'''
class A {
void m() {}
@@ -3973,12 +3995,12 @@
for(var a = m();;) {}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
- void test_useOfVoidResult_variableDeclaration_function() {
+ test_useOfVoidResult_variableDeclaration_function() async {
Source source = addSource(r'''
void f() {}
class A {
@@ -3986,12 +4008,12 @@
var a = f();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
- void test_useOfVoidResult_variableDeclaration_method() {
+ test_useOfVoidResult_variableDeclaration_method() async {
Source source = addSource(r'''
class A {
void m() {}
@@ -3999,12 +4021,12 @@
var a = m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
- void test_useOfVoidResult_variableDeclaration_method2() {
+ test_useOfVoidResult_variableDeclaration_method2() async {
Source source = addSource(r'''
class A {
void m() {}
@@ -4012,7 +4034,7 @@
var a = m(), b = m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
verify([source]);
diff --git a/pkg/analyzer/test/generated/non_error_resolver_driver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_driver_test.dart
new file mode 100644
index 0000000..a2cdd13
--- /dev/null
+++ b/pkg/analyzer/test/generated/non_error_resolver_driver_test.dart
@@ -0,0 +1,104 @@
+// Copyright (c) 2017, 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:test_reflective_loader/test_reflective_loader.dart';
+
+import 'non_error_resolver_test.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(NonErrorResolverTest_Driver);
+ });
+}
+
+@reflectiveTest
+class NonErrorResolverTest_Driver extends NonErrorResolverTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ @failingTest
+ @override
+ test_class_type_alias_documentationComment() {
+ return super.test_class_type_alias_documentationComment();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_beforeConstructor() {
+ return super.test_commentReference_beforeConstructor();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_beforeEnum() {
+ return super.test_commentReference_beforeEnum();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_beforeFunction_blockBody() {
+ return super.test_commentReference_beforeFunction_blockBody();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_beforeFunction_expressionBody() {
+ return super.test_commentReference_beforeFunction_expressionBody();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_beforeFunctionTypeAlias() {
+ return super.test_commentReference_beforeFunctionTypeAlias();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_beforeGetter() {
+ return super.test_commentReference_beforeGetter();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_beforeMethod() {
+ return super.test_commentReference_beforeMethod();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_class() {
+ return super.test_commentReference_class();
+ }
+
+ @failingTest
+ @override
+ test_commentReference_setter() {
+ return super.test_commentReference_setter();
+ }
+
+ @failingTest
+ @override
+ test_invalidAnnotation_constantVariable_field_importWithPrefix() {
+ return super
+ .test_invalidAnnotation_constantVariable_field_importWithPrefix();
+ }
+
+ @failingTest
+ @override
+ test_issue_24191() {
+ return super.test_issue_24191();
+ }
+
+ @failingTest
+ @override
+ test_nativeConstConstructor() {
+ return super.test_nativeConstConstructor();
+ }
+
+ @failingTest
+ @override
+ test_nativeFunctionBodyInNonSDKCode_function() {
+ return super.test_nativeFunctionBodyInNonSDKCode_function();
+ }
+}
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index 8ad198f..1fae0c2 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -4,6 +4,8 @@
library analyzer.test.generated.non_error_resolver_test;
+import 'dart:async';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -26,19 +28,18 @@
@reflectiveTest
class NonErrorResolverTest extends ResolverTestCase {
- void fail_undefinedEnumConstant() {
+ fail_undefinedEnumConstant() async {
Source source = addSource(r'''
enum E { ONE }
E e() {
return E.TWO;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_abstractSuperMemberReference_superHasConcrete_mixinHasAbstract_method() {
+ test_abstractSuperMemberReference_superHasConcrete_mixinHasAbstract_method() async {
Source source = addSource('''
class A {
void method() {}
@@ -54,12 +55,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_abstractSuperMemberReference_superHasNoSuchMethod() {
+ test_abstractSuperMemberReference_superHasNoSuchMethod() async {
Source source = addSource('''
abstract class A {
int m();
@@ -70,12 +71,12 @@
int m() => super.m();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_abstractSuperMemberReference_superSuperHasConcrete_getter() {
+ test_abstractSuperMemberReference_superSuperHasConcrete_getter() async {
Source source = addSource('''
abstract class A {
int get m => 0;
@@ -89,12 +90,12 @@
int get m => super.m;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_abstractSuperMemberReference_superSuperHasConcrete_method() {
+ test_abstractSuperMemberReference_superSuperHasConcrete_method() async {
Source source = addSource('''
void main() {
print(new C().m());
@@ -112,12 +113,12 @@
int m() => super.m();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_abstractSuperMemberReference_superSuperHasConcrete_setter() {
+ test_abstractSuperMemberReference_superSuperHasConcrete_setter() async {
Source source = addSource('''
abstract class A {
void set m(int v) {}
@@ -133,12 +134,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_ambiguousExport() {
+ test_ambiguousExport() async {
Source source = addSource(r'''
library L;
export 'lib1.dart';
@@ -153,12 +154,12 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_ambiguousExport_combinators_hide() {
+ test_ambiguousExport_combinators_hide() async {
Source source = addSource(r'''
library L;
export 'lib1.dart';
@@ -175,12 +176,12 @@
library L2;
class B {}
class C {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_ambiguousExport_combinators_show() {
+ test_ambiguousExport_combinators_show() async {
Source source = addSource(r'''
library L;
export 'lib1.dart';
@@ -197,12 +198,12 @@
library L2;
class B {}
class C {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_ambiguousExport_sameDeclaration() {
+ test_ambiguousExport_sameDeclaration() async {
Source source = addSource(r'''
library L;
export 'lib.dart';
@@ -212,12 +213,12 @@
r'''
library lib;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_ambiguousImport_hideCombinator() {
+ test_ambiguousImport_hideCombinator() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -245,11 +246,11 @@
library lib3;
class N {}
class N3 {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_ambiguousImport_showCombinator() {
+ test_ambiguousImport_showCombinator() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart' show N, N2;
@@ -269,19 +270,19 @@
library lib2;
class N {}
class N2 {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
}
- void test_annotated_partOfDeclaration() {
+ test_annotated_partOfDeclaration() async {
Source source = addSource('library L; part "part.dart";');
addNamedSource('/part.dart', '@deprecated part of L;');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_argumentTypeNotAssignable_classWithCall_Function() {
+ test_argumentTypeNotAssignable_classWithCall_Function() async {
Source source = addSource(r'''
caller(Function callee) {
callee();
@@ -294,12 +295,12 @@
main() {
caller(new CallMeBack());
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_argumentTypeNotAssignable_fieldFormalParameterElement_member() {
+ test_argumentTypeNotAssignable_fieldFormalParameterElement_member() async {
Source source = addSource(r'''
class ObjectSink<T> {
void sink(T object) {
@@ -310,46 +311,46 @@
E object2;
TimestampedObject(this.object2);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_functionParameter_generic() {
+ test_argumentTypeNotAssignable_invocation_functionParameter_generic() async {
Source source = addSource(r'''
class A<K> {
m(f(K k), K v) {
f(v);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_typedef_generic() {
+ test_argumentTypeNotAssignable_invocation_typedef_generic() async {
Source source = addSource(r'''
typedef A<T>(T p);
f(A<int> a) {
a(1);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_argumentTypeNotAssignable_Object_Function() {
+ test_argumentTypeNotAssignable_Object_Function() async {
Source source = addSource(r'''
main() {
process(() {});
}
process(Object x) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_argumentTypeNotAssignable_typedef_local() {
+ test_argumentTypeNotAssignable_typedef_local() async {
Source source = addSource(r'''
typedef A(int p1, String p2);
A getA() => null;
@@ -357,23 +358,23 @@
A a = getA();
a(1, '2');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_argumentTypeNotAssignable_typedef_parameter() {
+ test_argumentTypeNotAssignable_typedef_parameter() async {
Source source = addSource(r'''
typedef A(int p1, String p2);
f(A a) {
a(1, '2');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assert_with_message_await() {
+ test_assert_with_message_await() async {
Source source = addSource('''
import 'dart:async';
f() async {
@@ -381,69 +382,69 @@
}
Future<String> g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assert_with_message_dynamic() {
+ test_assert_with_message_dynamic() async {
Source source = addSource('''
f() {
assert(false, g());
}
g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assert_with_message_non_string() {
+ test_assert_with_message_non_string() async {
Source source = addSource('''
f() {
assert(false, 3);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assert_with_message_null() {
+ test_assert_with_message_null() async {
Source source = addSource('''
f() {
assert(false, null);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assert_with_message_string() {
+ test_assert_with_message_string() async {
Source source = addSource('''
f() {
assert(false, 'message');
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assert_with_message_suppresses_unused_var_hint() {
+ test_assert_with_message_suppresses_unused_var_hint() async {
Source source = addSource('''
f() {
String message = 'msg';
assert(true, message);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assignability_function_expr_rettype_from_typedef_cls() {
+ test_assignability_function_expr_rettype_from_typedef_cls() async {
// In the code below, the type of (() => f()) has a return type which is
// a class, and that class is inferred from the return type of the typedef
// F.
@@ -455,12 +456,12 @@
F f2 = (() => f());
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assignability_function_expr_rettype_from_typedef_typedef() {
+ test_assignability_function_expr_rettype_from_typedef_typedef() async {
// In the code below, the type of (() => f()) has a return type which is
// a typedef, and that typedef is inferred from the return type of the
// typedef F.
@@ -472,23 +473,23 @@
F f2 = (() => f());
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assignmentToFinal_prefixNegate() {
+ test_assignmentToFinal_prefixNegate() async {
Source source = addSource(r'''
f() {
final x = 0;
-x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assignmentToFinalNoSetter_prefixedIdentifier() {
+ test_assignmentToFinalNoSetter_prefixedIdentifier() async {
Source source = addSource(r'''
class A {
int get x => 0;
@@ -498,12 +499,12 @@
A a = new A();
a.x = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assignmentToFinalNoSetter_propertyAccess() {
+ test_assignmentToFinalNoSetter_propertyAccess() async {
Source source = addSource(r'''
class A {
int get x => 0;
@@ -515,12 +516,12 @@
main() {
B.a.x = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_assignmentToFinals_importWithPrefix() {
+ test_assignmentToFinals_importWithPrefix() async {
Source source = addSource(r'''
library lib;
import 'lib1.dart' as foo;
@@ -532,43 +533,43 @@
r'''
library lib1;
bool x = false;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_dynamic_with_return() {
+ test_async_dynamic_with_return() async {
Source source = addSource('''
dynamic f() async {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_dynamic_with_return_value() {
+ test_async_dynamic_with_return_value() async {
Source source = addSource('''
dynamic f() async {
return 5;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_dynamic_without_return() {
+ test_async_dynamic_without_return() async {
Source source = addSource('''
dynamic f() async {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_expression_function_type() {
+ test_async_expression_function_type() async {
Source source = addSource('''
import 'dart:async';
typedef Future<int> F(int i);
@@ -576,12 +577,12 @@
F f = (int i) async => i;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_flattened() {
+ test_async_flattened() async {
Source source = addSource('''
import 'dart:async';
typedef Future<int> CreatesFutureInt();
@@ -592,160 +593,160 @@
}
Future<int> f() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_dynamic_with_return() {
+ test_async_future_dynamic_with_return() async {
Source source = addSource('''
import 'dart:async';
Future<dynamic> f() async {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_dynamic_with_return_value() {
+ test_async_future_dynamic_with_return_value() async {
Source source = addSource('''
import 'dart:async';
Future<dynamic> f() async {
return 5;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_dynamic_without_return() {
+ test_async_future_dynamic_without_return() async {
Source source = addSource('''
import 'dart:async';
Future<dynamic> f() async {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_int_with_return_future_int() {
+ test_async_future_int_with_return_future_int() async {
Source source = addSource('''
import 'dart:async';
Future<int> f() async {
return new Future<int>.value(5);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_int_with_return_value() {
+ test_async_future_int_with_return_value() async {
Source source = addSource('''
import 'dart:async';
Future<int> f() async {
return 5;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_null_with_return() {
+ test_async_future_null_with_return() async {
Source source = addSource('''
import 'dart:async';
Future<Null> f() async {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_null_without_return() {
+ test_async_future_null_without_return() async {
Source source = addSource('''
import 'dart:async';
Future<Null> f() async {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_object_with_return() {
+ test_async_future_object_with_return() async {
Source source = addSource('''
import 'dart:async';
Future<Object> f() async {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_object_with_return_value() {
+ test_async_future_object_with_return_value() async {
Source source = addSource('''
import 'dart:async';
Future<Object> f() async {
return 5;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_object_without_return() {
+ test_async_future_object_without_return() async {
Source source = addSource('''
import 'dart:async';
Future<Object> f() async {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_with_return() {
+ test_async_future_with_return() async {
Source source = addSource('''
import 'dart:async';
Future f() async {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_with_return_value() {
+ test_async_future_with_return_value() async {
Source source = addSource('''
import 'dart:async';
Future f() async {
return 5;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_future_without_return() {
+ test_async_future_without_return() async {
Source source = addSource('''
import 'dart:async';
Future f() async {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_return_flattens_futures() {
+ test_async_return_flattens_futures() async {
Source source = addSource('''
import 'dart:async';
Future<int> f() async {
@@ -753,65 +754,65 @@
}
Future<Future<int>> g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_with_return() {
+ test_async_with_return() async {
Source source = addSource('''
f() async {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_with_return_value() {
+ test_async_with_return_value() async {
Source source = addSource('''
f() async {
return 5;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_async_without_return() {
+ test_async_without_return() async {
Source source = addSource('''
f() async {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_asyncForInWrongContext_async() {
+ test_asyncForInWrongContext_async() async {
Source source = addSource(r'''
f(list) async {
await for (var e in list) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_asyncForInWrongContext_asyncStar() {
+ test_asyncForInWrongContext_asyncStar() async {
Source source = addSource(r'''
f(list) async* {
await for (var e in list) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_await_flattened() {
+ test_await_flattened() async {
Source source = addSource('''
import 'dart:async';
Future<Future<int>> ffi() => null;
@@ -819,12 +820,12 @@
int b = await ffi();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_await_simple() {
+ test_await_simple() async {
Source source = addSource('''
import 'dart:async';
Future<int> fi() => null;
@@ -832,32 +833,32 @@
int a = await fi();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_awaitInWrongContext_async() {
+ test_awaitInWrongContext_async() async {
Source source = addSource(r'''
f(x, y) async {
return await x + await y;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_awaitInWrongContext_asyncStar() {
+ test_awaitInWrongContext_asyncStar() async {
Source source = addSource(r'''
f(x, y) async* {
yield await x + await y;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_breakWithoutLabelInSwitch() {
+ test_breakWithoutLabelInSwitch() async {
Source source = addSource(r'''
class A {
void m(int i) {
@@ -867,12 +868,12 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_bug_24539_getter() {
+ test_bug_24539_getter() async {
Source source = addSource('''
class C<T> {
List<Foo> get x => null;
@@ -880,12 +881,12 @@
typedef Foo(param);
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_bug_24539_setter() {
+ test_bug_24539_setter() async {
Source source = addSource('''
class C<T> {
void set x(List<Foo> value) {}
@@ -893,22 +894,22 @@
typedef Foo(param);
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_builtInIdentifierAsType_dynamic() {
+ test_builtInIdentifierAsType_dynamic() async {
Source source = addSource(r'''
f() {
dynamic x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_caseBlockNotTerminated() {
+ test_caseBlockNotTerminated() async {
Source source = addSource(r'''
f(int p) {
for (int i = 0; i < 10; i++) {
@@ -930,12 +931,12 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_caseBlockNotTerminated_lastCase() {
+ test_caseBlockNotTerminated_lastCase() async {
Source source = addSource(r'''
f(int p) {
switch (p) {
@@ -943,12 +944,12 @@
p = p + 1;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_caseExpressionTypeImplementsEquals() {
+ test_caseExpressionTypeImplementsEquals() async {
Source source = addSource(r'''
print(p) {}
@@ -970,12 +971,12 @@
case const C(1): print('Switch: 1'); break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_caseExpressionTypeImplementsEquals_int() {
+ test_caseExpressionTypeImplementsEquals_int() async {
Source source = addSource(r'''
f(int i) {
switch(i) {
@@ -983,12 +984,12 @@
default: return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_caseExpressionTypeImplementsEquals_Object() {
+ test_caseExpressionTypeImplementsEquals_Object() async {
Source source = addSource(r'''
class IntWrapper {
final int value;
@@ -1001,12 +1002,12 @@
default: return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_caseExpressionTypeImplementsEquals_String() {
+ test_caseExpressionTypeImplementsEquals_String() async {
Source source = addSource(r'''
f(String s) {
switch(s) {
@@ -1014,12 +1015,12 @@
default: return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_class_type_alias_documentationComment() {
+ test_class_type_alias_documentationComment() async {
Source source = addSource('''
/**
* Documentation
@@ -1028,27 +1029,26 @@
class D {}
class E {}''');
- computeLibrarySourceErrors(source);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
ClassElement classC =
resolutionMap.elementDeclaredByCompilationUnit(unit).getType('C');
expect(classC.documentationComment, isNotNull);
}
- void test_commentReference_beforeConstructor() {
+ test_commentReference_beforeConstructor() async {
String code = r'''
abstract class A {
/// [p]
A(int p) {}
}''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
{
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, "p]");
@@ -1056,7 +1056,7 @@
}
}
- void test_commentReference_beforeEnum() {
+ test_commentReference_beforeEnum() async {
String code = r'''
/// This is the [Samurai] kind.
enum Samurai {
@@ -1066,10 +1066,10 @@
WITHOUT_SWORD
}''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
{
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, 'Samurai]');
@@ -1093,61 +1093,61 @@
}
}
- void test_commentReference_beforeFunction_blockBody() {
+ test_commentReference_beforeFunction_blockBody() async {
String code = r'''
/// [p]
foo(int p) {
}''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
expect(ref.staticElement, new isInstanceOf<ParameterElement>());
}
- void test_commentReference_beforeFunction_expressionBody() {
+ test_commentReference_beforeFunction_expressionBody() async {
String code = r'''
/// [p]
foo(int p) => null;''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
expect(ref.staticElement, new isInstanceOf<ParameterElement>());
}
- void test_commentReference_beforeFunctionTypeAlias() {
+ test_commentReference_beforeFunctionTypeAlias() async {
String code = r'''
/// [p]
typedef Foo(int p);
''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
expect(ref.staticElement, new isInstanceOf<ParameterElement>());
}
- void test_commentReference_beforeGetter() {
+ test_commentReference_beforeGetter() async {
String code = r'''
abstract class A {
/// [int]
get g => null;
}''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
{
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, 'int]');
@@ -1155,7 +1155,7 @@
}
}
- void test_commentReference_beforeMethod() {
+ test_commentReference_beforeMethod() async {
String code = r'''
abstract class A {
/// [p1]
@@ -1168,10 +1168,10 @@
md(int p5, {int p6});
}''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
assertIsParameter(String search) {
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, search);
@@ -1186,23 +1186,23 @@
assertIsParameter('p6');
}
- void test_commentReference_class() {
+ test_commentReference_class() async {
String code = r'''
/// [foo]
class A {
foo() {}
}''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, 'foo]');
expect(ref.staticElement, new isInstanceOf<MethodElement>());
}
- void test_commentReference_setter() {
+ test_commentReference_setter() async {
String code = r'''
class A {
/// [x] in A
@@ -1215,10 +1215,10 @@
}
''';
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = _getResolvedLibraryUnit(source);
+ CompilationUnit unit = await _getResolvedLibraryUnit(source);
{
SimpleIdentifier ref =
EngineTestCase.findSimpleIdentifier(unit, code, "x] in A");
@@ -1231,17 +1231,17 @@
}
}
- void test_concreteClassWithAbstractMember() {
+ test_concreteClassWithAbstractMember() async {
Source source = addSource(r'''
abstract class A {
m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_concreteClassWithAbstractMember_inherited() {
+ test_concreteClassWithAbstractMember_inherited() async {
Source source = addSource(r'''
class A {
m() {}
@@ -1249,12 +1249,12 @@
class B extends A {
m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_conflictingInstanceGetterAndSuperclassMember_instance() {
+ test_conflictingInstanceGetterAndSuperclassMember_instance() async {
Source source = addSource(r'''
class A {
get v => 0;
@@ -1262,55 +1262,55 @@
class B extends A {
get v => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_conflictingStaticGetterAndInstanceSetter_thisClass() {
+ test_conflictingStaticGetterAndInstanceSetter_thisClass() async {
Source source = addSource(r'''
class A {
static get x => 0;
static set x(int p) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_conflictingStaticSetterAndInstanceMember_thisClass_method() {
+ test_conflictingStaticSetterAndInstanceMember_thisClass_method() async {
Source source = addSource(r'''
class A {
static x() {}
static set x(int p) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_const_constructor_with_named_generic_parameter() {
+ test_const_constructor_with_named_generic_parameter() async {
Source source = addSource('''
class C<T> {
const C({T t});
}
const c = const C(t: 1);
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_const_dynamic() {
+ test_const_dynamic() async {
Source source = addSource('''
const Type d = dynamic;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constConstructorWithNonConstSuper_explicit() {
+ test_constConstructorWithNonConstSuper_explicit() async {
Source source = addSource(r'''
class A {
const A();
@@ -1318,12 +1318,12 @@
class B extends A {
const B(): super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constConstructorWithNonConstSuper_redirectingFactory() {
+ test_constConstructorWithNonConstSuper_redirectingFactory() async {
Source source = addSource(r'''
class A {
A();
@@ -1334,12 +1334,12 @@
class C extends A {
const factory C() = B;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constConstructorWithNonConstSuper_unresolved() {
+ test_constConstructorWithNonConstSuper_unresolved() async {
Source source = addSource(r'''
class A {
A.a();
@@ -1347,24 +1347,24 @@
class B extends A {
const B(): super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]);
verify([source]);
}
- void test_constConstructorWithNonFinalField_finalInstanceVar() {
+ test_constConstructorWithNonFinalField_finalInstanceVar() async {
Source source = addSource(r'''
class A {
final int x = 0;
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constConstructorWithNonFinalField_mixin() {
+ test_constConstructorWithNonFinalField_mixin() async {
Source source = addSource(r'''
class A {
a() {}
@@ -1372,36 +1372,36 @@
class B extends Object with A {
const B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN]);
verify([source]);
}
- void test_constConstructorWithNonFinalField_static() {
+ test_constConstructorWithNonFinalField_static() async {
Source source = addSource(r'''
class A {
static int x;
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constConstructorWithNonFinalField_syntheticField() {
+ test_constConstructorWithNonFinalField_syntheticField() async {
Source source = addSource(r'''
class A {
const A();
set x(value) {}
get x {return 0;}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constDeferredClass_new() {
- resolveWithErrors(<String>[
+ test_constDeferredClass_new() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {
@@ -1416,16 +1416,16 @@
], <ErrorCode>[]);
}
- void test_constEval_functionTypeLiteral() {
+ test_constEval_functionTypeLiteral() async {
Source source = addSource(r'''
typedef F();
const C = F;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constEval_propertyExtraction_fieldStatic_targetType() {
+ test_constEval_propertyExtraction_fieldStatic_targetType() async {
addNamedSource(
"/math.dart",
r'''
@@ -1434,24 +1434,24 @@
Source source = addSource(r'''
import 'math.dart' as math;
const C = math.PI;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constEval_propertyExtraction_methodStatic_targetType() {
+ test_constEval_propertyExtraction_methodStatic_targetType() async {
Source source = addSource(r'''
class A {
const A();
static m() {}
}
const C = A.m;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constEval_symbol() {
+ test_constEval_symbol() async {
addNamedSource(
"/math.dart",
r'''
@@ -1460,12 +1460,12 @@
Source source = addSource(r'''
const C = #foo;
foo() {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constEvalTypeBoolNumString_equal() {
+ test_constEvalTypeBoolNumString_equal() async {
Source source = addSource(r'''
class A {
const A();
@@ -1490,11 +1490,11 @@
const B.n1(num p) : v = p == null;
const B.n2(num p) : v = null == p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_constEvalTypeBoolNumString_notEqual() {
+ test_constEvalTypeBoolNumString_notEqual() async {
Source source = addSource(r'''
class A {
const A();
@@ -1519,22 +1519,22 @@
const B.n1(num p) : v = p != null;
const B.n2(num p) : v = null != p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constEvelTypeNum_String() {
+ test_constEvelTypeNum_String() async {
Source source = addSource(r'''
const String A = 'a';
const String B = A + 'b';
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constMapKeyExpressionTypeImplementsEquals_abstract() {
+ test_constMapKeyExpressionTypeImplementsEquals_abstract() async {
Source source = addSource(r'''
abstract class B {
final id;
@@ -1551,32 +1551,32 @@
Map getMap() {
return const { const C(0): 'Map: 0' };
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constNotInitialized_field() {
+ test_constNotInitialized_field() async {
Source source = addSource(r'''
class A {
static const int x = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constNotInitialized_local() {
+ test_constNotInitialized_local() async {
Source source = addSource(r'''
main() {
const int x = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constRedirectSkipsSupertype() {
+ test_constRedirectSkipsSupertype() async {
// Since C redirects to C.named, it doesn't implicitly refer to B's
// unnamed constructor. Therefore there is no cycle.
Source source = addSource('''
@@ -1591,23 +1591,23 @@
}
const y = const C();
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constructorDeclaration_scope_signature() {
+ test_constructorDeclaration_scope_signature() async {
Source source = addSource(r'''
const app = 0;
class A {
A(@app int app) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constWithNonConstantArgument_constField() {
+ test_constWithNonConstantArgument_constField() async {
Source source = addSource(r'''
class A {
const A(x);
@@ -1615,34 +1615,34 @@
main() {
const A(double.INFINITY);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constWithNonConstantArgument_literals() {
+ test_constWithNonConstantArgument_literals() async {
Source source = addSource(r'''
class A {
const A(a, b, c, d);
}
f() { return const A(true, 0, 1.0, '2'); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constWithTypeParameters_direct() {
+ test_constWithTypeParameters_direct() async {
Source source = addSource(r'''
class A<T> {
static const V = const A<int>();
const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constWithUndefinedConstructor() {
+ test_constWithUndefinedConstructor() async {
Source source = addSource(r'''
class A {
const A.name();
@@ -1650,12 +1650,12 @@
f() {
return const A.name();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_constWithUndefinedConstructorDefault() {
+ test_constWithUndefinedConstructorDefault() async {
Source source = addSource(r'''
class A {
const A();
@@ -1663,33 +1663,33 @@
f() {
return const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_defaultValueInFunctionTypeAlias() {
+ test_defaultValueInFunctionTypeAlias() async {
Source source = addSource("typedef F([x]);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_defaultValueInFunctionTypedParameter_named() {
+ test_defaultValueInFunctionTypedParameter_named() async {
Source source = addSource("f(g({p})) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_defaultValueInFunctionTypedParameter_optional() {
+ test_defaultValueInFunctionTypedParameter_optional() async {
Source source = addSource("f(g([p])) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deprecatedMemberUse_hide() {
+ test_deprecatedMemberUse_hide() async {
Source source = addSource(r'''
library lib;
import 'lib1.dart' hide B;
@@ -1701,12 +1701,12 @@
class A {}
@deprecated
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_duplicateDefinition_emptyName() {
+ test_duplicateDefinition_emptyName() async {
// Note: This code has two FunctionElements '() {}' with an empty name,
// this tests that the empty string is not put into the scope
// (more than once).
@@ -1715,19 +1715,19 @@
'a' : () {},
'b' : () {}
};''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_duplicateDefinition_getter() {
+ test_duplicateDefinition_getter() async {
Source source = addSource("bool get a => true;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_duplicatePart() {
+ test_duplicatePart() async {
addNamedSource('/part1.dart', 'part of lib;');
addNamedSource('/part2.dart', 'part of lib;');
Source source = addSource(r'''
@@ -1735,116 +1735,116 @@
part 'part1.dart';
part 'part2.dart';
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_dynamicIdentifier() {
+ test_dynamicIdentifier() async {
Source source = addSource(r'''
main() {
var v = dynamic;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_empty_generator_async() {
+ test_empty_generator_async() async {
Source source = addSource('''
import 'dart:async';
Stream<int> f() async* {
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_empty_generator_sync() {
+ test_empty_generator_sync() async {
Source source = addSource('''
Iterable<int> f() sync* {
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_expectedOneListTypeArgument() {
+ test_expectedOneListTypeArgument() async {
Source source = addSource(r'''
main() {
<int> [];
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_expectedTwoMapTypeArguments() {
+ test_expectedTwoMapTypeArguments() async {
Source source = addSource(r'''
main() {
<int, int> {};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_exportDuplicatedLibraryUnnamed() {
+ test_exportDuplicatedLibraryUnnamed() async {
Source source = addSource(r'''
library test;
export 'lib1.dart';
export 'lib2.dart';''');
addNamedSource("/lib1.dart", "");
addNamedSource("/lib2.dart", "");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_exportOfNonLibrary_libraryDeclared() {
+ test_exportOfNonLibrary_libraryDeclared() async {
Source source = addSource(r'''
library L;
export 'lib1.dart';''');
addNamedSource("/lib1.dart", "library lib1;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_exportOfNonLibrary_libraryNotDeclared() {
+ test_exportOfNonLibrary_libraryNotDeclared() async {
Source source = addSource(r'''
library L;
export 'lib1.dart';''');
addNamedSource("/lib1.dart", "");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_extraPositionalArguments_function() {
+ test_extraPositionalArguments_function() async {
Source source = addSource(r'''
f(p1, p2) {}
main() {
f(1, 2);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_extraPositionalArguments_Function() {
+ test_extraPositionalArguments_Function() async {
Source source = addSource(r'''
f(Function a) {
a(1, 2);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_extraPositionalArguments_implicitConstructor() {
+ test_extraPositionalArguments_implicitConstructor() async {
Source source = addSource(r'''
class A<E extends num> {
A(E x, E y);
@@ -1854,12 +1854,12 @@
void main() {
B<int> x = new B<int>(0,0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_extraPositionalArguments_typedef_local() {
+ test_extraPositionalArguments_typedef_local() async {
Source source = addSource(r'''
typedef A(p1, p2);
A getA() => null;
@@ -1867,79 +1867,79 @@
A a = getA();
a(1, 2);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_extraPositionalArguments_typedef_parameter() {
+ test_extraPositionalArguments_typedef_parameter() async {
Source source = addSource(r'''
typedef A(p1, p2);
f(A a) {
a(1, 2);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldInitializedByMultipleInitializers() {
+ test_fieldInitializedByMultipleInitializers() async {
Source source = addSource(r'''
class A {
int x;
int y;
A() : x = 0, y = 0 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() {
+ test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() async {
Source source = addSource(r'''
class A {
int x = 0;
A() : x = 1 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() {
+ test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() async {
Source source = addSource(r'''
class A {
final int x;
A() : x = 1 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldInitializerOutsideConstructor() {
+ test_fieldInitializerOutsideConstructor() async {
Source source = addSource(r'''
class A {
int x;
A(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldInitializerOutsideConstructor_defaultParameters() {
+ test_fieldInitializerOutsideConstructor_defaultParameters() async {
Source source = addSource(r'''
class A {
int x;
A([this.x]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldInitializerRedirectingConstructor_super() {
+ test_fieldInitializerRedirectingConstructor_super() async {
Source source = addSource(r'''
class A {
A() {}
@@ -1948,143 +1948,143 @@
int x;
B(this.x) : super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_finalInitializedInDeclarationAndConstructor_initializer() {
+ test_finalInitializedInDeclarationAndConstructor_initializer() async {
Source source = addSource(r'''
class A {
final x;
A() : x = 1 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
+ test_finalInitializedInDeclarationAndConstructor_initializingFormal() async {
Source source = addSource(r'''
class A {
final x;
A(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_finalNotInitialized_atDeclaration() {
+ test_finalNotInitialized_atDeclaration() async {
Source source = addSource(r'''
class A {
final int x = 0;
A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_finalNotInitialized_fieldFormal() {
+ test_finalNotInitialized_fieldFormal() async {
Source source = addSource(r'''
class A {
final int x = 0;
A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_finalNotInitialized_functionTypedFieldFormal() {
+ test_finalNotInitialized_functionTypedFieldFormal() async {
Source source = addSource(r'''
class A {
final Function x;
A(int this.x(int p)) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_finalNotInitialized_hasNativeClause_hasConstructor() {
+ test_finalNotInitialized_hasNativeClause_hasConstructor() async {
Source source = addSource(r'''
class A native 'something' {
final int x;
A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
verify([source]);
}
- void test_finalNotInitialized_hasNativeClause_noConstructor() {
+ test_finalNotInitialized_hasNativeClause_noConstructor() async {
Source source = addSource(r'''
class A native 'something' {
final int x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
verify([source]);
}
- void test_finalNotInitialized_initializer() {
+ test_finalNotInitialized_initializer() async {
Source source = addSource(r'''
class A {
final int x;
A() : x = 0 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_finalNotInitialized_redirectingConstructor() {
+ test_finalNotInitialized_redirectingConstructor() async {
Source source = addSource(r'''
class A {
final int x;
A(this.x);
A.named() : this (42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionDeclaration_scope_returnType() {
+ test_functionDeclaration_scope_returnType() async {
Source source = addSource("int f(int) { return 0; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionDeclaration_scope_signature() {
+ test_functionDeclaration_scope_signature() async {
Source source = addSource(r'''
const app = 0;
f(@app int app) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionTypeAlias_scope_returnType() {
+ test_functionTypeAlias_scope_returnType() async {
Source source = addSource("typedef int f(int);");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionTypeAlias_scope_signature() {
+ test_functionTypeAlias_scope_signature() async {
Source source = addSource(r'''
const app = 0;
typedef int f(@app int app);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionWithoutCall() {
+ test_functionWithoutCall() async {
Source source = addSource(r'''
abstract class A implements Function {
}
@@ -2096,31 +2096,31 @@
}
class D extends C {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionWithoutCall_doesNotImplementFunction() {
+ test_functionWithoutCall_doesNotImplementFunction() async {
Source source = addSource("class A {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionWithoutCall_staticCallMethod() {
+ test_functionWithoutCall_staticCallMethod() async {
Source source = addSource(r'''
class A { }
class B extends A {
static call() { }
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionWithoutCall_withNoSuchMethod() {
+ test_functionWithoutCall_withNoSuchMethod() async {
// 16078
Source source = addSource(r'''
class A implements Function {
@@ -2128,36 +2128,36 @@
return 42;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionWithoutCall_withNoSuchMethod_mixin() {
+ test_functionWithoutCall_withNoSuchMethod_mixin() async {
Source source = addSource(r'''
class A {
noSuchMethod(inv) {}
}
class B extends Object with A implements Function {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionWithoutCall_withNoSuchMethod_superclass() {
+ test_functionWithoutCall_withNoSuchMethod_superclass() async {
Source source = addSource(r'''
class A {
noSuchMethod(inv) {}
}
class B extends A implements Function {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitConstructorDependencies() {
+ test_implicitConstructorDependencies() async {
// No warning should be generated for the code below; this requires that
// implicit constructors are generated for C1 before C2, even though C1
// follows C2 in the file. See dartbug.com/21600.
@@ -2175,12 +2175,12 @@
new C2(5);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_constructorName() {
+ test_implicitThisReferenceInInitializer_constructorName() async {
Source source = addSource(r'''
class A {
A.named() {}
@@ -2189,23 +2189,23 @@
var v;
B() : v = new A.named();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_importPrefix() {
+ test_implicitThisReferenceInInitializer_importPrefix() async {
Source source = addSource(r'''
import 'dart:async' as abstract;
class A {
var v = new abstract.Completer();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_prefixedIdentifier() {
+ test_implicitThisReferenceInInitializer_prefixedIdentifier() async {
Source source = addSource(r'''
class A {
var f;
@@ -2214,12 +2214,12 @@
var v;
B(A a) : v = a.f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() {
+ test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() async {
Source source = addSource(r'''
class A {
f() {}
@@ -2228,12 +2228,12 @@
var v;
B() : v = new A().f();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() {
+ test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() async {
Source source = addSource(r'''
class A {
var f;
@@ -2242,101 +2242,101 @@
var v;
B() : v = new A().f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_staticField_thisClass() {
+ test_implicitThisReferenceInInitializer_staticField_thisClass() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f;
static var f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_staticGetter() {
+ test_implicitThisReferenceInInitializer_staticGetter() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f;
static get f => 42;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_staticMethod() {
+ test_implicitThisReferenceInInitializer_staticMethod() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f();
static f() => 42;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_topLevelField() {
+ test_implicitThisReferenceInInitializer_topLevelField() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f;
}
var f = 42;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_topLevelFunction() {
+ test_implicitThisReferenceInInitializer_topLevelFunction() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f();
}
f() => 42;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_topLevelGetter() {
+ test_implicitThisReferenceInInitializer_topLevelGetter() async {
Source source = addSource(r'''
class A {
var v;
A() : v = f;
}
get f => 42;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_implicitThisReferenceInInitializer_typeParameter() {
+ test_implicitThisReferenceInInitializer_typeParameter() async {
Source source = addSource(r'''
class A<T> {
var v;
A(p) : v = (p is T);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_importDuplicatedLibraryName() {
+ test_importDuplicatedLibraryName() async {
Source source = addSource(r'''
library test;
import 'lib.dart';
import 'lib.dart';''');
addNamedSource("/lib.dart", "library lib;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
HintCode.UNUSED_IMPORT,
HintCode.UNUSED_IMPORT,
@@ -2345,14 +2345,14 @@
verify([source]);
}
- void test_importDuplicatedLibraryUnnamed() {
+ test_importDuplicatedLibraryUnnamed() async {
Source source = addSource(r'''
library test;
import 'lib1.dart';
import 'lib2.dart';''');
addNamedSource("/lib1.dart", "");
addNamedSource("/lib2.dart", "");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
// No warning on duplicate import (https://github.com/dart-lang/sdk/issues/24156)
HintCode.UNUSED_IMPORT,
@@ -2361,7 +2361,7 @@
verify([source]);
}
- void test_importOfNonLibrary_libraryDeclared() {
+ test_importOfNonLibrary_libraryDeclared() async {
Source source = addSource(r'''
library lib;
import 'part.dart';
@@ -2371,23 +2371,23 @@
r'''
library lib1;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_importOfNonLibrary_libraryNotDeclared() {
+ test_importOfNonLibrary_libraryNotDeclared() async {
Source source = addSource(r'''
library lib;
import 'part.dart';
A a;''');
addNamedSource("/part.dart", "class A {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_importPrefixes_withFirstLetterDifference() {
+ test_importPrefixes_withFirstLetterDifference() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' as math;
@@ -2406,12 +2406,12 @@
r'''
library lib2;
test2() {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentCaseExpressionTypes() {
+ test_inconsistentCaseExpressionTypes() async {
Source source = addSource(r'''
f(var p) {
switch (p) {
@@ -2421,12 +2421,12 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_accessors_typeParameter2() {
+ test_inconsistentMethodInheritance_accessors_typeParameter2() async {
Source source = addSource(r'''
abstract class A<E> {
E get x {return null;}
@@ -2435,12 +2435,12 @@
E get x {return null;}
}
class C<E> extends A<E> implements B<E> {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_accessors_typeParameters1() {
+ test_inconsistentMethodInheritance_accessors_typeParameters1() async {
Source source = addSource(r'''
abstract class A<E> {
E get x;
@@ -2451,12 +2451,12 @@
class C<E> implements A<E>, B<E> {
E get x => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_accessors_typeParameters_diamond() {
+ test_inconsistentMethodInheritance_accessors_typeParameters_diamond() async {
Source source = addSource(r'''
abstract class F<E> extends B<E> {}
class D<E> extends F<E> {
@@ -2470,12 +2470,12 @@
}
class A<E> extends B<E> implements D<E> {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_methods_typeParameter2() {
+ test_inconsistentMethodInheritance_methods_typeParameter2() async {
Source source = addSource(r'''
class A<E> {
x(E e) {}
@@ -2486,12 +2486,12 @@
class C<E> extends A<E> implements B<E> {
x(E e) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_methods_typeParameters1() {
+ test_inconsistentMethodInheritance_methods_typeParameters1() async {
Source source = addSource(r'''
class A<E> {
x(E e) {}
@@ -2502,12 +2502,12 @@
class C<E> implements A<E>, B<E> {
x(E e) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_overrideTrumpsInherits_getter() {
+ test_inconsistentMethodInheritance_overrideTrumpsInherits_getter() async {
// 16134
Source source = addSource(r'''
class B<S> {
@@ -2519,12 +2519,12 @@
class C extends B<double> implements I<int> {
num get g => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_overrideTrumpsInherits_method() {
+ test_inconsistentMethodInheritance_overrideTrumpsInherits_method() async {
// 16134
Source source = addSource(r'''
class B<S> {
@@ -2536,12 +2536,12 @@
class C extends B<double> implements I<int> {
m(num n) => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_overrideTrumpsInherits_setter() {
+ test_inconsistentMethodInheritance_overrideTrumpsInherits_setter() async {
// 16134
Source source = addSource(r'''
class B<S> {
@@ -2553,12 +2553,12 @@
class C extends B<double> implements I<int> {
set t(num n) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inconsistentMethodInheritance_simple() {
+ test_inconsistentMethodInheritance_simple() async {
Source source = addSource(r'''
abstract class A {
x();
@@ -2569,23 +2569,23 @@
class C implements A, B {
x() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_initializingFormalForNonExistentField() {
+ test_initializingFormalForNonExistentField() async {
Source source = addSource(r'''
class A {
int x;
A(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_instance_creation_inside_annotation() {
+ test_instance_creation_inside_annotation() async {
Source source = addSource('''
class C {
const C();
@@ -2597,12 +2597,12 @@
@D(const C())
f() {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_instanceAccessToStaticMember_fromComment() {
+ test_instanceAccessToStaticMember_fromComment() async {
Source source = addSource(r'''
class A {
static m() {}
@@ -2610,23 +2610,23 @@
/// [A.m]
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_instanceAccessToStaticMember_topLevel() {
+ test_instanceAccessToStaticMember_topLevel() async {
Source source = addSource(r'''
m() {}
main() {
m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_instanceMemberAccessFromStatic_fromComment() {
+ test_instanceMemberAccessFromStatic_fromComment() async {
Source source = addSource(r'''
class A {
m() {}
@@ -2634,12 +2634,12 @@
static foo() {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_field() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_field() async {
Source source = addSource(r'''
import 'lib.dart';
class B extends A {
@@ -2652,12 +2652,12 @@
class A {
static var _m;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_method() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_method() async {
Source source = addSource(r'''
import 'lib.dart';
class B extends A {
@@ -2670,23 +2670,23 @@
class A {
static _m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAnnotation_constantVariable_field() {
+ test_invalidAnnotation_constantVariable_field() async {
Source source = addSource(r'''
@A.C
class A {
static const C = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAnnotation_constantVariable_field_importWithPrefix() {
+ test_invalidAnnotation_constantVariable_field_importWithPrefix() async {
addNamedSource(
"/lib.dart",
r'''
@@ -2699,23 +2699,23 @@
@p.A.C
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAnnotation_constantVariable_topLevel() {
+ test_invalidAnnotation_constantVariable_topLevel() async {
Source source = addSource(r'''
const C = 0;
@C
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() {
+ test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() async {
addNamedSource(
"/lib.dart",
r'''
@@ -2726,12 +2726,12 @@
@p.C
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAnnotation_constConstructor_importWithPrefix() {
+ test_invalidAnnotation_constConstructor_importWithPrefix() async {
addNamedSource(
"/lib.dart",
r'''
@@ -2744,12 +2744,12 @@
@p.A(42)
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAnnotation_constConstructor_named_importWithPrefix() {
+ test_invalidAnnotation_constConstructor_named_importWithPrefix() async {
addNamedSource(
"/lib.dart",
r'''
@@ -2762,24 +2762,24 @@
@p.A.named(42)
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment() {
+ test_invalidAssignment() async {
Source source = addSource(r'''
f() {
var x;
var y;
x = y;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_compoundAssignment() {
+ test_invalidAssignment_compoundAssignment() async {
Source source = addSource(r'''
class byte {
int _value;
@@ -2791,54 +2791,54 @@
byte b = new byte(52);
b += 3;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_defaultValue_named() {
+ test_invalidAssignment_defaultValue_named() async {
Source source = addSource(r'''
f({String x: '0'}) {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_defaultValue_optional() {
+ test_invalidAssignment_defaultValue_optional() async {
Source source = addSource(r'''
f([String x = '0']) {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_ifNullAssignment_compatibleType() {
+ test_invalidAssignment_ifNullAssignment_compatibleType() async {
Source source = addSource('''
void f(int i) {
num n;
n ??= i;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_ifNullAssignment_sameType() {
+ test_invalidAssignment_ifNullAssignment_sameType() async {
Source source = addSource('''
void f(int i) {
int j;
j ??= i;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_implicitlyImplementFunctionViaCall_1() {
+ test_invalidAssignment_implicitlyImplementFunctionViaCall_1() async {
// 18341
//
// This test and
@@ -2854,12 +2854,12 @@
}
typedef int IntToInt(int x);
IntToInt f = new I();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_implicitlyImplementFunctionViaCall_2() {
+ test_invalidAssignment_implicitlyImplementFunctionViaCall_2() async {
// 18341
//
// Here 'C' checks as a subtype of 'I', but 'C' does not
@@ -2875,12 +2875,12 @@
}
typedef int IntToInt(int x);
IntToInt f = new C();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_implicitlyImplementFunctionViaCall_3() {
+ test_invalidAssignment_implicitlyImplementFunctionViaCall_3() async {
// 18341
//
// Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()',
@@ -2894,12 +2894,12 @@
}
typedef int IntToInt(int x);
Function f = new C();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_implicitlyImplementFunctionViaCall_4() {
+ test_invalidAssignment_implicitlyImplementFunctionViaCall_4() async {
// 18341
//
// Like 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()',
@@ -2920,33 +2920,33 @@
}
typedef int VoidToInt();
VoidToInt f = new C();''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidAssignment_toDynamic() {
+ test_invalidAssignment_toDynamic() async {
Source source = addSource(r'''
f() {
var g;
g = () => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidFactoryNameNotAClass() {
+ test_invalidFactoryNameNotAClass() async {
Source source = addSource(r'''
class A {
factory A() => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidIdentifierInAsync() {
+ test_invalidIdentifierInAsync() async {
Source source = addSource(r'''
class A {
m() {
@@ -2955,12 +2955,12 @@
int yield;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidMethodOverrideNamedParamType() {
+ test_invalidMethodOverrideNamedParamType() async {
Source source = addSource(r'''
class A {
m({int a}) {}
@@ -2968,12 +2968,12 @@
class B implements A {
m({int a, int b}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideDifferentDefaultValues_named() {
+ test_invalidOverrideDifferentDefaultValues_named() async {
Source source = addSource(r'''
class A {
m({int p : 0}) {}
@@ -2981,12 +2981,12 @@
class B extends A {
m({int p : 0}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideDifferentDefaultValues_named_function() {
+ test_invalidOverrideDifferentDefaultValues_named_function() async {
Source source = addSource(r'''
nothing() => 'nothing';
class A {
@@ -2995,12 +2995,12 @@
class B extends A {
thing(String a, {orElse : nothing}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideDifferentDefaultValues_positional() {
+ test_invalidOverrideDifferentDefaultValues_positional() async {
Source source = addSource(r'''
class A {
m([int p = 0]) {}
@@ -3008,12 +3008,12 @@
class B extends A {
m([int p = 0]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() {
+ test_invalidOverrideDifferentDefaultValues_positional_changedOrder() async {
Source source = addSource(r'''
class A {
m([int a = 0, String b = '0']) {}
@@ -3021,12 +3021,12 @@
class B extends A {
m([int b = 0, String a = '0']) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideDifferentDefaultValues_positional_function() {
+ test_invalidOverrideDifferentDefaultValues_positional_function() async {
Source source = addSource(r'''
nothing() => 'nothing';
class A {
@@ -3035,12 +3035,12 @@
class B extends A {
thing(String a, [orElse = nothing]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideNamed_unorderedNamedParameter() {
+ test_invalidOverrideNamed_unorderedNamedParameter() async {
Source source = addSource(r'''
class A {
m({a, b}) {}
@@ -3048,12 +3048,12 @@
class B extends A {
m({b, a}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideRequired_less() {
+ test_invalidOverrideRequired_less() async {
Source source = addSource(r'''
class A {
m(a, b) {}
@@ -3061,12 +3061,12 @@
class B extends A {
m(a, [b]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideRequired_same() {
+ test_invalidOverrideRequired_same() async {
Source source = addSource(r'''
class A {
m(a) {}
@@ -3074,12 +3074,12 @@
class B extends A {
m(a) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_interface() {
+ test_invalidOverrideReturnType_returnType_interface() async {
Source source = addNamedSource(
"/test.dart",
r'''
@@ -3089,12 +3089,12 @@
class B implements A {
int m() { return 1; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_interface2() {
+ test_invalidOverrideReturnType_returnType_interface2() async {
Source source = addNamedSource(
"/test.dart",
r'''
@@ -3106,12 +3106,12 @@
class C implements B {
int m() { return 1; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_mixin() {
+ test_invalidOverrideReturnType_returnType_mixin() async {
Source source = addNamedSource(
"/test.dart",
r'''
@@ -3121,12 +3121,12 @@
class B extends Object with A {
int m() { return 1; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_parameterizedTypes() {
+ test_invalidOverrideReturnType_returnType_parameterizedTypes() async {
Source source = addSource(r'''
abstract class A<E> {
List<E> m();
@@ -3134,12 +3134,12 @@
class B extends A<dynamic> {
List<dynamic> m() { return new List<dynamic>(); }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_sameType() {
+ test_invalidOverrideReturnType_returnType_sameType() async {
Source source = addNamedSource(
"/test.dart",
r'''
@@ -3149,12 +3149,12 @@
class B extends A {
int m() { return 1; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_superclass() {
+ test_invalidOverrideReturnType_returnType_superclass() async {
Source source = addNamedSource(
"/test.dart",
r'''
@@ -3164,12 +3164,12 @@
class B extends A {
int m() { return 1; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_superclass2() {
+ test_invalidOverrideReturnType_returnType_superclass2() async {
Source source = addNamedSource(
"/test.dart",
r'''
@@ -3181,12 +3181,12 @@
class C extends B {
int m() { return 1; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideReturnType_returnType_void() {
+ test_invalidOverrideReturnType_returnType_void() async {
Source source = addSource(r'''
class A {
void m() {}
@@ -3194,72 +3194,72 @@
class B extends A {
int m() { return 0; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidReferenceToThis_constructor() {
+ test_invalidReferenceToThis_constructor() async {
Source source = addSource(r'''
class A {
A() {
var v = this;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidReferenceToThis_instanceMethod() {
+ test_invalidReferenceToThis_instanceMethod() async {
Source source = addSource(r'''
class A {
m() {
var v = this;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidTypeArgumentForKey() {
+ test_invalidTypeArgumentForKey() async {
Source source = addSource(r'''
class A {
m() {
return const <int, int>{};
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidTypeArgumentInConstList() {
+ test_invalidTypeArgumentInConstList() async {
Source source = addSource(r'''
class A<E> {
m() {
return <E>[];
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidTypeArgumentInConstMap() {
+ test_invalidTypeArgumentInConstMap() async {
Source source = addSource(r'''
class A<E> {
m() {
return <String, E>{};
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_dynamic() {
+ test_invocationOfNonFunction_dynamic() async {
Source source = addSource(r'''
class A {
var f;
@@ -3269,12 +3269,12 @@
f();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_functionTypeTypeParameter() {
+ test_invocationOfNonFunction_functionTypeTypeParameter() async {
Source source = addSource(r'''
typedef void Action<T>(T x);
class C<T, U extends Action<T>> {
@@ -3286,12 +3286,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_getter() {
+ test_invocationOfNonFunction_getter() async {
Source source = addSource(r'''
class A {
var g;
@@ -3300,35 +3300,35 @@
A a;
a.g();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_localVariable() {
+ test_invocationOfNonFunction_localVariable() async {
Source source = addSource(r'''
f() {
var g;
g();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_localVariable_dynamic() {
+ test_invocationOfNonFunction_localVariable_dynamic() async {
Source source = addSource(r'''
f() {}
main() {
var v = f;
v();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_localVariable_dynamic2() {
+ test_invocationOfNonFunction_localVariable_dynamic2() async {
Source source = addSource(r'''
f() {}
main() {
@@ -3336,23 +3336,23 @@
v = 1;
v();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_Object() {
+ test_invocationOfNonFunction_Object() async {
Source source = addSource(r'''
main() {
Object v = null;
v();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invocationOfNonFunction_proxyOnFunctionClass() {
+ test_invocationOfNonFunction_proxyOnFunctionClass() async {
// 16078
Source source = addSource(r'''
@proxy
@@ -3365,12 +3365,12 @@
Functor f = new Functor();
f();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_issue_24191() {
+ test_issue_24191() async {
Source source = addSource('''
import 'dart:async';
@@ -3381,22 +3381,22 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_listElementTypeNotAssignable() {
+ test_listElementTypeNotAssignable() async {
Source source = addSource(r'''
var v1 = <int> [42];
var v2 = const <int> [42];''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_loadLibraryDefined() {
- resolveWithErrors(<String>[
+ test_loadLibraryDefined() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
foo() => 22;''',
@@ -3408,117 +3408,117 @@
], <ErrorCode>[]);
}
- void test_local_generator_async() {
+ test_local_generator_async() async {
Source source = addSource('''
f() {
return () async* { yield 0; };
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_local_generator_sync() {
+ test_local_generator_sync() async {
Source source = addSource('''
f() {
return () sync* { yield 0; };
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mapKeyTypeNotAssignable() {
+ test_mapKeyTypeNotAssignable() async {
Source source = addSource("var v = <String, int > {'a' : 1};");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_memberWithClassName_setter() {
+ test_memberWithClassName_setter() async {
Source source = addSource(r'''
class A {
set A(v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_methodDeclaration_scope_signature() {
+ test_methodDeclaration_scope_signature() async {
Source source = addSource(r'''
const app = 0;
class A {
foo(@app int app) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_misMatchedGetterAndSetterTypes_instance_sameTypes() {
+ test_misMatchedGetterAndSetterTypes_instance_sameTypes() async {
Source source = addSource(r'''
class C {
int get x => 0;
set x(int v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() {
+ test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() async {
Source source = addSource(r'''
class C {
get x => 0;
set x(String v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() {
+ test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() async {
Source source = addSource(r'''
class C {
int get x => 0;
set x(v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() {
+ test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() async {
Source source = addSource(r'''
int get x => 0;
set x(int v) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() {
+ test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() async {
Source source = addSource(r'''
get x => 0;
set x(String v) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() {
+ test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() async {
Source source = addSource(r'''
int get x => 0;
set x(v) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_missingEnumConstantInSwitch_all() {
+ test_missingEnumConstantInSwitch_all() async {
Source source = addSource(r'''
enum E { A, B, C }
@@ -3529,12 +3529,12 @@
case E.C: break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_missingEnumConstantInSwitch_default() {
+ test_missingEnumConstantInSwitch_default() async {
Source source = addSource(r'''
enum E { A, B, C }
@@ -3544,12 +3544,12 @@
default: break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixedReturnTypes_differentScopes() {
+ test_mixedReturnTypes_differentScopes() async {
Source source = addSource(r'''
class C {
m(int x) {
@@ -3560,23 +3560,23 @@
return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixedReturnTypes_ignoreImplicit() {
+ test_mixedReturnTypes_ignoreImplicit() async {
Source source = addSource(r'''
f(bool p) {
if (p) return 42;
// implicit 'return;' is ignored
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixedReturnTypes_ignoreImplicit2() {
+ test_mixedReturnTypes_ignoreImplicit2() async {
Source source = addSource(r'''
f(bool p) {
if (p) {
@@ -3586,12 +3586,12 @@
}
// implicit 'return;' is ignored
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixedReturnTypes_sameKind() {
+ test_mixedReturnTypes_sameKind() async {
Source source = addSource(r'''
class C {
m(int x) {
@@ -3601,163 +3601,163 @@
return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinDeclaresConstructor() {
+ test_mixinDeclaresConstructor() async {
Source source = addSource(r'''
class A {
m() {}
}
class B extends Object with A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinDeclaresConstructor_factory() {
+ test_mixinDeclaresConstructor_factory() async {
Source source = addSource(r'''
class A {
factory A() => null;
}
class B extends Object with A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinInheritsFromNotObject_classDeclaration_extends() {
+ test_mixinInheritsFromNotObject_classDeclaration_extends() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableSuperMixins = true;
- resetWithOptions(options);
+ resetWith(options: options);
Source source = addSource(r'''
class A {}
class B extends A {}
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() {
+ test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() async {
Source source = addSource(r'''
class A {}
class B = Object with A;
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinInheritsFromNotObject_classDeclaration_with() {
+ test_mixinInheritsFromNotObject_classDeclaration_with() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableSuperMixins = true;
- resetWithOptions(options);
+ resetWith(options: options);
Source source = addSource(r'''
class A {}
class B extends Object with A {}
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinInheritsFromNotObject_typeAlias_extends() {
+ test_mixinInheritsFromNotObject_typeAlias_extends() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableSuperMixins = true;
- resetWithOptions(options);
+ resetWith(options: options);
Source source = addSource(r'''
class A {}
class B extends A {}
class C = Object with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinInheritsFromNotObject_typeAlias_with() {
+ test_mixinInheritsFromNotObject_typeAlias_with() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableSuperMixins = true;
- resetWithOptions(options);
+ resetWith(options: options);
Source source = addSource(r'''
class A {}
class B extends Object with A {}
class C = Object with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinInheritsFromNotObject_typedef_mixTypeAlias() {
+ test_mixinInheritsFromNotObject_typedef_mixTypeAlias() async {
Source source = addSource(r'''
class A {}
class B = Object with A;
class C = Object with B;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_mixinReferencesSuper() {
+ test_mixinReferencesSuper() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableSuperMixins = true;
- resetWithOptions(options);
+ resetWith(options: options);
Source source = addSource(r'''
class A {
toString() => super.toString();
}
class B extends Object with A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_multipleSuperInitializers_no() {
+ test_multipleSuperInitializers_no() async {
Source source = addSource(r'''
class A {}
class B extends A {
B() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_multipleSuperInitializers_single() {
+ test_multipleSuperInitializers_single() async {
Source source = addSource(r'''
class A {}
class B extends A {
B() : super() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nativeConstConstructor() {
+ test_nativeConstConstructor() async {
Source source = addSource(r'''
import 'dart-ext:x';
class Foo {
const Foo() native 'Foo_Foo';
const factory Foo.foo() native 'Foo_Foo_foo';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
// Cannot verify the AST because the import's URI cannot be resolved.
}
- void test_nativeFunctionBodyInNonSDKCode_function() {
+ test_nativeFunctionBodyInNonSDKCode_function() async {
Source source = addSource(r'''
import 'dart-ext:x';
int m(a) native 'string';''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
// Cannot verify the AST because the import's URI cannot be resolved.
}
- void test_newWithAbstractClass_factory() {
+ test_newWithAbstractClass_factory() async {
Source source = addSource(r'''
abstract class A {
factory A() { return new B(); }
@@ -3768,12 +3768,12 @@
A f() {
return new A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_newWithUndefinedConstructor() {
+ test_newWithUndefinedConstructor() async {
Source source = addSource(r'''
class A {
A.name() {}
@@ -3781,12 +3781,12 @@
f() {
new A.name();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_newWithUndefinedConstructorDefault() {
+ test_newWithUndefinedConstructorDefault() async {
Source source = addSource(r'''
class A {
A() {}
@@ -3794,13 +3794,12 @@
f() {
new A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_getter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_getter() async {
Source source = addSource(r'''
class A {
int get g => 0;
@@ -3809,13 +3808,12 @@
int get g;
}
class C extends B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_method() {
+ test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_method() async {
Source source = addSource(r'''
class A {
m(p) {}
@@ -3824,13 +3822,12 @@
m(p);
}
class C extends B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_setter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_setter() async {
Source source = addSource(r'''
class A {
set s(v) {}
@@ -3839,13 +3836,12 @@
set s(v);
}
class C extends B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() {
+ test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() async {
// 15979
Source source = addSource(r'''
abstract class M {}
@@ -3854,12 +3850,12 @@
m();
}
abstract class B = A with M implements I;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() {
+ test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() async {
// 15979
Source source = addSource(r'''
abstract class M {
@@ -3867,13 +3863,12 @@
}
abstract class A {}
abstract class B = A with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() {
+ test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() async {
// 15979
Source source = addSource(r'''
class M {}
@@ -3881,12 +3876,12 @@
m();
}
abstract class B = A with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_mixin_getter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_mixin_getter() async {
// 17034
Source source = addSource(r'''
class A {
@@ -3897,12 +3892,12 @@
}
class B extends A with M {}
class C extends B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_mixin_method() {
+ test_nonAbstractClassInheritsAbstractMemberOne_mixin_method() async {
Source source = addSource(r'''
class A {
m() {}
@@ -3912,12 +3907,12 @@
}
class B extends A with M {}
class C extends B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_mixin_setter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_mixin_setter() async {
Source source = addSource(r'''
class A {
var a;
@@ -3927,12 +3922,12 @@
}
class B extends A with M {}
class C extends B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() {
+ test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() async {
Source source = addSource(r'''
abstract class A {
int get g;
@@ -3940,12 +3935,12 @@
class B extends A {
noSuchMethod(v) => '';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() {
+ test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() async {
Source source = addSource(r'''
abstract class A {
m(p);
@@ -3953,12 +3948,12 @@
class B extends A {
noSuchMethod(v) => '';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_mixin() {
+ test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_mixin() async {
Source source = addSource(r'''
class A {
noSuchMethod(v) => '';
@@ -3966,13 +3961,12 @@
class B extends Object with A {
m(p);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_superclass() {
+ test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_superclass() async {
Source source = addSource(r'''
class A {
noSuchMethod(v) => '';
@@ -3980,46 +3974,45 @@
class B extends A {
m(p);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_overridesMethodInObject() {
+ test_nonAbstractClassInheritsAbstractMemberOne_overridesMethodInObject() async {
Source source = addSource(r'''
class A {
String toString([String prefix = '']) => '${prefix}Hello';
}
class C {}
class B extends A with C {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolExpression_functionType() {
+ test_nonBoolExpression_functionType() async {
Source source = addSource(r'''
bool makeAssertion() => true;
f() {
assert(makeAssertion);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolExpression_interfaceType() {
+ test_nonBoolExpression_interfaceType() async {
Source source = addSource(r'''
f() {
assert(true);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolNegationExpression() {
+ test_nonBoolNegationExpression() async {
Source source = addSource(r'''
f(bool pb, pd) {
!true;
@@ -4027,12 +4020,12 @@
!pb;
!pd;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolNegationExpression_dynamic() {
+ test_nonBoolNegationExpression_dynamic() async {
Source source = addSource(r'''
f1(bool dynamic) {
!dynamic;
@@ -4042,115 +4035,115 @@
!dynamic;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolOperand_and_bool() {
+ test_nonBoolOperand_and_bool() async {
Source source = addSource(r'''
bool f(bool left, bool right) {
return left && right;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolOperand_and_dynamic() {
+ test_nonBoolOperand_and_dynamic() async {
Source source = addSource(r'''
bool f(left, dynamic right) {
return left && right;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolOperand_or_bool() {
+ test_nonBoolOperand_or_bool() async {
Source source = addSource(r'''
bool f(bool left, bool right) {
return left || right;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonBoolOperand_or_dynamic() {
+ test_nonBoolOperand_or_dynamic() async {
Source source = addSource(r'''
bool f(dynamic left, right) {
return left || right;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_constField() {
+ test_nonConstantDefaultValue_constField() async {
Source source = addSource(r'''
f([a = double.INFINITY]) {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_function_named() {
+ test_nonConstantDefaultValue_function_named() async {
Source source = addSource("f({x : 2 + 3}) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_function_positional() {
+ test_nonConstantDefaultValue_function_positional() async {
Source source = addSource("f([x = 2 + 3]) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_inConstructor_named() {
+ test_nonConstantDefaultValue_inConstructor_named() async {
Source source = addSource(r'''
class A {
A({x : 2 + 3}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_inConstructor_positional() {
+ test_nonConstantDefaultValue_inConstructor_positional() async {
Source source = addSource(r'''
class A {
A([x = 2 + 3]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_method_named() {
+ test_nonConstantDefaultValue_method_named() async {
Source source = addSource(r'''
class A {
m({x : 2 + 3}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_method_positional() {
+ test_nonConstantDefaultValue_method_positional() async {
Source source = addSource(r'''
class A {
m([x = 2 + 3]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantDefaultValue_typedConstList() {
+ test_nonConstantDefaultValue_typedConstList() async {
Source source = addSource(r'''
class A {
m([p111 = const <String>[]]) {}
@@ -4158,12 +4151,12 @@
class B extends A {
m([p222 = const <String>[]]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstantValueInInitializer_namedArgument() {
+ test_nonConstantValueInInitializer_namedArgument() async {
Source source = addSource(r'''
class A {
final a;
@@ -4172,12 +4165,12 @@
class B extends A {
const B({b}) : super(a: b);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstCaseExpression_constField() {
+ test_nonConstCaseExpression_constField() async {
Source source = addSource(r'''
f(double p) {
switch (p) {
@@ -4187,13 +4180,13 @@
return false;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
- void test_nonConstCaseExpression_typeLiteral() {
+ test_nonConstCaseExpression_typeLiteral() async {
Source source = addSource(r'''
f(Type t) {
switch (t) {
@@ -4204,73 +4197,73 @@
return false;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstListElement_constField() {
+ test_nonConstListElement_constField() async {
Source source = addSource(r'''
main() {
const [double.INFINITY];
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstMapAsExpressionStatement_const() {
+ test_nonConstMapAsExpressionStatement_const() async {
Source source = addSource(r'''
f() {
const {'a' : 0, 'b' : 1};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstMapAsExpressionStatement_notExpressionStatement() {
+ test_nonConstMapAsExpressionStatement_notExpressionStatement() async {
Source source = addSource(r'''
f() {
var m = {'a' : 0, 'b' : 1};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstMapAsExpressionStatement_typeArguments() {
+ test_nonConstMapAsExpressionStatement_typeArguments() async {
Source source = addSource(r'''
f() {
<String, int> {'a' : 0, 'b' : 1};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstMapKey_constField() {
+ test_nonConstMapKey_constField() async {
Source source = addSource(r'''
main() {
const {double.INFINITY: 0};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
- void test_nonConstMapValue_constField() {
+ test_nonConstMapValue_constField() async {
Source source = addSource(r'''
main() {
const {0: double.INFINITY};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstValueInInitializer_binary_bool() {
+ test_nonConstValueInInitializer_binary_bool() async {
Source source = addSource(r'''
class A {
final v;
@@ -4279,12 +4272,12 @@
const A.b1(bool p) : v = p || true;
const A.b2(bool p) : v = true || p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.DEAD_CODE]);
verify([source]);
}
- void test_nonConstValueInInitializer_binary_dynamic() {
+ test_nonConstValueInInitializer_binary_dynamic() async {
Source source = addSource(r'''
class A {
final v;
@@ -4309,12 +4302,12 @@
const A.j1(p) : v = p % 5;
const A.j2(p) : v = 5 % p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
// operations on "p" are not resolved
}
- void test_nonConstValueInInitializer_binary_int() {
+ test_nonConstValueInInitializer_binary_int() async {
Source source = addSource(r'''
class A {
final v;
@@ -4329,12 +4322,12 @@
const A.e1(int p) : v = p << 5;
const A.e2(int p) : v = 5 << p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstValueInInitializer_binary_num() {
+ test_nonConstValueInInitializer_binary_num() async {
Source source = addSource(r'''
class A {
final v;
@@ -4359,34 +4352,34 @@
const A.j1(num p) : v = p % 5;
const A.j2(num p) : v = 5 % p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstValueInInitializer_field() {
+ test_nonConstValueInInitializer_field() async {
Source source = addSource(r'''
class A {
final int a;
const A() : a = 5;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstValueInInitializer_redirecting() {
+ test_nonConstValueInInitializer_redirecting() async {
Source source = addSource(r'''
class A {
const A.named(p);
const A() : this.named(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstValueInInitializer_super() {
+ test_nonConstValueInInitializer_super() async {
Source source = addSource(r'''
class A {
const A(p);
@@ -4394,12 +4387,12 @@
class B extends A {
const B() : super(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonConstValueInInitializer_unary() {
+ test_nonConstValueInInitializer_unary() async {
Source source = addSource(r'''
class A {
final v;
@@ -4407,12 +4400,12 @@
const A.b(int p) : v = ~p;
const A.c(num p) : v = -p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonGenerativeConstructor() {
+ test_nonGenerativeConstructor() async {
Source source = addSource(r'''
class A {
A.named() {}
@@ -4421,24 +4414,24 @@
class B extends A {
B() : super.named();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonTypeInCatchClause_isClass() {
+ test_nonTypeInCatchClause_isClass() async {
Source source = addSource(r'''
f() {
try {
} on String catch (e) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonTypeInCatchClause_isFunctionTypeAlias() {
+ test_nonTypeInCatchClause_isFunctionTypeAlias() async {
Source source = addSource(r'''
typedef F();
f() {
@@ -4446,12 +4439,12 @@
} on F catch (e) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonTypeInCatchClause_isTypeParameter() {
+ test_nonTypeInCatchClause_isTypeParameter() async {
Source source = addSource(r'''
class A<T> {
f() {
@@ -4460,117 +4453,117 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonTypeInCatchClause_noType() {
+ test_nonTypeInCatchClause_noType() async {
Source source = addSource(r'''
f() {
try {
} catch (e) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonVoidReturnForOperator_no() {
+ test_nonVoidReturnForOperator_no() async {
Source source = addSource(r'''
class A {
operator []=(a, b) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonVoidReturnForOperator_void() {
+ test_nonVoidReturnForOperator_void() async {
Source source = addSource(r'''
class A {
void operator []=(a, b) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonVoidReturnForSetter_function_no() {
+ test_nonVoidReturnForSetter_function_no() async {
Source source = addSource("set x(v) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonVoidReturnForSetter_function_void() {
+ test_nonVoidReturnForSetter_function_void() async {
Source source = addSource("void set x(v) {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonVoidReturnForSetter_method_no() {
+ test_nonVoidReturnForSetter_method_no() async {
Source source = addSource(r'''
class A {
set x(v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nonVoidReturnForSetter_method_void() {
+ test_nonVoidReturnForSetter_method_void() async {
Source source = addSource(r'''
class A {
void set x(v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_null_callMethod() {
+ test_null_callMethod() async {
Source source = addSource(r'''
main() {
null.m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_null_callOperator() {
+ test_null_callOperator() async {
Source source = addSource(r'''
main() {
null + 5;
null == 5;
null[0];
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_optionalParameterInOperator_required() {
+ test_optionalParameterInOperator_required() async {
Source source = addSource(r'''
class A {
operator +(p) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_parameterDefaultDoesNotReferToParameterName() {
+ test_parameterDefaultDoesNotReferToParameterName() async {
// The final "f" should refer to the toplevel function "f", not to the
// parameter called "f". See dartbug.com/13179.
Source source = addSource('void f([void f([x]) = f]) {}');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_parameterScope_local() {
+ test_parameterScope_local() async {
// Parameter names shouldn't conflict with the name of the function they
// are enclosed in.
Source source = addSource(r'''
@@ -4581,12 +4574,12 @@
}
h(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_parameterScope_method() {
+ test_parameterScope_method() async {
// Parameter names shouldn't conflict with the name of the function they
// are enclosed in.
Source source = addSource(r'''
@@ -4597,12 +4590,12 @@
}
h(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_parameterScope_toplevel() {
+ test_parameterScope_toplevel() async {
// Parameter names shouldn't conflict with the name of the function they
// are enclosed in.
Source source = addSource(r'''
@@ -4611,12 +4604,12 @@
}
h(x) {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_prefixCollidesWithTopLevelMembers() {
+ test_prefixCollidesWithTopLevelMembers() async {
addNamedSource(
"/lib.dart",
r'''
@@ -4629,23 +4622,23 @@
var p3;
class p4 {}
p.A a;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_propagateTypeArgs_intoBounds() {
+ test_propagateTypeArgs_intoBounds() async {
Source source = addSource(r'''
abstract class A<E> {}
abstract class B<F> implements A<F>{}
abstract class C<G, H extends A<G>> {}
class D<I> extends C<I, B<I>> {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_propagateTypeArgs_intoSupertype() {
+ test_propagateTypeArgs_intoSupertype() async {
Source source = addSource(r'''
class A<T> {
A(T p);
@@ -4655,12 +4648,12 @@
B(S p) : super(p);
B.named(S p) : super.named(p);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_proxy_annotation_prefixed() {
+ test_proxy_annotation_prefixed() async {
Source source = addSource(r'''
library L;
@proxy
@@ -4673,11 +4666,11 @@
a++;
++a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_prefixed2() {
+ test_proxy_annotation_prefixed2() async {
Source source = addSource(r'''
library L;
@proxy
@@ -4692,11 +4685,11 @@
++a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_prefixed3() {
+ test_proxy_annotation_prefixed3() async {
Source source = addSource(r'''
library L;
class B {
@@ -4711,11 +4704,11 @@
}
@proxy
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_proxyHasPrefixedIdentifier() {
+ test_proxy_annotation_proxyHasPrefixedIdentifier() async {
Source source = addSource(r'''
library L;
import 'dart:core' as core;
@@ -4724,11 +4717,11 @@
new PrefixProxy().foo;
new PrefixProxy().foo();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_simple() {
+ test_proxy_annotation_simple() async {
Source source = addSource(r'''
library L;
@proxy
@@ -4740,11 +4733,11 @@
var y = this + this;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_superclass() {
+ test_proxy_annotation_superclass() async {
Source source = addSource(r'''
library L;
class B extends A {
@@ -4757,11 +4750,11 @@
}
@proxy
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_superclass_mixin() {
+ test_proxy_annotation_superclass_mixin() async {
Source source = addSource(r'''
library L;
class B extends Object with A {
@@ -4774,11 +4767,11 @@
}
@proxy
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_superinterface() {
+ test_proxy_annotation_superinterface() async {
Source source = addSource(r'''
library L;
class B implements A {
@@ -4791,12 +4784,12 @@
}
@proxy
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_superinterface_infiniteLoop() {
- Source source = addSource(r'''
+ test_proxy_annotation_superinterface_infiniteLoop() async {
+ addSource(r'''
library L;
class C implements A {
m() {
@@ -4808,24 +4801,23 @@
}
class B implements A{}
class A implements B{}''');
- computeLibrarySourceErrors(source);
// Test is that a stack overflow isn't reached in resolution
// (previous line), no need to assert error set.
}
- void test_recursiveConstructorRedirect() {
+ test_recursiveConstructorRedirect() async {
Source source = addSource(r'''
class A {
A.a() : this.b();
A.b() : this.c();
A.c() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_recursiveFactoryRedirect() {
+ test_recursiveFactoryRedirect() async {
Source source = addSource(r'''
class A {
factory A() = B;
@@ -4836,12 +4828,12 @@
class C implements B {
factory C() => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_redirectToInvalidFunctionType() {
+ test_redirectToInvalidFunctionType() async {
Source source = addSource(r'''
class A implements B {
A(int p) {}
@@ -4849,12 +4841,12 @@
class B {
factory B(int p) = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_redirectToInvalidReturnType() {
+ test_redirectToInvalidReturnType() async {
Source source = addSource(r'''
class A {
A() {}
@@ -4862,23 +4854,23 @@
class B extends A {
factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_redirectToNonConstConstructor() {
+ test_redirectToNonConstConstructor() async {
Source source = addSource(r'''
class A {
const A.a();
const factory A.b() = A.a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_referencedBeforeDeclaration_cascade() {
+ test_referencedBeforeDeclaration_cascade() async {
Source source = addSource(r'''
testRequestHandler() {}
@@ -4889,12 +4881,12 @@
var stream = 123;
print(stream);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_referenceToDeclaredVariableInInitializer_constructorName() {
+ test_referenceToDeclaredVariableInInitializer_constructorName() async {
Source source = addSource(r'''
class A {
A.x() {}
@@ -4902,12 +4894,12 @@
f() {
var x = new A.x();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_referenceToDeclaredVariableInInitializer_methodName() {
+ test_referenceToDeclaredVariableInInitializer_methodName() async {
Source source = addSource(r'''
class A {
x() {}
@@ -4915,12 +4907,12 @@
f(A a) {
var x = a.x();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_referenceToDeclaredVariableInInitializer_propertyName() {
+ test_referenceToDeclaredVariableInInitializer_propertyName() async {
Source source = addSource(r'''
class A {
var x;
@@ -4928,77 +4920,77 @@
f(A a) {
var x = a.x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_rethrowOutsideCatch() {
+ test_rethrowOutsideCatch() async {
Source source = addSource(r'''
class A {
void m() {
try {} catch (e) {rethrow;}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_return_in_generator_async() {
+ test_return_in_generator_async() async {
Source source = addSource('''
import 'dart:async';
Stream<int> f() async* {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_return_in_generator_sync() {
+ test_return_in_generator_sync() async {
Source source = addSource('''
Iterable<int> f() sync* {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnInGenerativeConstructor() {
+ test_returnInGenerativeConstructor() async {
Source source = addSource(r'''
class A {
A() { return; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnInGenerator_async() {
+ test_returnInGenerator_async() async {
Source source = addSource(r'''
f() async {
return 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnInGenerator_sync() {
+ test_returnInGenerator_sync() async {
Source source = addSource(r'''
f() {
return 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnOfInvalidType_async() {
+ test_returnOfInvalidType_async() async {
Source source = addSource(r'''
import 'dart:async';
class A {
@@ -5006,12 +4998,12 @@
return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnOfInvalidType_dynamic() {
+ test_returnOfInvalidType_dynamic() async {
Source source = addSource(r'''
class TypeError {}
class A {
@@ -5025,44 +5017,44 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnOfInvalidType_dynamicAsTypeArgument() {
+ test_returnOfInvalidType_dynamicAsTypeArgument() async {
Source source = addSource(r'''
class I<T> {
factory I() => new A<T>();
}
class A<T> implements I {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnOfInvalidType_subtype() {
+ test_returnOfInvalidType_subtype() async {
Source source = addSource(r'''
class A {}
class B extends A {}
A f(B b) { return b; }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnOfInvalidType_supertype() {
+ test_returnOfInvalidType_supertype() async {
Source source = addSource(r'''
class A {}
class B extends A {}
B f(A a) { return a; }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnOfInvalidType_typeParameter_18468() {
+ test_returnOfInvalidType_typeParameter_18468() async {
// https://code.google.com/p/dart/issues/detail?id=18468
//
// This test verifies that the type of T is more specific than Type,
@@ -5077,12 +5069,12 @@
class Foo<T> {
Type get t => T;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source);
verify([source]);
}
- void test_returnOfInvalidType_void() {
+ test_returnOfInvalidType_void() async {
Source source = addSource(r'''
void f1() {}
void f2() { return; }
@@ -5092,26 +5084,26 @@
g1() {}
void g2() {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnWithoutValue_noReturnType() {
+ test_returnWithoutValue_noReturnType() async {
Source source = addSource("f() { return; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_returnWithoutValue_void() {
+ test_returnWithoutValue_void() async {
Source source = addSource("void f() { return; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_reversedTypeArguments() {
+ test_reversedTypeArguments() async {
Source source = addSource(r'''
class Codec<S1, T1> {
Codec<T1, S1> get inverted => new _InvertedCodec<T1, S1>(this);
@@ -5119,13 +5111,13 @@
class _InvertedCodec<T2, S2> extends Codec<T2, S2> {
_InvertedCodec(Codec<S2, T2> codec);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_sharedDeferredPrefix() {
- resolveWithErrors(<String>[
+ test_sharedDeferredPrefix() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
f1() {}''',
@@ -5144,7 +5136,7 @@
], <ErrorCode>[]);
}
- void test_staticAccessToInstanceMember_annotation() {
+ test_staticAccessToInstanceMember_annotation() async {
Source source = addSource(r'''
class A {
const A.name();
@@ -5152,12 +5144,12 @@
@A.name()
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_staticAccessToInstanceMember_method() {
+ test_staticAccessToInstanceMember_method() async {
Source source = addSource(r'''
class A {
static m() {}
@@ -5166,12 +5158,12 @@
A.m;
A.m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_staticAccessToInstanceMember_propertyAccess_field() {
+ test_staticAccessToInstanceMember_propertyAccess_field() async {
Source source = addSource(r'''
class A {
static var f;
@@ -5180,12 +5172,12 @@
A.f;
A.f = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() {
+ test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() async {
Source source = addSource(r'''
class A {
static get f => 42;
@@ -5195,12 +5187,12 @@
A.f;
A.f = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_superInInvalidContext() {
+ test_superInInvalidContext() async {
Source source = addSource(r'''
class A {
m() {}
@@ -5213,23 +5205,23 @@
var v = super.m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() {
+ test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() async {
Source source = addSource(r'''
typedef B A();
class B {
A a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_const() {
+ test_typeArgumentNotMatchingBounds_const() async {
Source source = addSource(r'''
class A {}
class B extends A {}
@@ -5237,23 +5229,23 @@
const G();
}
f() { return const G<B>(); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_new() {
+ test_typeArgumentNotMatchingBounds_new() async {
Source source = addSource(r'''
class A {}
class B extends A {}
class G<E extends A> {}
f() { return new G<B>(); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound() {
+ test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound() async {
Source source = addSource(r'''
class A {}
class B extends A {}
@@ -5261,12 +5253,12 @@
F<A> fa;
F<B> fb;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound2() {
+ test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound2() async {
Source source = addSource(r'''
class MyClass<T> {}
typedef MyFunction<T, P extends MyClass<T>>();
@@ -5274,67 +5266,66 @@
MyFunction<T, P> f;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_noBound() {
+ test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_noBound() async {
Source source = addSource(r'''
typedef F<T>();
F<int> f1;
F<String> f2;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_typeArgumentList_0() {
+ test_typeArgumentNotMatchingBounds_typeArgumentList_0() async {
Source source = addSource("abstract class A<T extends A>{}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_typeArgumentList_1() {
+ test_typeArgumentNotMatchingBounds_typeArgumentList_1() async {
Source source = addSource("abstract class A<T extends A<A>>{}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeArgumentNotMatchingBounds_typeArgumentList_20() {
+ test_typeArgumentNotMatchingBounds_typeArgumentList_20() async {
Source source = addSource(
"abstract class A<T extends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>>>>>>>>>>>>>>>>>>>>{}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_booleanAnd_useInRight() {
+ test_typePromotion_booleanAnd_useInRight() async {
Source source = addSource(r'''
main(Object p) {
p is String && p.length != 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignment() {
+ test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignment() async {
Source source = addSource(r'''
callMe(f()) { f(); }
main(Object p) {
(p is String) && callMe(() { p.length; });
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_conditional_issue14655() {
+ test_typePromotion_conditional_issue14655() async {
Source source = addSource(r'''
class A {}
class B extends A {}
@@ -5345,34 +5336,33 @@
main(A p) {
(p is C) && (print(() => p) && (p is B)) ? p.mc() : p = null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_conditional_useInThen() {
+ test_typePromotion_conditional_useInThen() async {
Source source = addSource(r'''
main(Object p) {
p is String ? p.length : 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void
- test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() {
+ test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() async {
Source source = addSource(r'''
callMe(f()) { f(); }
main(Object p) {
p is String ? callMe(() { p.length; }) : 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() {
+ test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() async {
Source source = addSource(r'''
typedef FuncB(B b);
typedef FuncA(A a);
@@ -5383,12 +5373,12 @@
f(new A());
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() {
+ test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() async {
Source source = addSource(r'''
class A {}
typedef FuncAtoDyn(A a);
@@ -5398,12 +5388,12 @@
A a = f(new A());
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_functionType_return_voidToDynamic() {
+ test_typePromotion_functionType_return_voidToDynamic() async {
Source source = addSource(r'''
typedef FuncDynToDyn(x);
typedef void FuncDynToVoid(x);
@@ -5413,12 +5403,12 @@
A a = f(null);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_accessedInClosure_noAssignment() {
+ test_typePromotion_if_accessedInClosure_noAssignment() async {
Source source = addSource(r'''
callMe(f()) { f(); }
main(Object p) {
@@ -5428,12 +5418,12 @@
});
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_extends_moreSpecific() {
+ test_typePromotion_if_extends_moreSpecific() async {
Source source = addSource(r'''
class V {}
class VP extends V {}
@@ -5447,12 +5437,12 @@
p.b;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_hasAssignment_outsideAfter() {
+ test_typePromotion_if_hasAssignment_outsideAfter() async {
Source source = addSource(r'''
main(Object p) {
if (p is String) {
@@ -5460,12 +5450,12 @@
}
p = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_hasAssignment_outsideBefore() {
+ test_typePromotion_if_hasAssignment_outsideBefore() async {
Source source = addSource(r'''
main(Object p, Object p2) {
p = p2;
@@ -5473,12 +5463,12 @@
p.length;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_implements_moreSpecific() {
+ test_typePromotion_if_implements_moreSpecific() async {
Source source = addSource(r'''
class V {}
class VP extends V {}
@@ -5492,12 +5482,12 @@
p.b;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_inClosure_assignedAfter_inSameFunction() {
+ test_typePromotion_if_inClosure_assignedAfter_inSameFunction() async {
Source source = addSource(r'''
main() {
f(Object p) {
@@ -5507,12 +5497,12 @@
p = 0;
};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_is_and_left() {
+ test_typePromotion_if_is_and_left() async {
Source source = addSource(r'''
bool tt() => true;
main(Object p) {
@@ -5520,12 +5510,12 @@
p.length;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_is_and_right() {
+ test_typePromotion_if_is_and_right() async {
Source source = addSource(r'''
bool tt() => true;
main(Object p) {
@@ -5533,12 +5523,12 @@
p.length;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_is_and_subThenSuper() {
+ test_typePromotion_if_is_and_subThenSuper() async {
Source source = addSource(r'''
class A {
var a;
@@ -5552,36 +5542,36 @@
p.b;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_is_parenthesized() {
+ test_typePromotion_if_is_parenthesized() async {
Source source = addSource(r'''
main(Object p) {
if ((p is String)) {
p.length;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_if_is_single() {
+ test_typePromotion_if_is_single() async {
Source source = addSource(r'''
main(Object p) {
if (p is String) {
p.length;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typePromotion_parentheses() {
+ test_typePromotion_parentheses() async {
Source source = addSource(r'''
main(Object p) {
(p is String) ? p.length : 0;
@@ -5589,24 +5579,24 @@
((p)) is String ? p.length : 0;
((p) is String) ? p.length : 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeType_class() {
+ test_typeType_class() async {
Source source = addSource(r'''
class C {}
f(Type t) {}
main() {
f(C);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeType_class_prefixed() {
+ test_typeType_class_prefixed() async {
addNamedSource(
"/lib.dart",
r'''
@@ -5618,24 +5608,24 @@
main() {
f(p.C);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeType_functionTypeAlias() {
+ test_typeType_functionTypeAlias() async {
Source source = addSource(r'''
typedef F();
f(Type t) {}
main() {
f(F);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_typeType_functionTypeAlias_prefixed() {
+ test_typeType_functionTypeAlias_prefixed() async {
addNamedSource(
"/lib.dart",
r'''
@@ -5647,12 +5637,12 @@
main() {
f(p.F);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedConstructorInInitializer_explicit_named() {
+ test_undefinedConstructorInInitializer_explicit_named() async {
Source source = addSource(r'''
class A {
A.named() {}
@@ -5660,12 +5650,12 @@
class B extends A {
B() : super.named();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedConstructorInInitializer_explicit_unnamed() {
+ test_undefinedConstructorInInitializer_explicit_unnamed() async {
Source source = addSource(r'''
class A {
A() {}
@@ -5673,12 +5663,12 @@
class B extends A {
B() : super();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedConstructorInInitializer_hasOptionalParameters() {
+ test_undefinedConstructorInInitializer_hasOptionalParameters() async {
Source source = addSource(r'''
class A {
A([p]) {}
@@ -5686,12 +5676,12 @@
class B extends A {
B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedConstructorInInitializer_implicit() {
+ test_undefinedConstructorInInitializer_implicit() async {
Source source = addSource(r'''
class A {
A() {}
@@ -5699,24 +5689,24 @@
class B extends A {
B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedConstructorInInitializer_implicit_typeAlias() {
+ test_undefinedConstructorInInitializer_implicit_typeAlias() async {
Source source = addSource(r'''
class M {}
class A = Object with M;
class B extends A {
B();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedConstructorInInitializer_redirecting() {
+ test_undefinedConstructorInInitializer_redirecting() async {
Source source = addSource(r'''
class Foo {
Foo.ctor();
@@ -5725,12 +5715,12 @@
Bar() : this.ctor();
Bar.ctor() : super.ctor();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedGetter_static_conditionalAccess() {
+ test_undefinedGetter_static_conditionalAccess() async {
// The conditional access operator '?.' can be used to access static
// fields.
Source source = addSource('''
@@ -5739,12 +5729,12 @@
}
var a = A?.x;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedGetter_typeSubstitution() {
+ test_undefinedGetter_typeSubstitution() async {
Source source = addSource(r'''
class A<E> {
E element;
@@ -5754,52 +5744,52 @@
element.last;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedIdentifier_synthetic_whenExpression() {
+ test_undefinedIdentifier_synthetic_whenExpression() async {
Source source = addSource(r'''
print(x) {}
main() {
print(is String);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]);
}
- void test_undefinedIdentifier_synthetic_whenMethodName() {
+ test_undefinedIdentifier_synthetic_whenMethodName() async {
Source source = addSource(r'''
print(x) {}
main(int p) {
p.();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.MISSING_IDENTIFIER]);
}
- void test_undefinedMethod_functionExpression_callMethod() {
+ test_undefinedMethod_functionExpression_callMethod() async {
Source source = addSource(r'''
main() {
(() => null).call();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
// A call to verify(source) fails as '.call()' isn't resolved.
}
- void test_undefinedMethod_functionExpression_directCall() {
+ test_undefinedMethod_functionExpression_directCall() async {
Source source = addSource(r'''
main() {
(() => null)();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
// A call to verify(source) fails as '(() => null)()' isn't resolved.
}
- void test_undefinedMethod_static_conditionalAccess() {
+ test_undefinedMethod_static_conditionalAccess() async {
// The conditional access operator '?.' can be used to access static
// methods.
Source source = addSource('''
@@ -5808,12 +5798,12 @@
}
f() { A?.m(); }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedOperator_index() {
+ test_undefinedOperator_index() async {
Source source = addSource(r'''
class A {
operator [](a) {}
@@ -5823,21 +5813,21 @@
a[0];
a[0] = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedOperator_tilde() {
+ test_undefinedOperator_tilde() async {
Source source = addSource(r'''
const A = 3;
const B = ~((1 << A) - 1);''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedSetter_importWithPrefix() {
+ test_undefinedSetter_importWithPrefix() async {
addNamedSource(
"/lib.dart",
r'''
@@ -5848,12 +5838,12 @@
main() {
x.y = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedSetter_static_conditionalAccess() {
+ test_undefinedSetter_static_conditionalAccess() async {
// The conditional access operator '?.' can be used to access static
// fields.
Source source = addSource('''
@@ -5862,12 +5852,12 @@
}
f() { A?.x = 1; }
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedSuperMethod_field() {
+ test_undefinedSuperMethod_field() async {
Source source = addSource(r'''
class A {
var m;
@@ -5877,12 +5867,12 @@
super.m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_undefinedSuperMethod_method() {
+ test_undefinedSuperMethod_method() async {
Source source = addSource(r'''
class A {
m() {}
@@ -5892,12 +5882,12 @@
super.m();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() {
+ test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() async {
Source source = addSource(r'''
class A {
A() {}
@@ -5906,145 +5896,145 @@
/// [new A] or [new A.named]
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedShownName_unresolved() {
+ test_unusedShownName_unresolved() async {
Source source = addSource(r'''
import 'dart:math' show max, FooBar;
main() {
print(max(1, 2));
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [HintCode.UNDEFINED_SHOWN_NAME]);
}
- void test_uriDoesNotExist_dll() {
+ test_uriDoesNotExist_dll() async {
addNamedSource("/lib.dll", "");
Source source = addSource("import 'dart-ext:lib';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_uriDoesNotExist_dylib() {
+ test_uriDoesNotExist_dylib() async {
addNamedSource("/lib.dylib", "");
Source source = addSource("import 'dart-ext:lib';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_uriDoesNotExist_so() {
+ test_uriDoesNotExist_so() async {
addNamedSource("/lib.so", "");
Source source = addSource("import 'dart-ext:lib';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_wrongNumberOfParametersForOperator1() {
- _check_wrongNumberOfParametersForOperator1("<");
- _check_wrongNumberOfParametersForOperator1(">");
- _check_wrongNumberOfParametersForOperator1("<=");
- _check_wrongNumberOfParametersForOperator1(">=");
- _check_wrongNumberOfParametersForOperator1("+");
- _check_wrongNumberOfParametersForOperator1("/");
- _check_wrongNumberOfParametersForOperator1("~/");
- _check_wrongNumberOfParametersForOperator1("*");
- _check_wrongNumberOfParametersForOperator1("%");
- _check_wrongNumberOfParametersForOperator1("|");
- _check_wrongNumberOfParametersForOperator1("^");
- _check_wrongNumberOfParametersForOperator1("&");
- _check_wrongNumberOfParametersForOperator1("<<");
- _check_wrongNumberOfParametersForOperator1(">>");
- _check_wrongNumberOfParametersForOperator1("[]");
+ test_wrongNumberOfParametersForOperator1() async {
+ await _check_wrongNumberOfParametersForOperator1("<");
+ await _check_wrongNumberOfParametersForOperator1(">");
+ await _check_wrongNumberOfParametersForOperator1("<=");
+ await _check_wrongNumberOfParametersForOperator1(">=");
+ await _check_wrongNumberOfParametersForOperator1("+");
+ await _check_wrongNumberOfParametersForOperator1("/");
+ await _check_wrongNumberOfParametersForOperator1("~/");
+ await _check_wrongNumberOfParametersForOperator1("*");
+ await _check_wrongNumberOfParametersForOperator1("%");
+ await _check_wrongNumberOfParametersForOperator1("|");
+ await _check_wrongNumberOfParametersForOperator1("^");
+ await _check_wrongNumberOfParametersForOperator1("&");
+ await _check_wrongNumberOfParametersForOperator1("<<");
+ await _check_wrongNumberOfParametersForOperator1(">>");
+ await _check_wrongNumberOfParametersForOperator1("[]");
}
- void test_wrongNumberOfParametersForOperator_index() {
+ test_wrongNumberOfParametersForOperator_index() async {
Source source = addSource(r'''
class A {
operator []=(a, b) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_wrongNumberOfParametersForOperator_minus() {
- _check_wrongNumberOfParametersForOperator("-", "");
- _check_wrongNumberOfParametersForOperator("-", "a");
+ test_wrongNumberOfParametersForOperator_minus() async {
+ await _check_wrongNumberOfParametersForOperator("-", "");
+ await _check_wrongNumberOfParametersForOperator("-", "a");
}
- void test_wrongNumberOfParametersForSetter() {
+ test_wrongNumberOfParametersForSetter() async {
Source source = addSource(r'''
class A {
set x(a) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_async_to_dynamic_type() {
+ test_yield_async_to_dynamic_type() async {
Source source = addSource('''
dynamic f() async* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_async_to_generic_type() {
+ test_yield_async_to_generic_type() async {
Source source = addSource('''
import 'dart:async';
Stream f() async* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_async_to_parameterized_type() {
+ test_yield_async_to_parameterized_type() async {
Source source = addSource('''
import 'dart:async';
Stream<int> f() async* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_async_to_untyped() {
+ test_yield_async_to_untyped() async {
Source source = addSource('''
f() async* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_async_dynamic_to_dynamic() {
+ test_yield_each_async_dynamic_to_dynamic() async {
Source source = addSource('''
f() async* {
yield* g();
}
g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_async_dynamic_to_stream() {
+ test_yield_each_async_dynamic_to_stream() async {
Source source = addSource('''
import 'dart:async';
Stream f() async* {
@@ -6052,12 +6042,12 @@
}
g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_async_dynamic_to_typed_stream() {
+ test_yield_each_async_dynamic_to_typed_stream() async {
Source source = addSource('''
import 'dart:async';
Stream<int> f() async* {
@@ -6065,12 +6055,12 @@
}
g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_async_stream_to_dynamic() {
+ test_yield_each_async_stream_to_dynamic() async {
Source source = addSource('''
import 'dart:async';
f() async* {
@@ -6078,12 +6068,12 @@
}
Stream g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_async_typed_stream_to_dynamic() {
+ test_yield_each_async_typed_stream_to_dynamic() async {
Source source = addSource('''
import 'dart:async';
f() async* {
@@ -6091,12 +6081,12 @@
}
Stream<int> g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_async_typed_stream_to_typed_stream() {
+ test_yield_each_async_typed_stream_to_typed_stream() async {
Source source = addSource('''
import 'dart:async';
Stream<int> f() async* {
@@ -6104,163 +6094,164 @@
}
Stream<int> g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_sync_dynamic_to_dynamic() {
+ test_yield_each_sync_dynamic_to_dynamic() async {
Source source = addSource('''
f() sync* {
yield* g();
}
g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_sync_dynamic_to_iterable() {
+ test_yield_each_sync_dynamic_to_iterable() async {
Source source = addSource('''
Iterable f() sync* {
yield* g();
}
g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_sync_dynamic_to_typed_iterable() {
+ test_yield_each_sync_dynamic_to_typed_iterable() async {
Source source = addSource('''
Iterable<int> f() sync* {
yield* g();
}
g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_sync_iterable_to_dynamic() {
+ test_yield_each_sync_iterable_to_dynamic() async {
Source source = addSource('''
f() sync* {
yield* g();
}
Iterable g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_sync_typed_iterable_to_dynamic() {
+ test_yield_each_sync_typed_iterable_to_dynamic() async {
Source source = addSource('''
f() sync* {
yield* g();
}
Iterable<int> g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_each_sync_typed_iterable_to_typed_iterable() {
+ test_yield_each_sync_typed_iterable_to_typed_iterable() async {
Source source = addSource('''
Iterable<int> f() sync* {
yield* g();
}
Iterable<int> g() => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_sync_to_dynamic_type() {
+ test_yield_sync_to_dynamic_type() async {
Source source = addSource('''
dynamic f() sync* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_sync_to_generic_type() {
+ test_yield_sync_to_generic_type() async {
Source source = addSource('''
Iterable f() sync* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_sync_to_parameterized_type() {
+ test_yield_sync_to_parameterized_type() async {
Source source = addSource('''
Iterable<int> f() sync* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yield_sync_to_untyped() {
+ test_yield_sync_to_untyped() async {
Source source = addSource('''
f() sync* {
yield 3;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yieldInNonGenerator_asyncStar() {
+ test_yieldInNonGenerator_asyncStar() async {
Source source = addSource(r'''
f() async* {
yield 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_yieldInNonGenerator_syncStar() {
+ test_yieldInNonGenerator_syncStar() async {
Source source = addSource(r'''
f() sync* {
yield 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void _check_wrongNumberOfParametersForOperator(
- String name, String parameters) {
+ Future<Null> _check_wrongNumberOfParametersForOperator(
+ String name, String parameters) async {
Source source = addSource("""
class A {
operator $name($parameters) {}
}""");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
reset();
}
- void _check_wrongNumberOfParametersForOperator1(String name) {
- _check_wrongNumberOfParametersForOperator(name, "a");
+ Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async {
+ await _check_wrongNumberOfParametersForOperator(name, "a");
}
- CompilationUnit _getResolvedLibraryUnit(Source source) =>
- analysisContext.getResolvedCompilationUnit2(source, source);
+ Future<CompilationUnit> _getResolvedLibraryUnit(Source source) async {
+ return analysisContext.getResolvedCompilationUnit2(source, source);
+ }
}
diff --git a/pkg/analyzer/test/generated/non_hint_code_test.dart b/pkg/analyzer/test/generated/non_hint_code_test.dart
index 2ef678b..04a5623 100644
--- a/pkg/analyzer/test/generated/non_hint_code_test.dart
+++ b/pkg/analyzer/test/generated/non_hint_code_test.dart
@@ -15,29 +15,13 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(NonHintCodeTest);
+ defineReflectiveTests(NonHintCodeTest_Driver);
});
}
@reflectiveTest
class NonHintCodeTest extends ResolverTestCase {
- void test_() {
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
- Source source = addSource(r'''
-abstract class A {
- void test();
-}
-class B extends A {
- void test() {
- super.test;
- }
-}
-''');
- computeLibrarySourceErrors(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- void test_deadCode_afterTryCatch() {
+ test_deadCode_afterTryCatch() async {
Source source = addSource('''
main() {
try {
@@ -51,45 +35,45 @@
throw 'foo';
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_conditionalElse_debugConst() {
+ test_deadCode_deadBlock_conditionalElse_debugConst() async {
Source source = addSource(r'''
const bool DEBUG = true;
f() {
DEBUG ? 1 : 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_conditionalIf_debugConst() {
+ test_deadCode_deadBlock_conditionalIf_debugConst() async {
Source source = addSource(r'''
const bool DEBUG = false;
f() {
DEBUG ? 1 : 2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_else() {
+ test_deadCode_deadBlock_else() async {
Source source = addSource(r'''
const bool DEBUG = true;
f() {
if(DEBUG) {} else {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier() {
+ test_deadCode_deadBlock_if_debugConst_prefixedIdentifier() async {
Source source = addSource(r'''
class A {
static const bool DEBUG = false;
@@ -97,12 +81,12 @@
f() {
if(A.DEBUG) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2() {
+ test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2() async {
Source source = addSource(r'''
library L;
import 'lib2.dart';
@@ -116,12 +100,12 @@
class A {
static const bool DEBUG = false;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_if_debugConst_propertyAccessor() {
+ test_deadCode_deadBlock_if_debugConst_propertyAccessor() async {
Source source = addSource(r'''
library L;
import 'lib2.dart' as LIB;
@@ -135,46 +119,46 @@
class A {
static const bool DEBUG = false;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_if_debugConst_simpleIdentifier() {
+ test_deadCode_deadBlock_if_debugConst_simpleIdentifier() async {
Source source = addSource(r'''
const bool DEBUG = false;
f() {
if(DEBUG) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadBlock_while_debugConst() {
+ test_deadCode_deadBlock_while_debugConst() async {
Source source = addSource(r'''
const bool DEBUG = false;
f() {
while(DEBUG) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadCatch_onCatchSubtype() {
+ test_deadCode_deadCatch_onCatchSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {}
f() {
try {} on B catch (e) {} on A catch (e) {} catch (e) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadFinalBreakInCase() {
+ test_deadCode_deadFinalBreakInCase() async {
Source source = addSource(r'''
f() {
switch (true) {
@@ -189,34 +173,34 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadOperandLHS_and_debugConst() {
+ test_deadCode_deadOperandLHS_and_debugConst() async {
Source source = addSource(r'''
const bool DEBUG = false;
f() {
bool b = DEBUG && false;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_deadOperandLHS_or_debugConst() {
+ test_deadCode_deadOperandLHS_or_debugConst() async {
Source source = addSource(r'''
const bool DEBUG = true;
f() {
bool b = DEBUG || true;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deadCode_statementAfterIfWithoutElse() {
+ test_deadCode_statementAfterIfWithoutElse() async {
Source source = addSource(r'''
f() {
if (1 < 0) {
@@ -224,12 +208,12 @@
}
int a = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deprecatedMemberUse_inDeprecatedClass() {
+ test_deprecatedMemberUse_inDeprecatedClass() async {
Source source = addSource(r'''
@deprecated
f() {}
@@ -241,12 +225,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deprecatedMemberUse_inDeprecatedFunction() {
+ test_deprecatedMemberUse_inDeprecatedFunction() async {
Source source = addSource(r'''
@deprecated
f() {}
@@ -256,12 +240,12 @@
f();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deprecatedMemberUse_inDeprecatedLibrary() {
+ test_deprecatedMemberUse_inDeprecatedLibrary() async {
Source source = addSource(r'''
@deprecated
library lib;
@@ -275,12 +259,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deprecatedMemberUse_inDeprecatedMethod() {
+ test_deprecatedMemberUse_inDeprecatedMethod() async {
Source source = addSource(r'''
@deprecated
f() {}
@@ -292,12 +276,12 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_deprecatedMemberUse_inDeprecatedMethod_inDeprecatedClass() {
+ test_deprecatedMemberUse_inDeprecatedMethod_inDeprecatedClass() async {
Source source = addSource(r'''
@deprecated
f() {}
@@ -310,32 +294,32 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_divisionOptimization() {
+ test_divisionOptimization() async {
Source source = addSource(r'''
f(int x, int y) {
var v = x / y.toInt();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_divisionOptimization_supressIfDivisionNotDefinedInCore() {
+ test_divisionOptimization_supressIfDivisionNotDefinedInCore() async {
Source source = addSource(r'''
f(x, y) {
var v = (x / y).toInt();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_divisionOptimization_supressIfDivisionOverridden() {
+ test_divisionOptimization_supressIfDivisionOverridden() async {
Source source = addSource(r'''
class A {
num operator /(x) { return x; }
@@ -343,12 +327,12 @@
f(A x, A y) {
var v = (x / y).toInt();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_duplicateImport_as() {
+ test_duplicateImport_as() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -360,12 +344,12 @@
r'''
library lib1;
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_duplicateImport_hide() {
+ test_duplicateImport_hide() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -378,12 +362,12 @@
library lib1;
class A {}
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_duplicateImport_show() {
+ test_duplicateImport_show() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -396,13 +380,13 @@
library lib1;
class A {}
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_importDeferredLibraryWithLoadFunction() {
- resolveWithErrors(<String>[
+ test_importDeferredLibraryWithLoadFunction() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
f() {}''',
@@ -413,7 +397,7 @@
], const <ErrorCode>[]);
}
- void test_issue20904BuggyTypePromotionAtIfJoin_1() {
+ test_issue20904BuggyTypePromotionAtIfJoin_1() async {
// https://code.google.com/p/dart/issues/detail?id=20904
Source source = addSource(r'''
f(var message, var dynamic_) {
@@ -422,12 +406,12 @@
}
int s = message;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_issue20904BuggyTypePromotionAtIfJoin_3() {
+ test_issue20904BuggyTypePromotionAtIfJoin_3() async {
// https://code.google.com/p/dart/issues/detail?id=20904
Source source = addSource(r'''
f(var message) {
@@ -439,12 +423,12 @@
}
int s = message;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_issue20904BuggyTypePromotionAtIfJoin_4() {
+ test_issue20904BuggyTypePromotionAtIfJoin_4() async {
// https://code.google.com/p/dart/issues/detail?id=20904
Source source = addSource(r'''
f(var message) {
@@ -455,76 +439,76 @@
}
String s = message;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_missingReturn_emptyFunctionBody() {
+ test_missingReturn_emptyFunctionBody() async {
Source source = addSource(r'''
abstract class A {
int m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_missingReturn_expressionFunctionBody() {
+ test_missingReturn_expressionFunctionBody() async {
Source source = addSource("int f() => 0;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_missingReturn_noReturnType() {
+ test_missingReturn_noReturnType() async {
Source source = addSource("f() {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_missingReturn_voidReturnType() {
+ test_missingReturn_voidReturnType() async {
Source source = addSource("void f() {}");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nullAwareInCondition_for_noCondition() {
+ test_nullAwareInCondition_for_noCondition() async {
Source source = addSource(r'''
m(x) {
for (var v = x; ; v++) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_nullAwareInCondition_if_notTopLevel() {
+ test_nullAwareInCondition_if_notTopLevel() async {
Source source = addSource(r'''
m(x) {
if (x?.y == null) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideEqualsButNotHashCode() {
+ test_overrideEqualsButNotHashCode() async {
Source source = addSource(r'''
class A {
bool operator ==(x) { return x; }
get hashCode => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingField_inInterface() {
+ test_overrideOnNonOverridingField_inInterface() async {
Source source = addSource(r'''
class A {
int get a => 0;
@@ -539,12 +523,12 @@
@override
int c;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingField_inSuperclass() {
+ test_overrideOnNonOverridingField_inSuperclass() async {
Source source = addSource(r'''
class A {
int get a => 0;
@@ -559,12 +543,12 @@
@override
int c;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingGetter_inInterface() {
+ test_overrideOnNonOverridingGetter_inInterface() async {
Source source = addSource(r'''
class A {
int get m => 0;
@@ -573,12 +557,12 @@
@override
int get m => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingGetter_inSuperclass() {
+ test_overrideOnNonOverridingGetter_inSuperclass() async {
Source source = addSource(r'''
class A {
int get m => 0;
@@ -587,12 +571,12 @@
@override
int get m => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingMethod_inInterface() {
+ test_overrideOnNonOverridingMethod_inInterface() async {
Source source = addSource(r'''
class A {
int m() => 0;
@@ -601,12 +585,12 @@
@override
int m() => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingMethod_inSuperclass() {
+ test_overrideOnNonOverridingMethod_inSuperclass() async {
Source source = addSource(r'''
class A {
int m() => 0;
@@ -615,12 +599,12 @@
@override
int m() => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingMethod_inSuperclass_abstract() {
+ test_overrideOnNonOverridingMethod_inSuperclass_abstract() async {
Source source = addSource(r'''
abstract class A {
int m();
@@ -629,12 +613,12 @@
@override
int m() => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingSetter_inInterface() {
+ test_overrideOnNonOverridingSetter_inInterface() async {
Source source = addSource(r'''
class A {
set m(int x) {}
@@ -643,12 +627,12 @@
@override
set m(int x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_overrideOnNonOverridingSetter_inSuperclass() {
+ test_overrideOnNonOverridingSetter_inSuperclass() async {
Source source = addSource(r'''
class A {
set m(int x) {}
@@ -657,12 +641,12 @@
@override
set m(int x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_propagatedFieldType() {
+ test_propagatedFieldType() async {
Source source = addSource(r'''
class A { }
class X<T> {
@@ -674,12 +658,12 @@
y.x.add(new A());
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_proxy_annotation_prefixed() {
+ test_proxy_annotation_prefixed() async {
Source source = addSource(r'''
library L;
@proxy
@@ -693,11 +677,11 @@
a++;
++a;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_prefixed2() {
+ test_proxy_annotation_prefixed2() async {
Source source = addSource(r'''
library L;
@proxy
@@ -713,11 +697,11 @@
++a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_proxy_annotation_prefixed3() {
+ test_proxy_annotation_prefixed3() async {
Source source = addSource(r'''
library L;
class B {
@@ -733,11 +717,11 @@
}
@proxy
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedGetter_inSubtype() {
+ test_undefinedGetter_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -748,11 +732,11 @@
return a.b;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedMethod_assignmentExpression_inSubtype() {
+ test_undefinedMethod_assignmentExpression_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -763,21 +747,21 @@
a2 = new A();
a += a2;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedMethod_dynamic() {
+ test_undefinedMethod_dynamic() async {
Source source = addSource(r'''
class D<T extends dynamic> {
fieldAccess(T t) => t.abc;
methodAccess(T t) => t.xyz(1, 2, 'three');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedMethod_inSubtype() {
+ test_undefinedMethod_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -787,11 +771,11 @@
var a = new A();
a.b();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedMethod_unionType_all() {
+ test_undefinedMethod_unionType_all() async {
Source source = addSource(r'''
class A {
int m(int x) => 0;
@@ -808,11 +792,11 @@
}
ab.m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedMethod_unionType_some() {
+ test_undefinedMethod_unionType_some() async {
Source source = addSource(r'''
class A {
int m(int x) => 0;
@@ -827,11 +811,11 @@
}
ab.m(0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedOperator_binaryExpression_inSubtype() {
+ test_undefinedOperator_binaryExpression_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -842,11 +826,11 @@
a + 1;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedOperator_indexBoth_inSubtype() {
+ test_undefinedOperator_indexBoth_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -857,11 +841,11 @@
a[0]++;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedOperator_indexGetter_inSubtype() {
+ test_undefinedOperator_indexGetter_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -872,11 +856,11 @@
a[0];
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedOperator_indexSetter_inSubtype() {
+ test_undefinedOperator_indexSetter_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -887,11 +871,11 @@
a[0] = 1;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedOperator_postfixExpression() {
+ test_undefinedOperator_postfixExpression() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -902,11 +886,11 @@
a++;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedOperator_prefixExpression() {
+ test_undefinedOperator_prefixExpression() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -917,11 +901,11 @@
++a;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_undefinedSetter_inSubtype() {
+ test_undefinedSetter_inSubtype() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -932,11 +916,11 @@
a.b = 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_unnecessaryCast_13855_parameter_A() {
+ test_unnecessaryCast_13855_parameter_A() async {
// dartbug.com/13855, dartbug.com/13732
Source source = addSource(r'''
class A{
@@ -948,12 +932,12 @@
(e as A).a();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryCast_conditionalExpression() {
+ test_unnecessaryCast_conditionalExpression() async {
Source source = addSource(r'''
abstract class I {}
class A implements I {}
@@ -961,22 +945,22 @@
I m(A a, B b) {
return a == null ? b as I : a as I;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryCast_dynamic_type() {
+ test_unnecessaryCast_dynamic_type() async {
Source source = addSource(r'''
m(v) {
var b = v as Object;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryCast_generics() {
+ test_unnecessaryCast_generics() async {
// dartbug.com/18953
Source source = addSource(r'''
import 'dart:async';
@@ -984,22 +968,22 @@
void g(bool c) {
(c ? f(): new Future.value(0) as Future<int>).then((int value) {});
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryCast_type_dynamic() {
+ test_unnecessaryCast_type_dynamic() async {
Source source = addSource(r'''
m(v) {
var b = Object as dynamic;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryNoSuchMethod_blockBody_notReturnStatement() {
+ test_unnecessaryNoSuchMethod_blockBody_notReturnStatement() async {
Source source = addSource(r'''
class A {
noSuchMethod(x) => super.noSuchMethod(x);
@@ -1010,12 +994,12 @@
print(y);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryNoSuchMethod_blockBody_notSingleStatement() {
+ test_unnecessaryNoSuchMethod_blockBody_notSingleStatement() async {
Source source = addSource(r'''
class A {
noSuchMethod(x) => super.noSuchMethod(x);
@@ -1027,12 +1011,12 @@
return super.noSuchMethod(y);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryNoSuchMethod_expressionBody_notNoSuchMethod() {
+ test_unnecessaryNoSuchMethod_expressionBody_notNoSuchMethod() async {
Source source = addSource(r'''
class A {
noSuchMethod(x) => super.noSuchMethod(x);
@@ -1041,12 +1025,12 @@
mmm();
noSuchMethod(y) => super.hashCode;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unnecessaryNoSuchMethod_expressionBody_notSuper() {
+ test_unnecessaryNoSuchMethod_expressionBody_notSuper() async {
Source source = addSource(r'''
class A {
noSuchMethod(x) => super.noSuchMethod(x);
@@ -1055,12 +1039,12 @@
mmm();
noSuchMethod(y) => 42;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedImport_annotationOnDirective() {
+ test_unusedImport_annotationOnDirective() async {
Source source = addSource(r'''
library L;
@A()
@@ -1072,12 +1056,13 @@
class A {
const A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
assertErrors(source);
verify([source, source2]);
}
- void test_unusedImport_as_equalPrefixes() {
+ test_unusedImport_as_equalPrefixes() async {
// 18818
Source source = addSource(r'''
library L;
@@ -1095,23 +1080,25 @@
r'''
library lib2;
class B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(source2);
+ await computeAnalysisResult(source3);
assertErrors(source);
assertNoErrors(source2);
assertNoErrors(source3);
verify([source, source2, source3]);
}
- void test_unusedImport_core_library() {
+ test_unusedImport_core_library() async {
Source source = addSource(r'''
library L;
import 'dart:core';''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedImport_export() {
+ test_unusedImport_export() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -1127,12 +1114,12 @@
r'''
library lib2;
class Two {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedImport_export2() {
+ test_unusedImport_export2() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -1154,12 +1141,12 @@
r'''
library lib3;
class Three {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedImport_export_infiniteLoop() {
+ test_unusedImport_export_infiniteLoop() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -1182,12 +1169,12 @@
library lib3;
export 'lib2.dart';
class Three {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedImport_metadata() {
+ test_unusedImport_metadata() async {
Source source = addSource(r'''
library L;
@A(x)
@@ -1201,12 +1188,12 @@
r'''
library lib1;
const x = 0;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedImport_prefix_topLevelFunction() {
+ test_unusedImport_prefix_topLevelFunction() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' hide topLevelFunction;
@@ -1223,12 +1210,12 @@
library lib1;
class One {}
topLevelFunction() {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_unusedImport_prefix_topLevelFunction2() {
+ test_unusedImport_prefix_topLevelFunction2() async {
Source source = addSource(r'''
library L;
import 'lib1.dart' hide topLevelFunction;
@@ -1247,12 +1234,12 @@
library lib1;
class One {}
topLevelFunction() {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_useOfVoidResult_implicitReturnValue() {
+ test_useOfVoidResult_implicitReturnValue() async {
Source source = addSource(r'''
f() {}
class A {
@@ -1260,108 +1247,131 @@
var a = f();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_useOfVoidResult_nonVoidReturnValue() {
+ test_useOfVoidResult_nonVoidReturnValue() async {
Source source = addSource(r'''
int f() => 1;
g() {
var a = f();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ test_withSuperMixin() async {
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
+ Source source = addSource(r'''
+abstract class A {
+ void test();
+}
+class B extends A {
+ void test() {
+ super.test;
+ }
+}
+''');
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
}
+@reflectiveTest
+class NonHintCodeTest_Driver extends NonHintCodeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
+
class PubSuggestionCodeTest extends ResolverTestCase {
- void test_import_package() {
+ test_import_package() async {
Source source = addSource("import 'package:somepackage/other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
}
- void test_import_packageWithDotDot() {
+ test_import_packageWithDotDot() async {
Source source = addSource("import 'package:somepackage/../other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.URI_DOES_NOT_EXIST,
HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT
]);
}
- void test_import_packageWithLeadingDotDot() {
+ test_import_packageWithLeadingDotDot() async {
Source source = addSource("import 'package:../other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
CompileTimeErrorCode.URI_DOES_NOT_EXIST,
HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT
]);
}
- void test_import_referenceIntoLibDirectory() {
- cacheSource("/myproj/pubspec.yaml", "");
- cacheSource("/myproj/lib/other.dart", "");
+ test_import_referenceIntoLibDirectory() async {
+ addNamedSource("/myproj/pubspec.yaml", "");
+ addNamedSource("/myproj/lib/other.dart", "");
Source source =
addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE]);
}
- void test_import_referenceIntoLibDirectory_no_pubspec() {
- cacheSource("/myproj/lib/other.dart", "");
+ test_import_referenceIntoLibDirectory_no_pubspec() async {
+ addNamedSource("/myproj/lib/other.dart", "");
Source source =
addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_import_referenceOutOfLibDirectory() {
- cacheSource("/myproj/pubspec.yaml", "");
- cacheSource("/myproj/web/other.dart", "");
+ test_import_referenceOutOfLibDirectory() async {
+ addNamedSource("/myproj/pubspec.yaml", "");
+ addNamedSource("/myproj/web/other.dart", "");
Source source =
addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE]);
}
- void test_import_referenceOutOfLibDirectory_no_pubspec() {
- cacheSource("/myproj/web/other.dart", "");
+ test_import_referenceOutOfLibDirectory_no_pubspec() async {
+ addNamedSource("/myproj/web/other.dart", "");
Source source =
addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_import_valid_inside_lib1() {
- cacheSource("/myproj/pubspec.yaml", "");
- cacheSource("/myproj/lib/other.dart", "");
+ test_import_valid_inside_lib1() async {
+ addNamedSource("/myproj/pubspec.yaml", "");
+ addNamedSource("/myproj/lib/other.dart", "");
Source source =
addNamedSource("/myproj/lib/test.dart", "import 'other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_import_valid_inside_lib2() {
- cacheSource("/myproj/pubspec.yaml", "");
- cacheSource("/myproj/lib/bar/other.dart", "");
+ test_import_valid_inside_lib2() async {
+ addNamedSource("/myproj/pubspec.yaml", "");
+ addNamedSource("/myproj/lib/bar/other.dart", "");
Source source = addNamedSource(
"/myproj/lib/foo/test.dart", "import '../bar/other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_import_valid_outside_lib() {
- cacheSource("/myproj/pubspec.yaml", "");
- cacheSource("/myproj/web/other.dart", "");
+ test_import_valid_outside_lib() async {
+ addNamedSource("/myproj/pubspec.yaml", "");
+ addNamedSource("/myproj/web/other.dart", "");
Source source =
addNamedSource("/myproj/lib2/test.dart", "import '../web/other.dart';");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
}
diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
index d85fc09..9a2611f 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -3822,7 +3822,7 @@
VariableDeclaration field = fields[0];
expect(field.name.name, 'f');
// validate the type
- TypeArgumentList typeArguments = fieldList.type.typeArguments;
+ TypeArgumentList typeArguments = (fieldList.type as TypeName).typeArguments;
expect(typeArguments.arguments, hasLength(1));
// synthetic '>'
Token token = typeArguments.endToken;
@@ -3869,9 +3869,9 @@
expect(expression.expression, isNotNull);
expect(expression.isOperator, isNotNull);
expect(expression.notOperator, isNotNull);
- TypeName type = expression.type;
+ TypeAnnotation type = expression.type;
expect(type, isNotNull);
- expect(type.name.isSynthetic, isTrue);
+ expect(type is TypeName && type.name.isSynthetic, isTrue);
EngineTestCase.assertInstanceOf((obj) => obj is EmptyStatement,
EmptyStatement, ifStatement.thenStatement);
}
@@ -6042,7 +6042,7 @@
expect(method.externalKeyword, isNull);
expect(method.modifierKeyword, isNull);
expect(method.propertyKeyword, isNull);
- expect(method.returnType.name.name, 'T');
+ expect((method.returnType as TypeName).name.name, 'T');
expect(method.name, isNotNull);
expect(method.operatorKeyword, isNull);
expect(method.typeParameters, isNotNull);
@@ -6062,14 +6062,14 @@
expect(method.externalKeyword, isNull);
expect(method.modifierKeyword, isNull);
expect(method.propertyKeyword, isNull);
- expect(method.returnType.name.name, 'T');
+ expect((method.returnType as TypeName).name.name, 'T');
expect(method.name, isNotNull);
expect(method.operatorKeyword, isNull);
expect(method.typeParameters, isNotNull);
TypeParameter tp = method.typeParameters.typeParameters[0];
expect(tp.name.name, 'T');
expect(tp.extendsKeyword, isNotNull);
- expect(tp.bound.name.name, 'num');
+ expect((tp.bound as TypeName).name.name, 'num');
expect(method.parameters, isNotNull);
expect(method.body, isNotNull);
}
@@ -10150,9 +10150,9 @@
expect(name.period, isNull);
expect(name.name, isNull);
expect(expression.argumentList, isNotNull);
- NodeList<TypeName> arguments = type.typeArguments.arguments;
+ NodeList<TypeAnnotation> arguments = type.typeArguments.arguments;
expect(arguments, hasLength(1));
- expect(arguments[0].question, isNotNull);
+ expect((arguments[0] as TypeName).question, isNotNull);
}
void test_parseLibraryDirective() {
@@ -13073,7 +13073,7 @@
.parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata());
expectNotNullIfNoErrors(declarationList);
listener.assertNoErrors();
- expect(declarationList.type.name.name, 'T');
+ expect((declarationList.type as TypeName).name.name, 'T');
expect(declarationList.isFinal, true);
}
@@ -13128,7 +13128,7 @@
.parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata());
expectNotNullIfNoErrors(declarationList);
listener.assertNoErrors();
- expect(declarationList.type.name.name, 'T');
+ expect((declarationList.type as TypeName).name.name, 'T');
expect(declarationList.keyword, isNull);
}
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 0a01df5..d559010 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -4,11 +4,12 @@
library analyzer.test.generated.resolver_test;
+import 'dart:async';
import 'dart:collection';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/ast/standard_ast_factory.dart';
+import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -51,6 +52,8 @@
defineReflectiveTests(TypePropagationTest);
defineReflectiveTests(TypeProviderImplTest);
defineReflectiveTests(TypeResolverVisitorTest);
+ defineReflectiveTests(StrictModeTest_Driver);
+ defineReflectiveTests(TypePropagationTest_Driver);
});
}
@@ -146,7 +149,7 @@
@reflectiveTest
class EnclosedScopeTest extends ResolverTestCase {
- void test_define_duplicate() {
+ test_define_duplicate() async {
Scope rootScope = new _RootScope();
EnclosedScope scope = new EnclosedScope(rootScope);
SimpleIdentifier identifier = AstTestFactory.identifier3('v');
@@ -160,7 +163,7 @@
@reflectiveTest
class ErrorResolverTest extends ResolverTestCase {
- void test_breakLabelOnSwitchMember() {
+ test_breakLabelOnSwitchMember() async {
Source source = addSource(r'''
class A {
void m(int i) {
@@ -172,12 +175,12 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]);
verify([source]);
}
- void test_continueLabelOnSwitch() {
+ test_continueLabelOnSwitch() async {
Source source = addSource(r'''
class A {
void m(int i) {
@@ -187,12 +190,12 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]);
verify([source]);
}
- void test_enclosingElement_invalidLocalFunction() {
+ test_enclosingElement_invalidLocalFunction() async {
Source source = addSource(r'''
class C {
C() {
@@ -217,6 +220,7 @@
expect(functions, isNotNull);
expect(functions, hasLength(1));
expect(functions[0].enclosingElement, constructor);
+ await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.GETTER_IN_FUNCTION]);
}
}
@@ -226,7 +230,7 @@
*/
@reflectiveTest
class GenericMethodResolverTest extends StaticTypeAnalyzer2TestShared {
- void test_genericMethod_propagatedType_promotion() {
+ test_genericMethod_propagatedType_promotion() async {
// Regression test for:
// https://github.com/dart-lang/sdk/issues/25340
//
@@ -235,7 +239,7 @@
// therefore discard the propagated type.
//
// So this test does not use strong mode.
- resolveTestUnit(r'''
+ await resolveTestUnit(r'''
abstract class Iter {
List<S> map<S>(S f(x));
}
@@ -409,9 +413,9 @@
List<Expression> _invalidlyPropagatedExpressions = new List<Expression>();
/**
- * A list containing all of the AST TypeName nodes that were not resolved.
+ * The TypeAnnotation nodes that were not resolved.
*/
- List<TypeName> _unresolvedTypes = new List<TypeName>();
+ List<TypeAnnotation> _unresolvedTypes = new List<TypeAnnotation>();
/**
* Counter for the number of Expression nodes visited that are resolved.
@@ -441,7 +445,7 @@
buffer.write(" of ");
buffer.write(_resolvedTypeCount + unresolvedTypeCount);
buffer.writeln(" type names:");
- for (TypeName identifier in _unresolvedTypes) {
+ for (TypeAnnotation identifier in _unresolvedTypes) {
buffer.write(" ");
buffer.write(identifier.toString());
buffer.write(" (");
@@ -575,9 +579,21 @@
}
@override
+ Object visitTypeAnnotation(TypeAnnotation node) {
+ if (node.type == null) {
+ _unresolvedTypes.add(node);
+ } else {
+ _resolvedTypeCount++;
+ }
+ return super.visitTypeAnnotation(node);
+ }
+
+ @override
Object visitTypeName(TypeName node) {
// Note: do not visit children from this node, the child SimpleIdentifier in
// TypeName (i.e. "String") does not have a static type defined.
+ // TODO(brianwilkerson) Not visiting the children means that we won't catch
+ // type arguments that were not resolved.
if (node.type == null) {
_unresolvedTypes.add(node);
} else {
@@ -615,7 +631,7 @@
*/
@reflectiveTest
class StrictModeTest extends ResolverTestCase {
- void fail_for() {
+ fail_for() async {
Source source = addSource(r'''
int f(List<int> list) {
num sum = 0;
@@ -623,7 +639,7 @@
sum += list[i];
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
@@ -631,56 +647,56 @@
void setUp() {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.hint = false;
- resetWithOptions(options);
+ resetWith(options: options);
}
- void test_assert_is() {
+ test_assert_is() async {
Source source = addSource(r'''
int f(num n) {
assert (n is int);
return n & 0x0F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_conditional_and_is() {
+ test_conditional_and_is() async {
Source source = addSource(r'''
int f(num n) {
return (n is int && n > 0) ? n & 0x0F : 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_conditional_is() {
+ test_conditional_is() async {
Source source = addSource(r'''
int f(num n) {
return (n is int) ? n & 0x0F : 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_conditional_isNot() {
+ test_conditional_isNot() async {
Source source = addSource(r'''
int f(num n) {
return (n is! int) ? 0 : n & 0x0F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_conditional_or_is() {
+ test_conditional_or_is() async {
Source source = addSource(r'''
int f(num n) {
return (n is! int || n < 0) ? 0 : n & 0x0F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_forEach() {
+ test_forEach() async {
Source source = addSource(r'''
int f(List<int> list) {
num sum = 0;
@@ -688,11 +704,11 @@
sum += n & 0x0F;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_if_and_is() {
+ test_if_and_is() async {
Source source = addSource(r'''
int f(num n) {
if (n is int && n > 0) {
@@ -700,11 +716,11 @@
}
return 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_if_is() {
+ test_if_is() async {
Source source = addSource(r'''
int f(num n) {
if (n is int) {
@@ -712,11 +728,11 @@
}
return 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_if_isNot() {
+ test_if_isNot() async {
Source source = addSource(r'''
int f(num n) {
if (n is! int) {
@@ -725,11 +741,11 @@
return n & 0x0F;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_if_isNot_abrupt() {
+ test_if_isNot_abrupt() async {
Source source = addSource(r'''
int f(num n) {
if (n is! int) {
@@ -737,11 +753,11 @@
}
return n & 0x0F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_if_or_is() {
+ test_if_or_is() async {
Source source = addSource(r'''
int f(num n) {
if (n is! int || n < 0) {
@@ -750,22 +766,28 @@
return n & 0x0F;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_localVar() {
+ test_localVar() async {
Source source = addSource(r'''
int f() {
num n = 1234;
return n & 0x0F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
}
@reflectiveTest
+class StrictModeTest_Driver extends StrictModeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
+
+@reflectiveTest
class SubtypeManagerTest {
/**
* The inheritance manager being tested.
@@ -930,9 +952,9 @@
@reflectiveTest
class TypePropagationTest extends ResolverTestCase {
- void fail_mergePropagatedTypesAtJoinPoint_1() {
+ fail_mergePropagatedTypesAtJoinPoint_1() async {
// https://code.google.com/p/dart/issues/detail?id=19929
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f1(x) {
var y = [];
@@ -949,9 +971,9 @@
typeProvider.dynamicType);
}
- void fail_mergePropagatedTypesAtJoinPoint_2() {
+ fail_mergePropagatedTypesAtJoinPoint_2() async {
// https://code.google.com/p/dart/issues/detail?id=19929
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f2(x) {
var y = [];
@@ -967,9 +989,9 @@
typeProvider.dynamicType);
}
- void fail_mergePropagatedTypesAtJoinPoint_3() {
+ fail_mergePropagatedTypesAtJoinPoint_3() async {
// https://code.google.com/p/dart/issues/detail?id=19929
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f4(x) {
var y = [];
@@ -987,9 +1009,9 @@
typeProvider.numType);
}
- void fail_mergePropagatedTypesAtJoinPoint_5() {
+ fail_mergePropagatedTypesAtJoinPoint_5() async {
// https://code.google.com/p/dart/issues/detail?id=19929
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f6(x,y) {
var z = [];
@@ -1005,7 +1027,7 @@
typeProvider.dynamicType);
}
- void fail_mergePropagatedTypesAtJoinPoint_7() {
+ fail_mergePropagatedTypesAtJoinPoint_7() async {
// https://code.google.com/p/dart/issues/detail?id=19929
//
// In general [continue]s are unsafe for the purposes of
@@ -1029,12 +1051,13 @@
x; // marker
}
}''';
- DartType t = findMarkedIdentifier(code, "; // marker").propagatedType;
+ DartType t =
+ (await findMarkedIdentifier(code, "; // marker")).propagatedType;
expect(typeProvider.intType.isSubtypeOf(t), isTrue);
expect(typeProvider.stringType.isSubtypeOf(t), isTrue);
}
- void fail_mergePropagatedTypesAtJoinPoint_8() {
+ fail_mergePropagatedTypesAtJoinPoint_8() async {
// https://code.google.com/p/dart/issues/detail?id=19929
//
// In nested loops [breaks]s are unsafe for the purposes of
@@ -1061,22 +1084,23 @@
}
}
}''';
- DartType t = findMarkedIdentifier(code, "; // marker").propagatedType;
+ DartType t =
+ (await findMarkedIdentifier(code, "; // marker")).propagatedType;
expect(typeProvider.intType.isSubtypeOf(t), isTrue);
expect(typeProvider.stringType.isSubtypeOf(t), isTrue);
}
- void fail_propagatedReturnType_functionExpression() {
+ fail_propagatedReturnType_functionExpression() async {
// TODO(scheglov) disabled because we don't resolve function expression
String code = r'''
main() {
var v = (() {return 42;})();
}''';
- assertPropagatedAssignedType(
+ await assertPropagatedAssignedType(
code, typeProvider.dynamicType, typeProvider.intType);
}
- void test_as() {
+ test_as() async {
Source source = addSource(r'''
class A {
bool get g => true;
@@ -1088,10 +1112,7 @@
return null;
}
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1105,17 +1126,14 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_assert() {
+ test_assert() async {
Source source = addSource(r'''
class A {}
A f(var p) {
assert (p is A);
return p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1127,17 +1145,14 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_assignment() {
+ test_assignment() async {
Source source = addSource(r'''
f() {
var v;
v = 0;
return v;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1146,17 +1161,14 @@
expect(variableName.propagatedType, same(typeProvider.intType));
}
- void test_assignment_afterInitializer() {
+ test_assignment_afterInitializer() async {
Source source = addSource(r'''
f() {
var v = 0;
v = 1.0;
return v;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1165,7 +1177,7 @@
expect(variableName.propagatedType, same(typeProvider.doubleType));
}
- void test_assignment_null() {
+ test_assignment_null() async {
String code = r'''
main() {
int v; // declare
@@ -1175,10 +1187,10 @@
CompilationUnit unit;
{
Source source = addSource(code);
- LibraryElement library = resolve2(source);
+ TestAnalysisResult analysisResult = await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- unit = resolveCompilationUnit(source, library);
+ unit = analysisResult.unit;
}
{
SimpleIdentifier identifier = EngineTestCase.findNode(
@@ -1200,24 +1212,21 @@
}
}
- void test_CanvasElement_getContext() {
+ test_CanvasElement_getContext() async {
String code = r'''
import 'dart:html';
main(CanvasElement canvas) {
var context = canvas.getContext('2d');
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
SimpleIdentifier identifier = EngineTestCase.findNode(
unit, code, "context", (node) => node is SimpleIdentifier);
expect(resolutionMap.propagatedTypeForExpression(identifier).name,
"CanvasRenderingContext2D");
}
- void test_forEach() {
+ test_forEach() async {
String code = r'''
main() {
var list = <String> [];
@@ -1226,10 +1235,7 @@
}
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
InterfaceType stringType = typeProvider.stringType;
// in the declaration
{
@@ -1245,7 +1251,7 @@
}
}
- void test_forEach_async() {
+ test_forEach_async() async {
String code = r'''
import 'dart:async';
f(Stream<String> stream) async {
@@ -1254,10 +1260,7 @@
}
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
InterfaceType stringType = typeProvider.stringType;
// in the declaration
{
@@ -1273,7 +1276,7 @@
}
}
- void test_forEach_async_inheritedStream() {
+ test_forEach_async_inheritedStream() async {
// From https://github.com/dart-lang/sdk/issues/24191, this ensures that
// `await for` works for types where the generic parameter doesn't
// correspond to the type of the Stream's data.
@@ -1286,10 +1289,7 @@
}
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
InterfaceType listOfStringType =
typeProvider.listType.instantiate([typeProvider.stringType]);
// in the declaration
@@ -1306,7 +1306,7 @@
}
}
- void test_functionExpression_asInvocationArgument() {
+ test_functionExpression_asInvocationArgument() async {
String code = r'''
class MyMap<K, V> {
forEach(f(K key, V value)) {}
@@ -1318,10 +1318,7 @@
});
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
// k
DartType intType = typeProvider.intType;
FormalParameter kParameter = EngineTestCase.findNode(
@@ -1342,7 +1339,7 @@
expect(vIdentifier.staticType, same(typeProvider.dynamicType));
}
- void test_functionExpression_asInvocationArgument_fromInferredInvocation() {
+ test_functionExpression_asInvocationArgument_fromInferredInvocation() async {
String code = r'''
class MyMap<K, V> {
forEach(f(K key, V value)) {}
@@ -1352,10 +1349,7 @@
m2.forEach((k, v) {});
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
// k
DartType intType = typeProvider.intType;
FormalParameter kParameter = EngineTestCase.findNode(
@@ -1368,8 +1362,7 @@
expect(vParameter.identifier.propagatedType, same(stringType));
}
- void
- test_functionExpression_asInvocationArgument_functionExpressionInvocation() {
+ test_functionExpression_asInvocationArgument_functionExpressionInvocation() async {
String code = r'''
main() {
(f(String value)) {} ((v) {
@@ -1377,10 +1370,7 @@
});
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
// v
DartType dynamicType = typeProvider.dynamicType;
DartType stringType = typeProvider.stringType;
@@ -1394,7 +1384,7 @@
expect(vIdentifier.staticType, same(dynamicType));
}
- void test_functionExpression_asInvocationArgument_keepIfLessSpecific() {
+ test_functionExpression_asInvocationArgument_keepIfLessSpecific() async {
String code = r'''
class MyList {
forEach(f(Object value)) {}
@@ -1405,10 +1395,7 @@
});
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
// v
DartType intType = typeProvider.intType;
FormalParameter vParameter = EngineTestCase.findNode(
@@ -1421,7 +1408,7 @@
expect(vIdentifier.propagatedType, same(null));
}
- void test_functionExpression_asInvocationArgument_notSubtypeOfStaticType() {
+ test_functionExpression_asInvocationArgument_notSubtypeOfStaticType() async {
String code = r'''
class A {
m(void f(int i)) {}
@@ -1431,10 +1418,8 @@
a.m(() => 0);
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
+ CompilationUnit unit = await _computeResolvedUnit(source, noErrors: false);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
// () => 0
FunctionExpression functionExpression = EngineTestCase.findNode(
unit, code, "() => 0)", (node) => node is FunctionExpression);
@@ -1443,7 +1428,7 @@
expect(functionExpression.propagatedType, same(null));
}
- void test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() {
+ test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() async {
String code = r'''
class MyList<E> {
forEach(f(E value)) {}
@@ -1454,10 +1439,7 @@
});
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
// v
DartType stringType = typeProvider.stringType;
FormalParameter vParameter = EngineTestCase.findNode(
@@ -1469,7 +1451,7 @@
expect(vIdentifier.propagatedType, same(stringType));
}
- void test_Future_then() {
+ test_Future_then() async {
String code = r'''
import 'dart:async';
main(Future<int> firstFuture) {
@@ -1481,10 +1463,7 @@
});
}''';
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
// p1
FormalParameter p1 = EngineTestCase.findNode(
unit, code, "p1) {", (node) => node is SimpleFormalParameter);
@@ -1499,16 +1478,13 @@
expect(p3.identifier.propagatedType, same(typeProvider.stringType));
}
- void test_initializer() {
+ test_initializer() async {
Source source = addSource(r'''
f() {
var v = 0;
return v;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1529,14 +1505,13 @@
}
}
- void test_initializer_dereference() {
+ test_initializer_dereference() async {
Source source = addSource(r'''
f() {
var v = 'String';
v.
}''');
- LibraryElement library = resolve2(source);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source, noErrors: false);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1547,16 +1522,13 @@
expect(variableName.propagatedType, same(typeProvider.stringType));
}
- void test_initializer_hasStaticType() {
+ test_initializer_hasStaticType() async {
Source source = addSource(r'''
f() {
int v = 0;
return v;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1578,16 +1550,13 @@
}
}
- void test_initializer_hasStaticType_parameterized() {
+ test_initializer_hasStaticType_parameterized() async {
Source source = addSource(r'''
f() {
List<int> v = <int>[];
return v;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1609,7 +1578,7 @@
}
}
- void test_initializer_null() {
+ test_initializer_null() async {
String code = r'''
main() {
int v = null;
@@ -1618,10 +1587,7 @@
CompilationUnit unit;
{
Source source = addSource(code);
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- unit = resolveCompilationUnit(source, library);
+ unit = await _computeResolvedUnit(source);
}
{
SimpleIdentifier identifier = EngineTestCase.findNode(
@@ -1637,7 +1603,7 @@
}
}
- void test_invocation_target_prefixed() {
+ test_invocation_target_prefixed() async {
addNamedSource(
'/helper.dart',
'''
@@ -1650,22 +1616,19 @@
helper.max(10, 10); // marker
}''';
SimpleIdentifier methodName =
- findMarkedIdentifier(code, "(10, 10); // marker");
+ await findMarkedIdentifier(code, "(10, 10); // marker");
MethodInvocation methodInvoke = methodName.parent;
expect(methodInvoke.methodName.staticElement, isNotNull);
expect(methodInvoke.methodName.propagatedElement, isNull);
}
- void test_is_conditional() {
+ test_is_conditional() async {
Source source = addSource(r'''
class A {}
A f(var p) {
return (p is A) ? p : null;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1680,7 +1643,7 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_is_if() {
+ test_is_if() async {
Source source = addSource(r'''
class A {}
A f(var p) {
@@ -1690,10 +1653,7 @@
return null;
}
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
// prepare A
InterfaceType typeA;
{
@@ -1720,7 +1680,7 @@
}
}
- void test_is_if_lessSpecific() {
+ test_is_if_lessSpecific() async {
Source source = addSource(r'''
class A {}
A f(A p) {
@@ -1730,12 +1690,7 @@
return null;
}
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
-// ClassDeclaration classA = (ClassDeclaration) unit.getDeclarations().get(0);
-// InterfaceType typeA = classA.getElement().getType();
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1746,7 +1701,7 @@
expect(variableName.propagatedType, same(null));
}
- void test_is_if_logicalAnd() {
+ test_is_if_logicalAnd() async {
Source source = addSource(r'''
class A {}
A f(var p) {
@@ -1756,10 +1711,7 @@
return null;
}
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1773,17 +1725,14 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_is_postConditional() {
+ test_is_postConditional() async {
Source source = addSource(r'''
class A {}
A f(var p) {
A a = (p is A) ? p : throw null;
return p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1795,7 +1744,7 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_is_postIf() {
+ test_is_postIf() async {
Source source = addSource(r'''
class A {}
A f(var p) {
@@ -1806,10 +1755,7 @@
}
return p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1821,7 +1767,7 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_is_subclass() {
+ test_is_subclass() async {
Source source = addSource(r'''
class A {}
class B extends A {
@@ -1833,9 +1779,7 @@
}
return p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -1847,7 +1791,7 @@
expect(invocation.methodName.propagatedElement, isNull);
}
- void test_is_while() {
+ test_is_while() async {
Source source = addSource(r'''
class A {}
A f(var p) {
@@ -1856,10 +1800,7 @@
}
return p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1873,16 +1814,13 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_isNot_conditional() {
+ test_isNot_conditional() async {
Source source = addSource(r'''
class A {}
A f(var p) {
return (p is! A) ? null : p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1897,7 +1835,7 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_isNot_if() {
+ test_isNot_if() async {
Source source = addSource(r'''
class A {}
A f(var p) {
@@ -1907,10 +1845,7 @@
return p;
}
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1924,7 +1859,7 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_isNot_if_logicalOr() {
+ test_isNot_if_logicalOr() async {
Source source = addSource(r'''
class A {}
A f(var p) {
@@ -1934,9 +1869,7 @@
return p;
}
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source, noErrors: false);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1950,17 +1883,14 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_isNot_postConditional() {
+ test_isNot_postConditional() async {
Source source = addSource(r'''
class A {}
A f(var p) {
A a = (p is! A) ? throw null : p;
return p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1972,7 +1902,7 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_isNot_postIf() {
+ test_isNot_postIf() async {
Source source = addSource(r'''
class A {}
A f(var p) {
@@ -1981,10 +1911,7 @@
}
return p;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
InterfaceType typeA =
resolutionMap.elementDeclaredByClassDeclaration(classA).type;
@@ -1996,7 +1923,7 @@
expect(variableName.propagatedType, same(typeA));
}
- void test_issue20904BuggyTypePromotionAtIfJoin_5() {
+ test_issue20904BuggyTypePromotionAtIfJoin_5() async {
// https://code.google.com/p/dart/issues/detail?id=20904
//
// This is not an example of the 20904 bug, but rather,
@@ -2026,11 +1953,11 @@
return a; // marker
}
}''';
- DartType tB = findMarkedIdentifier(code, "; // B").propagatedType;
- assertTypeOfMarkedExpression(code, null, tB);
+ DartType tB = (await findMarkedIdentifier(code, "; // B")).propagatedType;
+ await assertTypeOfMarkedExpression(code, null, tB);
}
- void test_issue20904BuggyTypePromotionAtIfJoin_6() {
+ test_issue20904BuggyTypePromotionAtIfJoin_6() async {
// https://code.google.com/p/dart/issues/detail?id=20904
//
// The other half of the *_5() test.
@@ -2046,20 +1973,17 @@
return b; // marker
}
}''';
- DartType tB = findMarkedIdentifier(code, "; // B").propagatedType;
- assertTypeOfMarkedExpression(code, null, tB);
+ DartType tB = (await findMarkedIdentifier(code, "; // B")).propagatedType;
+ await assertTypeOfMarkedExpression(code, null, tB);
}
- void test_listLiteral_different() {
+ test_listLiteral_different() async {
Source source = addSource(r'''
f() {
var v = [0, '1', 2];
return v[2];
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -2068,16 +1992,13 @@
expect(indexExpression.propagatedType, isNull);
}
- void test_listLiteral_same() {
+ test_listLiteral_same() async {
Source source = addSource(r'''
f() {
var v = [0, 1, 2];
return v[2];
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -2092,16 +2013,13 @@
expect(typeArguments[0], same(typeProvider.dynamicType));
}
- void test_mapLiteral_different() {
+ test_mapLiteral_different() async {
Source source = addSource(r'''
f() {
var v = {'0' : 0, 1 : '1', '2' : 2};
return v;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -2115,16 +2033,13 @@
expect(typeArguments[1], same(typeProvider.dynamicType));
}
- void test_mapLiteral_same() {
+ test_mapLiteral_same() async {
Source source = addSource(r'''
f() {
var v = {'a' : 0, 'b' : 1, 'c' : 2};
return v;
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body =
function.functionExpression.body as BlockFunctionBody;
@@ -2138,7 +2053,7 @@
expect(typeArguments[1], same(typeProvider.dynamicType));
}
- void test_mergePropagatedTypes_afterIfThen_different() {
+ test_mergePropagatedTypes_afterIfThen_different() async {
String code = r'''
main() {
var v = 0;
@@ -2148,17 +2063,17 @@
return v;
}''';
{
- SimpleIdentifier identifier = findMarkedIdentifier(code, "v;");
+ SimpleIdentifier identifier = await findMarkedIdentifier(code, "v;");
expect(identifier.propagatedType, null);
}
{
- SimpleIdentifier identifier = findMarkedIdentifier(code, "v = '';");
+ SimpleIdentifier identifier = await findMarkedIdentifier(code, "v = '';");
expect(identifier.propagatedType, typeProvider.stringType);
}
}
- void test_mergePropagatedTypes_afterIfThen_same() {
- assertTypeOfMarkedExpression(
+ test_mergePropagatedTypes_afterIfThen_same() async {
+ await assertTypeOfMarkedExpression(
r'''
main() {
var v = 1;
@@ -2171,8 +2086,8 @@
typeProvider.intType);
}
- void test_mergePropagatedTypes_afterIfThenElse_different() {
- assertTypeOfMarkedExpression(
+ test_mergePropagatedTypes_afterIfThenElse_different() async {
+ await assertTypeOfMarkedExpression(
r'''
main() {
var v = 1;
@@ -2187,8 +2102,8 @@
null);
}
- void test_mergePropagatedTypes_afterIfThenElse_same() {
- assertTypeOfMarkedExpression(
+ test_mergePropagatedTypes_afterIfThenElse_same() async {
+ await assertTypeOfMarkedExpression(
r'''
main() {
var v = 1;
@@ -2203,9 +2118,9 @@
typeProvider.intType);
}
- void test_mergePropagatedTypesAtJoinPoint_4() {
+ test_mergePropagatedTypesAtJoinPoint_4() async {
// https://code.google.com/p/dart/issues/detail?id=19929
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f5(x) {
var y = [];
@@ -2221,7 +2136,7 @@
typeProvider.intType);
}
- void test_mutatedOutsideScope() {
+ test_mutatedOutsideScope() async {
// https://code.google.com/p/dart/issues/detail?id=22732
Source source = addSource(r'''
class Base {
@@ -2248,11 +2163,11 @@
}
x = null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_objectAccessInference_disabled_for_library_prefix() {
+ test_objectAccessInference_disabled_for_library_prefix() async {
String name = 'hashCode';
addNamedSource(
'/helper.dart',
@@ -2266,13 +2181,13 @@
helper.$name; // marker
}''';
- SimpleIdentifier id = findMarkedIdentifier(code, "; // marker");
+ SimpleIdentifier id = await findMarkedIdentifier(code, "; // marker");
PrefixedIdentifier prefixedId = id.parent;
expect(id.staticType, typeProvider.dynamicType);
expect(prefixedId.staticType, typeProvider.dynamicType);
}
- void test_objectAccessInference_disabled_for_local_getter() {
+ test_objectAccessInference_disabled_for_local_getter() async {
String name = 'hashCode';
String code = '''
dynamic get $name => null;
@@ -2280,23 +2195,24 @@
$name; // marker
}''';
- SimpleIdentifier getter = findMarkedIdentifier(code, "; // marker");
+ SimpleIdentifier getter = await findMarkedIdentifier(code, "; // marker");
expect(getter.staticType, typeProvider.dynamicType);
}
- void test_objectAccessInference_enabled_for_cascades() {
+ test_objectAccessInference_enabled_for_cascades() async {
String name = 'hashCode';
String code = '''
main() {
dynamic obj;
obj..$name..$name; // marker
}''';
- PropertyAccess access = findMarkedIdentifier(code, "; // marker").parent;
+ PropertyAccess access =
+ (await findMarkedIdentifier(code, "; // marker")).parent;
expect(access.staticType, typeProvider.dynamicType);
expect(access.realTarget.staticType, typeProvider.dynamicType);
}
- void test_objectMethodInference_disabled_for_library_prefix() {
+ test_objectMethodInference_disabled_for_library_prefix() async {
String name = 'toString';
addNamedSource(
'/helper.dart',
@@ -2309,50 +2225,53 @@
main() {
helper.$name(); // marker
}''';
- SimpleIdentifier methodName = findMarkedIdentifier(code, "(); // marker");
+ SimpleIdentifier methodName =
+ await findMarkedIdentifier(code, "(); // marker");
MethodInvocation methodInvoke = methodName.parent;
expect(methodName.staticType, typeProvider.dynamicType);
expect(methodInvoke.staticType, typeProvider.dynamicType);
}
- void test_objectMethodInference_disabled_for_local_function() {
+ test_objectMethodInference_disabled_for_local_function() async {
String name = 'toString';
String code = '''
main() {
dynamic $name = () => null;
$name(); // marker
}''';
- SimpleIdentifier identifier = findMarkedIdentifier(code, "$name = ");
+ SimpleIdentifier identifier = await findMarkedIdentifier(code, "$name = ");
expect(identifier.staticType, typeProvider.dynamicType);
- SimpleIdentifier methodName = findMarkedIdentifier(code, "(); // marker");
+ SimpleIdentifier methodName =
+ await findMarkedIdentifier(code, "(); // marker");
MethodInvocation methodInvoke = methodName.parent;
expect(methodName.staticType, typeProvider.dynamicType);
expect(methodInvoke.staticType, typeProvider.dynamicType);
}
- void test_objectMethodInference_enabled_for_cascades() {
+ test_objectMethodInference_enabled_for_cascades() async {
String name = 'toString';
String code = '''
main() {
dynamic obj;
obj..$name()..$name(); // marker
}''';
- SimpleIdentifier methodName = findMarkedIdentifier(code, "(); // marker");
+ SimpleIdentifier methodName =
+ await findMarkedIdentifier(code, "(); // marker");
MethodInvocation methodInvoke = methodName.parent;
expect(methodInvoke.staticType, typeProvider.dynamicType);
expect(methodInvoke.realTarget.staticType, typeProvider.dynamicType);
}
- void test_objectMethodOnDynamicExpression_doubleEquals() {
+ test_objectMethodOnDynamicExpression_doubleEquals() async {
// https://code.google.com/p/dart/issues/detail?id=20342
//
// This was not actually part of Issue 20342, since the spec specifies a
// static type of [bool] for [==] comparison and the implementation
// was already consistent with the spec there. But, it's another
// [Object] method, so it's included here.
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f1(x) {
var v = (x == x);
@@ -2362,9 +2281,9 @@
typeProvider.boolType);
}
- void test_objectMethodOnDynamicExpression_hashCode() {
+ test_objectMethodOnDynamicExpression_hashCode() async {
// https://code.google.com/p/dart/issues/detail?id=20342
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f1(x) {
var v = x.hashCode;
@@ -2374,9 +2293,9 @@
typeProvider.intType);
}
- void test_objectMethodOnDynamicExpression_runtimeType() {
+ test_objectMethodOnDynamicExpression_runtimeType() async {
// https://code.google.com/p/dart/issues/detail?id=20342
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f1(x) {
var v = x.runtimeType;
@@ -2386,9 +2305,9 @@
typeProvider.typeType);
}
- void test_objectMethodOnDynamicExpression_toString() {
+ test_objectMethodOnDynamicExpression_toString() async {
// https://code.google.com/p/dart/issues/detail?id=20342
- assertTypeOfMarkedExpression(
+ await assertTypeOfMarkedExpression(
r'''
f1(x) {
var v = x.toString();
@@ -2398,17 +2317,17 @@
typeProvider.stringType);
}
- void test_propagatedReturnType_localFunction() {
+ test_propagatedReturnType_localFunction() async {
String code = r'''
main() {
f() => 42;
var v = f();
}''';
- assertPropagatedAssignedType(
+ await assertPropagatedAssignedType(
code, typeProvider.dynamicType, typeProvider.intType);
}
- void test_query() {
+ test_query() async {
Source source = addSource(r'''
import 'dart:html';
@@ -2428,10 +2347,7 @@
var b3 = query('body div');
return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];
}''');
- LibraryElement library = resolve2(source);
- assertNoErrors(source);
- verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
+ CompilationUnit unit = await _computeResolvedUnit(source);
FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration;
BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody;
ReturnStatement statement = body.block.statements[11] as ReturnStatement;
@@ -2460,6 +2376,33 @@
expect(resolutionMap.propagatedTypeForExpression(elements[10]).name,
"Element");
}
+
+ /**
+ * Return the resolved unit for the given [source].
+ *
+ * If [noErrors] is not specified or is not `true`, [assertNoErrors].
+ */
+ Future<CompilationUnit> _computeResolvedUnit(Source source,
+ {bool noErrors: true}) async {
+ TestAnalysisResult analysisResult = await computeAnalysisResult(source);
+ if (noErrors) {
+ assertNoErrors(source);
+ verify([source]);
+ }
+ return analysisResult.unit;
+ }
+}
+
+@reflectiveTest
+class TypePropagationTest_Driver extends TypePropagationTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ @failingTest
+ @override
+ test_query() {
+ return super.test_query();
+ }
}
@reflectiveTest
@@ -2583,17 +2526,17 @@
*/
TypeResolverVisitor _visitor;
- void fail_visitConstructorDeclaration() {
+ fail_visitConstructorDeclaration() async {
fail("Not yet tested");
_listener.assertNoErrors();
}
- void fail_visitFunctionTypeAlias() {
+ fail_visitFunctionTypeAlias() async {
fail("Not yet tested");
_listener.assertNoErrors();
}
- void fail_visitVariableDeclaration() {
+ fail_visitVariableDeclaration() async {
fail("Not yet tested");
ClassElement type = ElementFactory.classElement2("A");
VariableDeclaration node = AstTestFactory.variableDeclaration("a");
@@ -2622,7 +2565,7 @@
nameScope: libraryScope);
}
- void test_modeApi() {
+ test_modeApi() async {
CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
class C extends A with A implements A {
A f = new A();
@@ -2723,7 +2666,7 @@
}
}
- void test_modeLocal_noContext() {
+ test_modeLocal_noContext() async {
CompilationUnit unit;
_resolveTypeModeLocal(
r'''
@@ -2837,7 +2780,7 @@
}
}
- void test_modeLocal_withContext_bad_methodBody() {
+ test_modeLocal_withContext_bad_methodBody() async {
expect(() {
_resolveTypeModeLocal(
r'''
@@ -2856,7 +2799,7 @@
}, throwsStateError);
}
- void test_modeLocal_withContext_bad_topLevelVariable_declaration() {
+ test_modeLocal_withContext_bad_topLevelVariable_declaration() async {
expect(() {
_resolveTypeModeLocal(
r'''
@@ -2868,7 +2811,7 @@
}, throwsStateError);
}
- void test_modeLocal_withContext_bad_topLevelVariable_initializer() {
+ test_modeLocal_withContext_bad_topLevelVariable_initializer() async {
expect(() {
_resolveTypeModeLocal(
r'''
@@ -2880,7 +2823,7 @@
}, throwsStateError);
}
- void test_modeLocal_withContext_class() {
+ test_modeLocal_withContext_class() async {
ClassDeclaration c;
_resolveTypeModeLocal(
r'''
@@ -2915,7 +2858,7 @@
}
}
- void test_modeLocal_withContext_inClass_constructor() {
+ test_modeLocal_withContext_inClass_constructor() async {
ConstructorDeclaration cc;
_resolveTypeModeLocal(
r'''
@@ -2940,7 +2883,7 @@
}
}
- void test_modeLocal_withContext_inClass_method() {
+ test_modeLocal_withContext_inClass_method() async {
MethodDeclaration m;
_resolveTypeModeLocal(
r'''
@@ -2975,7 +2918,7 @@
}
}
- void test_modeLocal_withContext_topLevelFunction() {
+ test_modeLocal_withContext_topLevelFunction() async {
FunctionDeclaration f;
_resolveTypeModeLocal(
r'''
@@ -2998,7 +2941,7 @@
expect(vd.variables.type.type.toString(), 'T');
}
- void test_modeLocal_withContext_topLevelVariable() {
+ test_modeLocal_withContext_topLevelVariable() async {
TopLevelVariableDeclaration v;
_resolveTypeModeLocal(
r'''
@@ -3016,7 +2959,7 @@
expect(vi.constructorName.type.type.toString(), 'A');
}
- void test_visitCatchClause_exception() {
+ test_visitCatchClause_exception() async {
// catch (e)
CatchClause clause = AstTestFactory.catchClause("e");
SimpleIdentifier exceptionParameter = clause.exceptionParameter;
@@ -3026,7 +2969,7 @@
_listener.assertNoErrors();
}
- void test_visitCatchClause_exception_stackTrace() {
+ test_visitCatchClause_exception_stackTrace() async {
// catch (e, s)
CatchClause clause = AstTestFactory.catchClause2("e", "s");
SimpleIdentifier exceptionParameter = clause.exceptionParameter;
@@ -3040,7 +2983,7 @@
_listener.assertNoErrors();
}
- void test_visitCatchClause_on_exception() {
+ test_visitCatchClause_on_exception() async {
// on E catch (e)
ClassElement exceptionElement = ElementFactory.classElement2("E");
TypeName exceptionType = AstTestFactory.typeName(exceptionElement);
@@ -3053,7 +2996,7 @@
_listener.assertNoErrors();
}
- void test_visitCatchClause_on_exception_stackTrace() {
+ test_visitCatchClause_on_exception_stackTrace() async {
// on E catch (e, s)
ClassElement exceptionElement = ElementFactory.classElement2("E");
TypeName exceptionType = AstTestFactory.typeName(exceptionElement);
@@ -3070,7 +3013,7 @@
_listener.assertNoErrors();
}
- void test_visitClassDeclaration() {
+ test_visitClassDeclaration() async {
// class A extends B with C implements D {}
// class B {}
// class C {}
@@ -3099,7 +3042,7 @@
_listener.assertNoErrors();
}
- void test_visitClassDeclaration_instanceMemberCollidesWithClass() {
+ test_visitClassDeclaration_instanceMemberCollidesWithClass() async {
// class A {}
// class B extends A {
// void A() {}
@@ -3119,7 +3062,7 @@
_listener.assertNoErrors();
}
- void test_visitClassTypeAlias() {
+ test_visitClassTypeAlias() async {
// class A = B with C implements D;
ClassElement elementA = ElementFactory.classElement2("A");
ClassElement elementB = ElementFactory.classElement2("B");
@@ -3143,7 +3086,7 @@
_listener.assertNoErrors();
}
- void test_visitClassTypeAlias_constructorWithOptionalParams_ignored() {
+ test_visitClassTypeAlias_constructorWithOptionalParams_ignored() async {
// class T {}
// class B {
// B.c1();
@@ -3184,7 +3127,7 @@
expect(constructor.parameters, isEmpty);
}
- void test_visitClassTypeAlias_constructorWithParams() {
+ test_visitClassTypeAlias_constructorWithParams() async {
// class T {}
// class B {
// B(T a0);
@@ -3218,7 +3161,7 @@
equals(constructorB.parameters[0].name));
}
- void test_visitClassTypeAlias_defaultConstructor() {
+ test_visitClassTypeAlias_defaultConstructor() async {
// class B {}
// class M {}
// class C = B with M
@@ -3246,7 +3189,7 @@
expect(constructor.parameters, isEmpty);
}
- void test_visitFieldFormalParameter_functionType() {
+ test_visitFieldFormalParameter_functionType() async {
InterfaceType intType = _typeProvider.intType;
TypeName intTypeName = AstTestFactory.typeName4("int");
String innerParameterName = "a";
@@ -3271,7 +3214,7 @@
_listener.assertNoErrors();
}
- void test_visitFieldFormalParameter_noType() {
+ test_visitFieldFormalParameter_noType() async {
String parameterName = "p";
FormalParameter node =
AstTestFactory.fieldFormalParameter(Keyword.VAR, null, parameterName);
@@ -3281,7 +3224,7 @@
_listener.assertNoErrors();
}
- void test_visitFieldFormalParameter_type() {
+ test_visitFieldFormalParameter_type() async {
InterfaceType intType = _typeProvider.intType;
TypeName intTypeName = AstTestFactory.typeName4("int");
String parameterName = "p";
@@ -3293,7 +3236,7 @@
_listener.assertNoErrors();
}
- void test_visitFunctionDeclaration() {
+ test_visitFunctionDeclaration() async {
// R f(P p) {}
// class R {}
// class P {}
@@ -3319,7 +3262,7 @@
_listener.assertNoErrors();
}
- void test_visitFunctionDeclaration_typeParameter() {
+ test_visitFunctionDeclaration_typeParameter() async {
// E f<E>(E e) {}
TypeParameterElement elementE = ElementFactory.typeParameterElement('E');
FunctionElementImpl elementF = ElementFactory.functionElement('f');
@@ -3343,7 +3286,7 @@
_listener.assertNoErrors();
}
- void test_visitFunctionTypedFormalParameter() {
+ test_visitFunctionTypedFormalParameter() async {
// R f(R g(P p)) {}
// class R {}
// class P {}
@@ -3374,7 +3317,7 @@
_listener.assertNoErrors();
}
- void test_visitFunctionTypedFormalParameter_typeParameter() {
+ test_visitFunctionTypedFormalParameter_typeParameter() async {
// R f(R g<E>(E e)) {}
// class R {}
ClassElement elementR = ElementFactory.classElement2('R');
@@ -3405,7 +3348,7 @@
_listener.assertNoErrors();
}
- void test_visitMethodDeclaration() {
+ test_visitMethodDeclaration() async {
// class A {
// R m(P p) {}
// }
@@ -3434,7 +3377,7 @@
_listener.assertNoErrors();
}
- void test_visitMethodDeclaration_typeParameter() {
+ test_visitMethodDeclaration_typeParameter() async {
// class A {
// E m<E>(E e) {}
// }
@@ -3461,7 +3404,7 @@
_listener.assertNoErrors();
}
- void test_visitSimpleFormalParameter_noType() {
+ test_visitSimpleFormalParameter_noType() async {
// p
FormalParameter node = AstTestFactory.simpleFormalParameter3("p");
node.identifier.staticElement =
@@ -3470,7 +3413,7 @@
_listener.assertNoErrors();
}
- void test_visitSimpleFormalParameter_type() {
+ test_visitSimpleFormalParameter_type() async {
// int p
InterfaceType intType = _typeProvider.intType;
ClassElement intElement = intType.element;
@@ -3483,7 +3426,7 @@
_listener.assertNoErrors();
}
- void test_visitTypeName_noParameters_noArguments() {
+ test_visitTypeName_noParameters_noArguments() async {
ClassElement classA = ElementFactory.classElement2("A");
TypeName typeName = AstTestFactory.typeName(classA);
typeName.type = null;
@@ -3492,7 +3435,7 @@
_listener.assertNoErrors();
}
- void test_visitTypeName_noParameters_noArguments_undefined() {
+ test_visitTypeName_noParameters_noArguments_undefined() async {
SimpleIdentifier id = AstTestFactory.identifier3("unknown")
..staticElement = new _StaleElement();
TypeName typeName = astFactory.typeName(id, null);
@@ -3502,7 +3445,7 @@
_listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]);
}
- void test_visitTypeName_parameters_arguments() {
+ test_visitTypeName_parameters_arguments() async {
ClassElement classA = ElementFactory.classElement2("A", ["E"]);
ClassElement classB = ElementFactory.classElement2("B");
TypeName typeName =
@@ -3517,7 +3460,7 @@
_listener.assertNoErrors();
}
- void test_visitTypeName_parameters_noArguments() {
+ test_visitTypeName_parameters_noArguments() async {
ClassElement classA = ElementFactory.classElement2("A", ["E"]);
TypeName typeName = AstTestFactory.typeName(classA);
typeName.type = null;
@@ -3530,7 +3473,7 @@
_listener.assertNoErrors();
}
- void test_visitTypeName_prefixed_noParameters_noArguments_undefined() {
+ test_visitTypeName_prefixed_noParameters_noArguments_undefined() async {
SimpleIdentifier prefix = AstTestFactory.identifier3("unknownPrefix")
..staticElement = new _StaleElement();
SimpleIdentifier suffix = AstTestFactory.identifier3("unknownSuffix")
@@ -3544,7 +3487,7 @@
_listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]);
}
- void test_visitTypeName_void() {
+ test_visitTypeName_void() async {
ClassElement classA = ElementFactory.classElement2("A");
TypeName typeName = AstTestFactory.typeName4("void");
_resolveNode(typeName, [classA]);
diff --git a/pkg/analyzer/test/generated/resolver_test_case.dart b/pkg/analyzer/test/generated/resolver_test_case.dart
index 8de57ce..509c639 100644
--- a/pkg/analyzer/test/generated/resolver_test_case.dart
+++ b/pkg/analyzer/test/generated/resolver_test_case.dart
@@ -4,24 +4,33 @@
library analyzer.test.generated.resolver_test_case;
+import 'dart:async';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
+import 'package:analyzer/source/package_map_resolver.dart';
+import 'package:analyzer/src/dart/analysis/byte_store.dart';
+import 'package:analyzer/src/dart/analysis/driver.dart';
+import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult;
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/resolver.dart';
+import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
import 'package:analyzer/src/generated/testing/element_factory.dart';
import 'package:test/test.dart';
+import '../src/dart/analysis/physical_sdk.dart' as physical_sdk;
import 'analysis_context_factory.dart';
import 'test_support.dart';
@@ -323,15 +332,29 @@
*/
bool enableUnusedLocalVariable = false;
+ final Map<Source, TestAnalysisResult> analysisResults = {};
+
+ StringBuffer _logBuffer = new StringBuffer();
+ FileContentOverlay _fileContentOverlay = new FileContentOverlay();
+ AnalysisDriver driver;
+
AnalysisContext get analysisContext => analysisContext2;
+ bool get enableNewAnalysisDriver => false;
+
/**
* Return a type provider that can be used to test the results of resolution.
*
* @return a type provider
* @throws AnalysisException if dart:core cannot be resolved
*/
- TypeProvider get typeProvider => analysisContext2.typeProvider;
+ TypeProvider get typeProvider {
+ if (enableNewAnalysisDriver) {
+ return driver.sourceFactory.dartSdk.context.typeProvider;
+ } else {
+ return analysisContext2.typeProvider;
+ }
+ }
/**
* Return a type system that can be used to test the results of resolution.
@@ -346,11 +369,17 @@
* set in the content provider. Return the source representing the added file.
*/
Source addNamedSource(String filePath, String contents) {
- Source source =
- cacheSource(resourceProvider.convertPath(filePath), contents);
- ChangeSet changeSet = new ChangeSet();
- changeSet.addedSource(source);
- analysisContext2.applyChanges(changeSet);
+ filePath = resourceProvider.convertPath(filePath);
+ File file = resourceProvider.newFile(filePath, contents);
+ Source source = file.createSource();
+ if (enableNewAnalysisDriver) {
+ driver.addFile(filePath);
+ } else {
+ analysisContext2.setContents(source, contents);
+ ChangeSet changeSet = new ChangeSet();
+ changeSet.addedSource(source);
+ analysisContext2.applyChanges(changeSet);
+ }
return source;
}
@@ -362,20 +391,18 @@
Source addSource(String contents) => addNamedSource("/test.dart", contents);
/**
- * Assert that the number of errors reported against the given source matches the number of errors
- * that are given and that they have the expected error codes. The order in which the errors were
- * gathered is ignored.
- *
- * @param source the source against which the errors should have been reported
- * @param expectedErrorCodes the error codes of the errors that should have been reported
- * @throws AnalysisException if the reported errors could not be computed
- * @throws AssertionFailedError if a different number of errors have been reported than were
- * expected
+ * Assert that the number of errors reported against the given
+ * [source] matches the number of errors that are given and that they have
+ * the expected error codes. The order in which the errors were gathered is
+ * ignored.
*/
void assertErrors(Source source,
[List<ErrorCode> expectedErrorCodes = const <ErrorCode>[]]) {
+ TestAnalysisResult result = analysisResults[source];
+ expect(result, isNotNull);
+
GatheringErrorListener errorListener = new GatheringErrorListener();
- for (AnalysisError error in analysisContext2.computeErrors(source)) {
+ for (AnalysisError error in result.errors) {
expect(error.source, source);
ErrorCode errorCode = error.errorCode;
if (!enableUnusedElement &&
@@ -400,9 +427,9 @@
* Like [assertErrors], but takes a string of source code.
*/
// TODO(rnystrom): Use this in more tests that have the same structure.
- void assertErrorsInCode(String code, List<ErrorCode> errors) {
+ Future<Null> assertErrorsInCode(String code, List<ErrorCode> errors) async {
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, errors);
verify([source]);
}
@@ -412,9 +439,10 @@
*
* Like [assertErrors], but takes a string of source code.
*/
- void assertErrorsInUnverifiedCode(String code, List<ErrorCode> errors) {
+ Future<Null> assertErrorsInUnverifiedCode(
+ String code, List<ErrorCode> errors) async {
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, errors);
}
@@ -433,9 +461,9 @@
* Asserts that [code] has no errors or warnings.
*/
// TODO(rnystrom): Use this in more tests that have the same structure.
- void assertNoErrorsInCode(String code) {
+ Future<Null> assertNoErrorsInCode(String code) async {
Source source = addSource(code);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
@@ -444,9 +472,9 @@
* @param code the code that assigns the value to the variable "v", no matter how. We check that
* "v" has expected static and propagated type.
*/
- void assertPropagatedAssignedType(String code, DartType expectedStaticType,
- DartType expectedPropagatedType) {
- SimpleIdentifier identifier = findMarkedIdentifier(code, "v = ");
+ Future<Null> assertPropagatedAssignedType(String code,
+ DartType expectedStaticType, DartType expectedPropagatedType) async {
+ SimpleIdentifier identifier = await findMarkedIdentifier(code, "v = ");
expect(identifier.staticType, same(expectedStaticType));
expect(identifier.propagatedType, same(expectedPropagatedType));
}
@@ -455,9 +483,9 @@
* @param code the code that iterates using variable "v". We check that
* "v" has expected static and propagated type.
*/
- void assertPropagatedIterationType(String code, DartType expectedStaticType,
- DartType expectedPropagatedType) {
- SimpleIdentifier identifier = findMarkedIdentifier(code, "v in ");
+ Future<Null> assertPropagatedIterationType(String code,
+ DartType expectedStaticType, DartType expectedPropagatedType) async {
+ SimpleIdentifier identifier = await findMarkedIdentifier(code, "v in ");
expect(identifier.staticType, same(expectedStaticType));
expect(identifier.propagatedType, same(expectedPropagatedType));
}
@@ -470,9 +498,10 @@
* @param expectedPropagatedType if non-null, check actual static type is equal to this.
* @throws Exception
*/
- void assertTypeOfMarkedExpression(String code, DartType expectedStaticType,
- DartType expectedPropagatedType) {
- SimpleIdentifier identifier = findMarkedIdentifier(code, "; // marker");
+ Future<Null> assertTypeOfMarkedExpression(String code,
+ DartType expectedStaticType, DartType expectedPropagatedType) async {
+ SimpleIdentifier identifier =
+ await findMarkedIdentifier(code, "; // marker");
if (expectedStaticType != null) {
expect(identifier.staticType, expectedStaticType);
}
@@ -480,16 +509,6 @@
}
/**
- * Cache the [contents] for the file at the given [filePath] but don't add the
- * source to the analysis context. The file path must be absolute.
- */
- Source cacheSource(String filePath, String contents) {
- Source source = resourceProvider.getFile(filePath).createSource();
- analysisContext2.setContents(source, contents);
- return source;
- }
-
- /**
* Change the contents of the given [source] to the given [contents].
*/
void changeSource(Source source, String contents) {
@@ -499,13 +518,24 @@
analysisContext2.applyChanges(changeSet);
}
- /**
- * Computes errors for the given [librarySource].
- * This assumes that the given [librarySource] and its parts have already
- * been added to the content provider using the method [addNamedSource].
- */
- void computeLibrarySourceErrors(Source librarySource) {
- analysisContext.computeErrors(librarySource);
+ Future<TestAnalysisResult> computeAnalysisResult(Source source) async {
+ TestAnalysisResult analysisResult;
+ if (enableNewAnalysisDriver) {
+ AnalysisResult result = await driver.getResult(source.fullName);
+ analysisResult =
+ new TestAnalysisResult(source, result.unit, result.errors);
+ } else {
+ analysisContext2.computeKindOf(source);
+ List<Source> libraries = analysisContext2.getLibrariesContaining(source);
+ if (libraries.length > 0) {
+ CompilationUnit unit =
+ analysisContext.resolveCompilationUnit2(source, libraries.first);
+ List<AnalysisError> errors = analysisContext.computeErrors(source);
+ analysisResult = new TestAnalysisResult(source, unit, errors);
+ }
+ }
+ analysisResults[source] = analysisResult;
+ return analysisResult;
}
/**
@@ -578,15 +608,14 @@
* @return expression marked by the marker.
* @throws Exception
*/
- SimpleIdentifier findMarkedIdentifier(String code, String marker) {
+ Future<SimpleIdentifier> findMarkedIdentifier(
+ String code, String marker) async {
try {
Source source = addSource(code);
- LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
- CompilationUnit unit = resolveCompilationUnit(source, library);
- // Could generalize this further by making [SimpleIdentifier.class] a
- // parameter.
+ CompilationUnit unit = analysisResults[source].unit;
return EngineTestCase.findNode(
unit, code, marker, (node) => node is SimpleIdentifier);
} catch (exception) {
@@ -602,7 +631,6 @@
Expression findTopLevelConstantExpression(
CompilationUnit compilationUnit, String name) =>
findTopLevelDeclaration(compilationUnit, name).initializer;
-
VariableDeclaration findTopLevelDeclaration(
CompilationUnit compilationUnit, String name) {
for (CompilationUnitMember member in compilationUnit.declarations) {
@@ -622,17 +650,65 @@
* Re-create the analysis context being used by the test case.
*/
void reset() {
- analysisContext2 = AnalysisContextFactory.contextWithCore(
- resourceProvider: resourceProvider);
+ resetWith();
}
/**
- * Re-create the analysis context being used by the test case and set the
- * [options] in the newly created context to the given [options].
+ * Re-create the analysis context being used by the test with the either given
+ * [options] or [packages].
*/
- void resetWithOptions(AnalysisOptions options) {
- analysisContext2 = AnalysisContextFactory.contextWithCoreAndOptions(options,
- resourceProvider: resourceProvider);
+ void resetWith({AnalysisOptions options, List<List<String>> packages}) {
+ if (options != null && packages != null) {
+ fail('Only packages or options can be specified.');
+ }
+ if (enableNewAnalysisDriver) {
+ options ??= new AnalysisOptionsImpl();
+ DartSdk sdk =
+ options.strongMode ? physical_sdk.strongSdk : physical_sdk.sdk;
+
+ List<UriResolver> resolvers = <UriResolver>[
+ new DartUriResolver(sdk),
+ new ResourceUriResolver(resourceProvider)
+ ];
+ if (packages != null) {
+ var packageMap = <String, List<Folder>>{};
+ packages.forEach((args) {
+ String name = args[0];
+ String path =
+ resourceProvider.convertPath('/packages/$name/$name.dart');
+ String content = args[1];
+ File file = resourceProvider.newFile(path, content);
+ packageMap[name] = <Folder>[file.parent];
+ });
+ resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
+ }
+ SourceFactory sourceFactory = new SourceFactory(resolvers);
+
+ PerformanceLog log = new PerformanceLog(_logBuffer);
+ AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log);
+ driver = new AnalysisDriver(scheduler, log, resourceProvider,
+ new MemoryByteStore(), _fileContentOverlay, sourceFactory, options);
+ scheduler.start();
+ } else {
+ if (packages != null) {
+ var packageMap = <String, String>{};
+ packages.forEach((args) {
+ String name = args[0];
+ String content = args[1];
+ packageMap['package:$name/$name.dart'] = content;
+ });
+ analysisContext2 = AnalysisContextFactory.contextWithCoreAndPackages(
+ packageMap,
+ resourceProvider: resourceProvider);
+ } else if (options != null) {
+ analysisContext2 = AnalysisContextFactory.contextWithCoreAndOptions(
+ options,
+ resourceProvider: resourceProvider);
+ } else {
+ analysisContext2 = AnalysisContextFactory.contextWithCore(
+ resourceProvider: resourceProvider);
+ }
+ }
}
/**
@@ -659,50 +735,53 @@
Source source, LibraryElement library) =>
analysisContext2.resolveCompilationUnit(source, library);
- CompilationUnit resolveSource(String sourceText) =>
- resolveSource2("/test.dart", sourceText);
-
- CompilationUnit resolveSource2(String fileName, String sourceText) {
+ Future<CompilationUnit> resolveSource2(
+ String fileName, String sourceText) async {
Source source = addNamedSource(fileName, sourceText);
- LibraryElement library = analysisContext.computeLibraryElement(source);
- return analysisContext.resolveCompilationUnit(source, library);
+ TestAnalysisResult analysisResult = await computeAnalysisResult(source);
+ return analysisResult.unit;
}
- Source resolveSources(List<String> sourceTexts) {
+ Future<CompilationUnit> resolveSource(String sourceText) =>
+ resolveSource2('/test.dart', sourceText);
+
+ Future<Source> resolveSources(List<String> sourceTexts) async {
for (int i = 0; i < sourceTexts.length; i++) {
- CompilationUnit unit =
- resolveSource2("/lib${i + 1}.dart", sourceTexts[i]);
+ Source source = addNamedSource('/lib${i + 1}.dart', sourceTexts[i]);
+ await computeAnalysisResult(source);
// reference the source if this is the last source
if (i + 1 == sourceTexts.length) {
- return resolutionMap.elementDeclaredByCompilationUnit(unit).source;
+ return source;
}
}
return null;
}
- void resolveWithAndWithoutExperimental(
+ Future<Null> resolveWithAndWithoutExperimental(
List<String> strSources,
List<ErrorCode> codesWithoutExperimental,
- List<ErrorCode> codesWithExperimental) {
+ List<ErrorCode> codesWithExperimental) async {
// Setup analysis context as non-experimental
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
// options.enableDeferredLoading = false;
- resetWithOptions(options);
+ resetWith(options: options);
// Analysis and assertions
- Source source = resolveSources(strSources);
+ Source source = await resolveSources(strSources);
+ await computeAnalysisResult(source);
assertErrors(source, codesWithoutExperimental);
verify([source]);
// Setup analysis context as experimental
reset();
// Analysis and assertions
- source = resolveSources(strSources);
+ source = await resolveSources(strSources);
+ await computeAnalysisResult(source);
assertErrors(source, codesWithExperimental);
verify([source]);
}
- void resolveWithErrors(List<String> strSources, List<ErrorCode> codes) {
- // Analysis and assertions
- Source source = resolveSources(strSources);
+ Future<Null> resolveWithErrors(
+ List<String> strSources, List<ErrorCode> codes) async {
+ Source source = await resolveSources(strSources);
assertErrors(source, codes);
verify([source]);
}
@@ -727,12 +806,9 @@
void verify(List<Source> sources) {
ResolutionVerifier verifier = new ResolutionVerifier();
for (Source source in sources) {
- List<Source> libraries = analysisContext2.getLibrariesContaining(source);
- for (Source library in libraries) {
- analysisContext2
- .resolveCompilationUnit2(source, library)
- .accept(verifier);
- }
+ TestAnalysisResult result = analysisResults[source];
+ expect(result, isNotNull);
+ result.unit.accept(verifier);
}
verifier.assertResolved();
}
@@ -752,11 +828,14 @@
* stringifies to [type] and that its generics match the given stringified
* output.
*/
- expectFunctionType(String name, String type,
+ FunctionTypeImpl expectFunctionType(String name, String type,
{String elementTypeParams: '[]',
String typeParams: '[]',
String typeArgs: '[]',
- String typeFormals: '[]'}) {
+ String typeFormals: '[]',
+ String identifierType}) {
+ identifierType ??= type;
+
typeParameters(Element element) {
if (element is ExecutableElement) {
return element.typeParameters;
@@ -768,13 +847,15 @@
SimpleIdentifier identifier = findIdentifier(name);
// Element is either ExecutableElement or ParameterElement.
- Element element = identifier.staticElement;
- FunctionTypeImpl functionType = identifier.staticType;
+ var element = identifier.staticElement;
+ FunctionTypeImpl functionType = (element as dynamic).type;
expect(functionType.toString(), type);
+ expect(identifier.staticType.toString(), identifierType);
expect(typeParameters(element).toString(), elementTypeParams);
expect(functionType.typeParameters.toString(), typeParams);
expect(functionType.typeArguments.toString(), typeArgs);
expect(functionType.typeFormals.toString(), typeFormals);
+ return functionType;
}
/**
@@ -823,13 +904,13 @@
return identifier;
}
- void resolveTestUnit(String code) {
+ Future<Null> resolveTestUnit(String code) async {
testCode = code;
testSource = addSource(testCode);
- LibraryElement library = resolve2(testSource);
+ TestAnalysisResult analysisResult = await computeAnalysisResult(testSource);
assertNoErrors(testSource);
verify([testSource]);
- testUnit = resolveCompilationUnit(testSource, library);
+ testUnit = analysisResult.unit;
}
/**
@@ -846,3 +927,10 @@
}
}
}
+
+class TestAnalysisResult {
+ final Source source;
+ final CompilationUnit unit;
+ final List<AnalysisError> errors;
+ TestAnalysisResult(this.source, this.unit, this.errors);
+}
diff --git a/pkg/analyzer/test/generated/simple_resolver_test.dart b/pkg/analyzer/test/generated/simple_resolver_test.dart
index 620bc1f..f8ce31e 100644
--- a/pkg/analyzer/test/generated/simple_resolver_test.dart
+++ b/pkg/analyzer/test/generated/simple_resolver_test.dart
@@ -27,7 +27,7 @@
@reflectiveTest
class SimpleResolverTest extends ResolverTestCase {
- void test_argumentResolution_required_matching() {
+ test_argumentResolution_required_matching() async {
Source source = addSource(r'''
class A {
void f() {
@@ -38,7 +38,7 @@
_validateArgumentResolution(source, [0, 1, 2]);
}
- void test_argumentResolution_required_tooFew() {
+ test_argumentResolution_required_tooFew() async {
Source source = addSource(r'''
class A {
void f() {
@@ -49,7 +49,7 @@
_validateArgumentResolution(source, [0, 1]);
}
- void test_argumentResolution_required_tooMany() {
+ test_argumentResolution_required_tooMany() async {
Source source = addSource(r'''
class A {
void f() {
@@ -60,7 +60,7 @@
_validateArgumentResolution(source, [0, 1, -1]);
}
- void test_argumentResolution_requiredAndNamed_extra() {
+ test_argumentResolution_requiredAndNamed_extra() async {
Source source = addSource(r'''
class A {
void f() {
@@ -71,7 +71,7 @@
_validateArgumentResolution(source, [0, 1, 2, -1]);
}
- void test_argumentResolution_requiredAndNamed_matching() {
+ test_argumentResolution_requiredAndNamed_matching() async {
Source source = addSource(r'''
class A {
void f() {
@@ -82,7 +82,7 @@
_validateArgumentResolution(source, [0, 1, 2]);
}
- void test_argumentResolution_requiredAndNamed_missing() {
+ test_argumentResolution_requiredAndNamed_missing() async {
Source source = addSource(r'''
class A {
void f() {
@@ -93,7 +93,7 @@
_validateArgumentResolution(source, [0, 1, 3]);
}
- void test_argumentResolution_requiredAndPositional_fewer() {
+ test_argumentResolution_requiredAndPositional_fewer() async {
Source source = addSource(r'''
class A {
void f() {
@@ -104,7 +104,7 @@
_validateArgumentResolution(source, [0, 1, 2]);
}
- void test_argumentResolution_requiredAndPositional_matching() {
+ test_argumentResolution_requiredAndPositional_matching() async {
Source source = addSource(r'''
class A {
void f() {
@@ -115,7 +115,7 @@
_validateArgumentResolution(source, [0, 1, 2, 3]);
}
- void test_argumentResolution_requiredAndPositional_more() {
+ test_argumentResolution_requiredAndPositional_more() async {
Source source = addSource(r'''
class A {
void f() {
@@ -126,7 +126,7 @@
_validateArgumentResolution(source, [0, 1, 2, -1]);
}
- void test_argumentResolution_setter_propagated() {
+ test_argumentResolution_setter_propagated() async {
Source source = addSource(r'''
main() {
var a = new A();
@@ -159,7 +159,7 @@
expect(setter.parameters[0], same(parameter));
}
- void test_argumentResolution_setter_propagated_propertyAccess() {
+ test_argumentResolution_setter_propagated_propertyAccess() async {
Source source = addSource(r'''
main() {
var a = new A();
@@ -195,7 +195,7 @@
expect(setter.parameters[0], same(parameter));
}
- void test_argumentResolution_setter_static() {
+ test_argumentResolution_setter_static() async {
Source source = addSource(r'''
main() {
A a = new A();
@@ -227,7 +227,7 @@
expect(setter.parameters[0], same(parameter));
}
- void test_argumentResolution_setter_static_propertyAccess() {
+ test_argumentResolution_setter_static_propertyAccess() async {
Source source = addSource(r'''
main() {
A a = new A();
@@ -262,7 +262,7 @@
expect(setter.parameters[0], same(parameter));
}
- void test_breakTarget_labeled() {
+ test_breakTarget_labeled() async {
// Verify that the target of the label is correctly found and is recorded
// as the unlabeled portion of the statement.
String text = r'''
@@ -275,7 +275,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
WhileStatement whileStatement = EngineTestCase.findNode(
unit, text, 'while (true)', (n) => n is WhileStatement);
ForStatement forStatement =
@@ -288,7 +288,7 @@
expect(break2.target, same(forStatement));
}
- void test_breakTarget_unlabeledBreakFromDo() {
+ test_breakTarget_unlabeledBreakFromDo() async {
String text = r'''
void f() {
do {
@@ -296,7 +296,7 @@
} while (true);
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
DoStatement doStatement =
EngineTestCase.findNode(unit, text, 'do', (n) => n is DoStatement);
BreakStatement breakStatement = EngineTestCase.findNode(
@@ -304,7 +304,7 @@
expect(breakStatement.target, same(doStatement));
}
- void test_breakTarget_unlabeledBreakFromFor() {
+ test_breakTarget_unlabeledBreakFromFor() async {
String text = r'''
void f() {
for (int i = 0; i < 10; i++) {
@@ -312,7 +312,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
ForStatement forStatement =
EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement);
BreakStatement breakStatement = EngineTestCase.findNode(
@@ -320,7 +320,7 @@
expect(breakStatement.target, same(forStatement));
}
- void test_breakTarget_unlabeledBreakFromForEach() {
+ test_breakTarget_unlabeledBreakFromForEach() async {
String text = r'''
void f() {
for (x in []) {
@@ -328,7 +328,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
ForEachStatement forStatement = EngineTestCase.findNode(
unit, text, 'for', (n) => n is ForEachStatement);
BreakStatement breakStatement = EngineTestCase.findNode(
@@ -336,7 +336,7 @@
expect(breakStatement.target, same(forStatement));
}
- void test_breakTarget_unlabeledBreakFromSwitch() {
+ test_breakTarget_unlabeledBreakFromSwitch() async {
String text = r'''
void f() {
while (true) {
@@ -347,7 +347,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
SwitchStatement switchStatement = EngineTestCase.findNode(
unit, text, 'switch', (n) => n is SwitchStatement);
BreakStatement breakStatement = EngineTestCase.findNode(
@@ -355,7 +355,7 @@
expect(breakStatement.target, same(switchStatement));
}
- void test_breakTarget_unlabeledBreakFromWhile() {
+ test_breakTarget_unlabeledBreakFromWhile() async {
String text = r'''
void f() {
while (true) {
@@ -363,7 +363,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
WhileStatement whileStatement = EngineTestCase.findNode(
unit, text, 'while', (n) => n is WhileStatement);
BreakStatement breakStatement = EngineTestCase.findNode(
@@ -371,7 +371,7 @@
expect(breakStatement.target, same(whileStatement));
}
- void test_breakTarget_unlabeledBreakToOuterFunction() {
+ test_breakTarget_unlabeledBreakToOuterFunction() async {
// Verify that unlabeled break statements can't resolve to loops in an
// outer function.
String text = r'''
@@ -383,13 +383,13 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
BreakStatement breakStatement = EngineTestCase.findNode(
unit, text, 'break', (n) => n is BreakStatement);
expect(breakStatement.target, isNull);
}
- void test_class_definesCall() {
+ test_class_definesCall() async {
Source source = addSource(r'''
class A {
int call(int x) { return x; }
@@ -397,22 +397,22 @@
int f(A a) {
return a(0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_class_extends_implements() {
+ test_class_extends_implements() async {
Source source = addSource(r'''
class A extends B implements C {}
class B {}
class C {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_commentReference_class() {
+ test_commentReference_class() async {
Source source = addSource(r'''
f() {}
/** [A] [new A] [A.n] [new A.n] [m] [f] */
@@ -421,12 +421,12 @@
A.n() {}
m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_commentReference_parameter() {
+ test_commentReference_parameter() async {
Source source = addSource(r'''
class A {
A() {}
@@ -434,21 +434,21 @@
/** [e] [f] */
m(e, f()) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_commentReference_singleLine() {
+ test_commentReference_singleLine() async {
Source source = addSource(r'''
/// [A]
class A {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_continueTarget_labeled() {
+ test_continueTarget_labeled() async {
// Verify that the target of the label is correctly found and is recorded
// as the unlabeled portion of the statement.
String text = r'''
@@ -461,7 +461,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
WhileStatement whileStatement = EngineTestCase.findNode(
unit, text, 'while (true)', (n) => n is WhileStatement);
ForStatement forStatement =
@@ -474,7 +474,7 @@
expect(continue2.target, same(forStatement));
}
- void test_continueTarget_unlabeledContinueFromDo() {
+ test_continueTarget_unlabeledContinueFromDo() async {
String text = r'''
void f() {
do {
@@ -482,7 +482,7 @@
} while (true);
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
DoStatement doStatement =
EngineTestCase.findNode(unit, text, 'do', (n) => n is DoStatement);
ContinueStatement continueStatement = EngineTestCase.findNode(
@@ -490,7 +490,7 @@
expect(continueStatement.target, same(doStatement));
}
- void test_continueTarget_unlabeledContinueFromFor() {
+ test_continueTarget_unlabeledContinueFromFor() async {
String text = r'''
void f() {
for (int i = 0; i < 10; i++) {
@@ -498,7 +498,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
ForStatement forStatement =
EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement);
ContinueStatement continueStatement = EngineTestCase.findNode(
@@ -506,7 +506,7 @@
expect(continueStatement.target, same(forStatement));
}
- void test_continueTarget_unlabeledContinueFromForEach() {
+ test_continueTarget_unlabeledContinueFromForEach() async {
String text = r'''
void f() {
for (x in []) {
@@ -514,7 +514,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
ForEachStatement forStatement = EngineTestCase.findNode(
unit, text, 'for', (n) => n is ForEachStatement);
ContinueStatement continueStatement = EngineTestCase.findNode(
@@ -522,7 +522,7 @@
expect(continueStatement.target, same(forStatement));
}
- void test_continueTarget_unlabeledContinueFromWhile() {
+ test_continueTarget_unlabeledContinueFromWhile() async {
String text = r'''
void f() {
while (true) {
@@ -530,7 +530,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
WhileStatement whileStatement = EngineTestCase.findNode(
unit, text, 'while', (n) => n is WhileStatement);
ContinueStatement continueStatement = EngineTestCase.findNode(
@@ -538,7 +538,7 @@
expect(continueStatement.target, same(whileStatement));
}
- void test_continueTarget_unlabeledContinueSkipsSwitch() {
+ test_continueTarget_unlabeledContinueSkipsSwitch() async {
String text = r'''
void f() {
while (true) {
@@ -549,7 +549,7 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
WhileStatement whileStatement = EngineTestCase.findNode(
unit, text, 'while', (n) => n is WhileStatement);
ContinueStatement continueStatement = EngineTestCase.findNode(
@@ -557,7 +557,7 @@
expect(continueStatement.target, same(whileStatement));
}
- void test_continueTarget_unlabeledContinueToOuterFunction() {
+ test_continueTarget_unlabeledContinueToOuterFunction() async {
// Verify that unlabeled continue statements can't resolve to loops in an
// outer function.
String text = r'''
@@ -569,20 +569,20 @@
}
}
''';
- CompilationUnit unit = resolveSource(text);
+ CompilationUnit unit = await resolveSource(text);
ContinueStatement continueStatement = EngineTestCase.findNode(
unit, text, 'continue', (n) => n is ContinueStatement);
expect(continueStatement.target, isNull);
}
- void test_empty() {
+ test_empty() async {
Source source = addSource("");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_entryPoint_exported() {
+ test_entryPoint_exported() async {
addNamedSource(
"/two.dart",
r'''
@@ -598,11 +598,12 @@
FunctionElement main = library.entryPoint;
expect(main, isNotNull);
expect(main.library, isNot(same(library)));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_entryPoint_local() {
+ test_entryPoint_local() async {
Source source = addNamedSource(
"/one.dart",
r'''
@@ -613,20 +614,22 @@
FunctionElement main = library.entryPoint;
expect(main, isNotNull);
expect(main.library, same(library));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_entryPoint_none() {
+ test_entryPoint_none() async {
Source source = addNamedSource("/one.dart", "library one;");
LibraryElement library = resolve2(source);
expect(library, isNotNull);
expect(library.entryPoint, isNull);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_enum_externalLibrary() {
+ test_enum_externalLibrary() async {
addNamedSource(
"/my_lib.dart",
r'''
@@ -637,12 +640,12 @@
main() {
EEE e = null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_extractedMethodAsConstant() {
+ test_extractedMethodAsConstant() async {
Source source = addSource(r'''
abstract class Comparable<T> {
int compareTo(T other);
@@ -651,12 +654,12 @@
class A {
void sort([compare = Comparable.compare]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_fieldFormalParameter() {
+ test_fieldFormalParameter() async {
Source source = addSource(r'''
class A {
int x;
@@ -677,24 +680,24 @@
SimpleIdentifier identifierX = initializer.expression;
expect(identifierX.staticElement, paramElement);
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_forEachLoops_nonConflicting() {
+ test_forEachLoops_nonConflicting() async {
Source source = addSource(r'''
f() {
List list = [1,2,3];
for (int x in list) {}
for (int x in list) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_forLoops_nonConflicting() {
+ test_forLoops_nonConflicting() async {
Source source = addSource(r'''
f() {
for (int i = 0; i < 3; i++) {
@@ -702,12 +705,12 @@
for (int i = 0; i < 3; i++) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_functionTypeAlias() {
+ test_functionTypeAlias() async {
Source source = addSource(r'''
typedef bool P(e);
class A {
@@ -716,12 +719,12 @@
if (p(e)) {}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_getter_and_setter_fromMixins_bare_identifier() {
+ test_getter_and_setter_fromMixins_bare_identifier() async {
Source source = addSource('''
class B {}
class M1 {
@@ -739,6 +742,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that both the getter and setter for "x" in C.f() refer to the
@@ -760,7 +764,7 @@
}
@failingTest
- void test_getter_and_setter_fromMixins_property_access() {
+ test_getter_and_setter_fromMixins_property_access() async {
// TODO(paulberry): it appears that auxiliaryElements isn't properly set on
// a SimpleIdentifier that's inside a property access. This bug should be
// fixed.
@@ -780,6 +784,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that both the getter and setter for "x" in "new C().x" refer to
@@ -802,7 +807,7 @@
'M2');
}
- void test_getter_fromMixins_bare_identifier() {
+ test_getter_fromMixins_bare_identifier() async {
Source source = addSource('''
class B {}
class M1 {
@@ -818,6 +823,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that the getter for "x" in C.f() refers to the getter defined in
@@ -831,7 +837,7 @@
'M2');
}
- void test_getter_fromMixins_property_access() {
+ test_getter_fromMixins_property_access() async {
Source source = addSource('''
class B {}
class M1 {
@@ -846,6 +852,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that the getter for "x" in "new C().x" refers to the getter
@@ -863,7 +870,7 @@
'M2');
}
- void test_getterAndSetterWithDifferentTypes() {
+ test_getterAndSetterWithDifferentTypes() async {
Source source = addSource(r'''
class A {
int get f => 0;
@@ -872,13 +879,13 @@
g (A a) {
a.f = a.f.toString();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
verify([source]);
}
- void test_hasReferenceToSuper() {
+ test_hasReferenceToSuper() async {
Source source = addSource(r'''
class A {}
class B {toString() => super.toString();}''');
@@ -890,11 +897,12 @@
expect(classes, hasLength(2));
expect(classes[0].hasReferenceToSuper, isFalse);
expect(classes[1].hasReferenceToSuper, isTrue);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_import_hide() {
+ test_import_hide() async {
addNamedSource(
"/lib1.dart",
r'''
@@ -916,12 +924,12 @@
foo = 0;
}
A a;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_import_prefix() {
+ test_import_prefix() async {
addNamedSource(
"/two.dart",
r'''
@@ -937,12 +945,12 @@
main() {
_two.f(0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_import_prefix_doesNotExist() {
+ test_import_prefix_doesNotExist() async {
//
// The primary purpose of this test is to ensure that we are only getting a
// single error generated when the only problem is that an imported file
@@ -967,12 +975,12 @@
H(int i) : super(i);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
verify([source]);
}
- void test_import_show_doesNotExist() {
+ test_import_show_doesNotExist() async {
//
// The primary purpose of this test is to ensure that we are only getting a
// single error generated when the only problem is that an imported file
@@ -997,12 +1005,12 @@
H(int i) : super(i);
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
verify([source]);
}
- void test_import_spaceInUri() {
+ test_import_spaceInUri() async {
addNamedSource(
"/sub folder/lib.dart",
r'''
@@ -1016,12 +1024,12 @@
main() {
foo();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_indexExpression_typeParameters() {
+ test_indexExpression_typeParameters() async {
Source source = addSource(r'''
f() {
List<int> a;
@@ -1031,23 +1039,23 @@
List<List<List<int>>> c;
c[0][0][0];
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_indexExpression_typeParameters_invalidAssignmentWarning() {
+ test_indexExpression_typeParameters_invalidAssignmentWarning() async {
Source source = addSource(r'''
f() {
List<List<int>> b;
b[0][0] = 'hi';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
verify([source]);
}
- void test_indirectOperatorThroughCall() {
+ test_indirectOperatorThroughCall() async {
Source source = addSource(r'''
class A {
B call() { return new B(); }
@@ -1064,12 +1072,12 @@
main() {
g(f()[0]);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invoke_dynamicThroughGetter() {
+ test_invoke_dynamicThroughGetter() async {
Source source = addSource(r'''
class A {
List get X => [() => 0];
@@ -1077,12 +1085,12 @@
X.last;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_isValidMixin_badSuperclass() {
+ test_isValidMixin_badSuperclass() async {
Source source = addSource(r'''
class A extends B {}
class B {}
@@ -1093,12 +1101,13 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isFalse);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
verify([source]);
}
- void test_isValidMixin_badSuperclass_withSuperMixins() {
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
+ test_isValidMixin_badSuperclass_withSuperMixins() async {
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
Source source = addSource(r'''
class A extends B {}
class B {}
@@ -1109,11 +1118,12 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isTrue);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_isValidMixin_constructor() {
+ test_isValidMixin_constructor() async {
Source source = addSource(r'''
class A {
A() {}
@@ -1125,12 +1135,13 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isFalse);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
verify([source]);
}
- void test_isValidMixin_constructor_withSuperMixins() {
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
+ test_isValidMixin_constructor_withSuperMixins() async {
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
Source source = addSource(r'''
class A {
A() {}
@@ -1142,11 +1153,12 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isFalse);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
verify([source]);
}
- void test_isValidMixin_factoryConstructor() {
+ test_isValidMixin_factoryConstructor() async {
Source source = addSource(r'''
class A {
factory A() => null;
@@ -1158,12 +1170,13 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isTrue);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_isValidMixin_factoryConstructor_withSuperMixins() {
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
+ test_isValidMixin_factoryConstructor_withSuperMixins() async {
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
Source source = addSource(r'''
class A {
factory A() => null;
@@ -1175,11 +1188,12 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isTrue);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_isValidMixin_super() {
+ test_isValidMixin_super() async {
Source source = addSource(r'''
class A {
toString() {
@@ -1193,12 +1207,13 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isFalse);
+ await computeAnalysisResult(source);
assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]);
verify([source]);
}
- void test_isValidMixin_super_withSuperMixins() {
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
+ test_isValidMixin_super_withSuperMixins() async {
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
Source source = addSource(r'''
class A {
toString() {
@@ -1212,11 +1227,12 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isTrue);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_isValidMixin_valid() {
+ test_isValidMixin_valid() async {
Source source = addSource('''
class A {}
class C = Object with A;''');
@@ -1226,12 +1242,13 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isTrue);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_isValidMixin_valid_withSuperMixins() {
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
+ test_isValidMixin_valid_withSuperMixins() async {
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
Source source = addSource('''
class A {}
class C = Object with A;''');
@@ -1241,11 +1258,12 @@
expect(unit, isNotNull);
ClassElement a = unit.getType('A');
expect(a.isValidMixin, isTrue);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_labels_switch() {
+ test_labels_switch() async {
Source source = addSource(r'''
void doSwitch(int target) {
switch (target) {
@@ -1259,11 +1277,12 @@
}''');
LibraryElement library = resolve2(source);
expect(library, isNotNull);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_localVariable_types_invoked() {
+ test_localVariable_types_invoked() async {
Source source = addSource(r'''
const A = null;
main() {
@@ -1286,7 +1305,7 @@
expect(found[0], isTrue);
}
- void test_metadata_class() {
+ test_metadata_class() async {
Source source = addSource(r'''
const A = null;
@A class C<A> {}''');
@@ -1298,6 +1317,7 @@
expect(classes, hasLength(1));
List<ElementAnnotation> annotations = classes[0].metadata;
expect(annotations, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
CompilationUnit unit = resolveCompilationUnit(source, library);
@@ -1316,7 +1336,7 @@
expect(actualElement, same(expectedElement));
}
- void test_metadata_field() {
+ test_metadata_field() async {
Source source = addSource(r'''
const A = null;
class C {
@@ -1331,11 +1351,12 @@
FieldElement field = classes[0].fields[0];
List<ElementAnnotation> annotations = field.metadata;
expect(annotations, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_fieldFormalParameter() {
+ test_metadata_fieldFormalParameter() async {
Source source = addSource(r'''
const A = null;
class C {
@@ -1354,11 +1375,12 @@
expect(parameters, hasLength(1));
List<ElementAnnotation> annotations = parameters[0].metadata;
expect(annotations, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_function() {
+ test_metadata_function() async {
Source source = addSource(r'''
const A = null;
@A f() {}''');
@@ -1370,11 +1392,12 @@
expect(functions, hasLength(1));
List<ElementAnnotation> annotations = functions[0].metadata;
expect(annotations, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_functionTypedParameter() {
+ test_metadata_functionTypedParameter() async {
Source source = addSource(r'''
const A = null;
f(@A int p(int x)) {}''');
@@ -1388,11 +1411,12 @@
expect(parameters, hasLength(1));
List<ElementAnnotation> annotations1 = parameters[0].metadata;
expect(annotations1, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_libraryDirective() {
+ test_metadata_libraryDirective() async {
Source source = addSource(r'''
@A library lib;
const A = null;''');
@@ -1400,11 +1424,12 @@
expect(library, isNotNull);
List<ElementAnnotation> annotations = library.metadata;
expect(annotations, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_method() {
+ test_metadata_method() async {
Source source = addSource(r'''
const A = null;
class C {
@@ -1419,11 +1444,12 @@
MethodElement method = classes[0].methods[0];
List<ElementAnnotation> annotations = method.metadata;
expect(annotations, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_namedParameter() {
+ test_metadata_namedParameter() async {
Source source = addSource(r'''
const A = null;
f({@A int p : 0}) {}''');
@@ -1437,11 +1463,12 @@
expect(parameters, hasLength(1));
List<ElementAnnotation> annotations1 = parameters[0].metadata;
expect(annotations1, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_positionalParameter() {
+ test_metadata_positionalParameter() async {
Source source = addSource(r'''
const A = null;
f([@A int p = 0]) {}''');
@@ -1455,11 +1482,12 @@
expect(parameters, hasLength(1));
List<ElementAnnotation> annotations1 = parameters[0].metadata;
expect(annotations1, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_simpleParameter() {
+ test_metadata_simpleParameter() async {
Source source = addSource(r'''
const A = null;
f(@A p1, @A int p2) {}''');
@@ -1475,11 +1503,12 @@
expect(annotations1, hasLength(1));
List<ElementAnnotation> annotations2 = parameters[1].metadata;
expect(annotations2, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_metadata_typedef() {
+ test_metadata_typedef() async {
Source source = addSource(r'''
const A = null;
@A typedef F<A>();''');
@@ -1491,6 +1520,7 @@
expect(aliases, hasLength(1));
List<ElementAnnotation> annotations = aliases[0].metadata;
expect(annotations, hasLength(1));
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
CompilationUnit unit = resolveCompilationUnit(source, library);
@@ -1509,7 +1539,7 @@
expect(actualElement, same(expectedElement));
}
- void test_method_fromMixin() {
+ test_method_fromMixin() async {
Source source = addSource(r'''
class B {
bar() => 1;
@@ -1522,12 +1552,12 @@
bar() => super.bar();
foo() => super.foo();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_method_fromMixins() {
+ test_method_fromMixins() async {
Source source = addSource('''
class B {}
class M1 {
@@ -1542,6 +1572,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that the "f" in "new C().f()" refers to the "f" defined in M2.
@@ -1558,7 +1589,7 @@
'M2');
}
- void test_method_fromMixins_bare_identifier() {
+ test_method_fromMixins_bare_identifier() async {
Source source = addSource('''
class B {}
class M1 {
@@ -1574,6 +1605,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that the call to f() in C.g() refers to the method defined in M2.
@@ -1591,7 +1623,7 @@
'M2');
}
- void test_method_fromMixins_invked_from_outside_class() {
+ test_method_fromMixins_invked_from_outside_class() async {
Source source = addSource('''
class B {}
class M1 {
@@ -1606,6 +1638,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that the call to f() in "new C().f()" refers to the method
@@ -1623,7 +1656,7 @@
'M2');
}
- void test_method_fromSuperclassMixin() {
+ test_method_fromSuperclassMixin() async {
Source source = addSource(r'''
class A {
void m1() {}
@@ -1635,12 +1668,12 @@
f(C c) {
c.m1();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_methodCascades() {
+ test_methodCascades() async {
Source source = addSource(r'''
class A {
void m1() {}
@@ -1651,12 +1684,12 @@
..m2();
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_methodCascades_withSetter() {
+ test_methodCascades_withSetter() async {
Source source = addSource(r'''
class A {
String name;
@@ -1669,22 +1702,22 @@
..m2();
}
}''');
- computeLibrarySourceErrors(source);
// failing with error code: INVOCATION_OF_NON_FUNCTION
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_resolveAgainstNull() {
+ test_resolveAgainstNull() async {
Source source = addSource(r'''
f(var p) {
return null == p;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
}
- void test_setter_fromMixins_bare_identifier() {
+ test_setter_fromMixins_bare_identifier() async {
Source source = addSource('''
class B {}
class M1 {
@@ -1700,6 +1733,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that the setter for "x" in C.f() refers to the setter defined in
@@ -1718,7 +1752,7 @@
'M2');
}
- void test_setter_fromMixins_property_access() {
+ test_setter_fromMixins_property_access() async {
Source source = addSource('''
class B {}
class M1 {
@@ -1733,6 +1767,7 @@
}
''');
LibraryElement library = resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
// Verify that the setter for "x" in "new C().x" refers to the setter
@@ -1751,7 +1786,7 @@
'M2');
}
- void test_setter_inherited() {
+ test_setter_inherited() async {
Source source = addSource(r'''
class A {
int get x => 0;
@@ -1761,12 +1796,12 @@
int get x => super.x == null ? 0 : super.x;
int f() => x = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_setter_static() {
+ test_setter_static() async {
Source source = addSource(r'''
set s(x) {
}
@@ -1774,13 +1809,13 @@
main() {
s = 123;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
@failingTest
- void test_staticInvocation() {
+ test_staticInvocation() async {
Source source = addSource(r'''
class A {
static int get g => (a,b) => 0;
@@ -1790,7 +1825,7 @@
A.g(1,0);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
diff --git a/pkg/analyzer/test/generated/static_type_analyzer_test.dart b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
index 3a510f9a..14c408f 100644
--- a/pkg/analyzer/test/generated/static_type_analyzer_test.dart
+++ b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
@@ -33,6 +33,7 @@
defineReflectiveSuite(() {
defineReflectiveTests(StaticTypeAnalyzerTest);
defineReflectiveTests(StaticTypeAnalyzer2Test);
+ defineReflectiveTests(StaticTypeAnalyzer2Test_Driver);
});
}
@@ -41,17 +42,17 @@
*/
@reflectiveTest
class StaticTypeAnalyzer2Test extends StaticTypeAnalyzer2TestShared {
- void test_FunctionExpressionInvocation_block() {
+ test_FunctionExpressionInvocation_block() async {
String code = r'''
main() {
var foo = (() { return 1; })();
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'dynamic', isNull);
}
- void test_FunctionExpressionInvocation_curried() {
+ test_FunctionExpressionInvocation_curried() async {
String code = r'''
typedef int F();
F f() => null;
@@ -59,21 +60,21 @@
var foo = f()();
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'int', isNull);
}
- void test_FunctionExpressionInvocation_expression() {
+ test_FunctionExpressionInvocation_expression() async {
String code = r'''
main() {
var foo = (() => 1)();
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'int', isNull);
}
- void test_MethodInvocation_nameType_localVariable() {
+ test_MethodInvocation_nameType_localVariable() async {
String code = r"""
typedef Foo();
main() {
@@ -81,24 +82,24 @@
foo();
}
""";
- resolveTestUnit(code);
+ await resolveTestUnit(code);
// "foo" should be resolved to the "Foo" type
expectIdentifierType("foo();", new isInstanceOf<FunctionType>());
}
- void test_MethodInvocation_nameType_parameter_FunctionTypeAlias() {
+ test_MethodInvocation_nameType_parameter_FunctionTypeAlias() async {
String code = r"""
typedef Foo();
main(Foo foo) {
foo();
}
""";
- resolveTestUnit(code);
+ await resolveTestUnit(code);
// "foo" should be resolved to the "Foo" type
expectIdentifierType("foo();", new isInstanceOf<FunctionType>());
}
- void test_MethodInvocation_nameType_parameter_propagatedType() {
+ test_MethodInvocation_nameType_parameter_propagatedType() async {
String code = r"""
typedef Foo();
main(p) {
@@ -107,12 +108,12 @@
}
}
""";
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectIdentifierType("p()", DynamicTypeImpl.instance,
predicate((type) => type.name == 'Foo'));
}
- void test_staticMethods_classTypeParameters() {
+ test_staticMethods_classTypeParameters() async {
String code = r'''
class C<T> {
static void m() => null;
@@ -121,11 +122,11 @@
print(C.m);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectFunctionType('m);', '() → void');
}
- void test_staticMethods_classTypeParameters_genericMethod() {
+ test_staticMethods_classTypeParameters_genericMethod() async {
String code = r'''
class C<T> {
static void m<S>(S s) {
@@ -137,14 +138,15 @@
print(C.m);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
// C - m
TypeParameterType typeS;
{
- expectFunctionType('m);', '<S>(S) → void',
- elementTypeParams: '[S]', typeFormals: '[S]');
+ FunctionTypeImpl type = expectFunctionType('m);', '<S>(S) → void',
+ elementTypeParams: '[S]',
+ typeFormals: '[S]',
+ identifierType: '(dynamic) → void');
- FunctionTypeImpl type = findIdentifier('m);').staticType;
typeS = type.typeFormals[0].type;
type = type.instantiate([DynamicTypeImpl.instance]);
expect(type.toString(), '(dynamic) → void');
@@ -154,13 +156,13 @@
}
// C - m - f
{
- expectFunctionType('f);', '<U>(S, U) → void',
+ FunctionTypeImpl type = expectFunctionType('f);', '<U>(S, U) → void',
elementTypeParams: '[U]',
typeParams: '[S]',
typeArgs: '[S]',
- typeFormals: '[U]');
+ typeFormals: '[U]',
+ identifierType: '(S, dynamic) → void');
- FunctionTypeImpl type = findIdentifier('f);').staticType;
type = type.instantiate([DynamicTypeImpl.instance]);
expect(type.toString(), '(S, dynamic) → void');
expect(type.typeParameters.toString(), '[S, U]');
@@ -171,6 +173,12 @@
}
@reflectiveTest
+class StaticTypeAnalyzer2Test_Driver extends StaticTypeAnalyzer2Test {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
+
+@reflectiveTest
class StaticTypeAnalyzerTest extends EngineTestCase {
/**
* The error listener to which errors will be reported.
diff --git a/pkg/analyzer/test/generated/static_type_warning_code_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
index e4496f0..4bd6b61 100644
--- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
@@ -18,15 +18,17 @@
defineReflectiveSuite(() {
defineReflectiveTests(StaticTypeWarningCodeTest);
defineReflectiveTests(StrongModeStaticTypeWarningCodeTest);
+ defineReflectiveTests(StaticTypeWarningCodeTest_Driver);
+ defineReflectiveTests(StrongModeStaticTypeWarningCodeTest_Driver);
});
}
@reflectiveTest
class StaticTypeWarningCodeTest extends ResolverTestCase {
- void fail_method_lookup_mixin_of_extends() {
+ fail_method_lookup_mixin_of_extends() async {
// See dartbug.com/25605
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
- assertErrorsInUnverifiedCode(
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
+ await assertErrorsInUnverifiedCode(
'''
class A { a() => null; }
class B {}
@@ -43,10 +45,10 @@
]);
}
- void fail_method_lookup_mixin_of_implements() {
+ fail_method_lookup_mixin_of_implements() async {
// See dartbug.com/25605
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
- assertErrorsInUnverifiedCode(
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
+ await assertErrorsInUnverifiedCode(
'''
class A { a() => null; }
class B {}
@@ -62,10 +64,10 @@
]);
}
- void fail_method_lookup_mixin_of_mixin() {
+ fail_method_lookup_mixin_of_mixin() async {
// See dartbug.com/25605
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
- assertErrorsInUnverifiedCode(
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
+ await assertErrorsInUnverifiedCode(
'''
class A {}
class B { b() => null; }
@@ -79,10 +81,10 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void fail_method_lookup_mixin_of_mixin_application() {
+ fail_method_lookup_mixin_of_mixin_application() async {
// See dartbug.com/25605
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
- assertErrorsInUnverifiedCode(
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
+ await assertErrorsInUnverifiedCode(
'''
class A { a() => null; }
class B {}
@@ -96,8 +98,8 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void fail_typeArgumentNotMatchingBounds_ofFunctionTypeAlias() {
- assertErrorsInCode(
+ fail_typeArgumentNotMatchingBounds_ofFunctionTypeAlias() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -107,9 +109,9 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void fail_undefinedEnumConstant() {
+ fail_undefinedEnumConstant() async {
// We need a way to set the parseEnum flag in the parser to true.
- assertErrorsInCode(
+ await assertErrorsInCode(
r'''
enum E { ONE }
E e() {
@@ -118,7 +120,7 @@
[StaticTypeWarningCode.UNDEFINED_ENUM_CONSTANT]);
}
- void test_ambiguousImport_function() {
+ test_ambiguousImport_function() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -133,17 +135,17 @@
r'''
library lib2;
f() {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_assert_message_suppresses_type_promotion() {
+ test_assert_message_suppresses_type_promotion() async {
// If a variable is assigned to inside the expression for an assert
// message, type promotion should be suppressed, just as it would be if the
// assignment occurred outside an assert statement. (Note that it is a
// dubious practice for the computation of an assert message to have side
// effects, since it is only evaluated if the assert fails).
- assertErrorsInCode(
+ await assertErrorsInCode(
'''
class C {
void foo() {}
@@ -160,8 +162,8 @@
// Do not verify since `x.foo()` fails to resolve.
}
- void test_await_flattened() {
- assertErrorsInCode(
+ test_await_flattened() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
Future<Future<int>> ffi() => null;
@@ -172,8 +174,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_await_simple() {
- assertErrorsInCode(
+ test_await_simple() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
Future<int> fi() => null;
@@ -184,8 +186,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_awaitForIn_declaredVariableRightType() {
- assertNoErrorsInCode('''
+ test_awaitForIn_declaredVariableRightType() async {
+ await assertNoErrorsInCode('''
import 'dart:async';
f() async {
Stream<int> stream;
@@ -194,8 +196,8 @@
''');
}
- void test_awaitForIn_declaredVariableWrongType() {
- assertErrorsInCode(
+ test_awaitForIn_declaredVariableWrongType() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
f() async {
@@ -206,8 +208,8 @@
[StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
- void test_awaitForIn_downcast() {
- assertNoErrorsInCode('''
+ test_awaitForIn_downcast() async {
+ await assertNoErrorsInCode('''
import 'dart:async';
f() async {
Stream<num> stream;
@@ -216,8 +218,8 @@
''');
}
- void test_awaitForIn_dynamicStream() {
- assertNoErrorsInCode('''
+ test_awaitForIn_dynamicStream() async {
+ await assertNoErrorsInCode('''
f() async {
dynamic stream;
await for (int i in stream) {}
@@ -225,8 +227,8 @@
''');
}
- void test_awaitForIn_dynamicVariable() {
- assertNoErrorsInCode('''
+ test_awaitForIn_dynamicVariable() async {
+ await assertNoErrorsInCode('''
import 'dart:async';
f() async {
Stream<int> stream;
@@ -235,8 +237,8 @@
''');
}
- void test_awaitForIn_existingVariableRightType() {
- assertNoErrorsInCode('''
+ test_awaitForIn_existingVariableRightType() async {
+ await assertNoErrorsInCode('''
import 'dart:async';
f() async {
Stream<int> stream;
@@ -246,8 +248,8 @@
''');
}
- void test_awaitForIn_existingVariableWrongType() {
- assertErrorsInCode(
+ test_awaitForIn_existingVariableWrongType() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
f() async {
@@ -259,8 +261,8 @@
[StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
- void test_awaitForIn_notStream() {
- assertErrorsInCode(
+ test_awaitForIn_notStream() async {
+ await assertErrorsInCode(
'''
f() async {
await for (var i in true) {}
@@ -269,8 +271,8 @@
[StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
}
- void test_awaitForIn_streamOfDynamic() {
- assertNoErrorsInCode('''
+ test_awaitForIn_streamOfDynamic() async {
+ await assertNoErrorsInCode('''
import 'dart:async';
f() async {
Stream stream;
@@ -279,8 +281,8 @@
''');
}
- void test_awaitForIn_upcast() {
- assertNoErrorsInCode('''
+ test_awaitForIn_upcast() async {
+ await assertNoErrorsInCode('''
import 'dart:async';
f() async {
Stream<int> stream;
@@ -289,8 +291,8 @@
''');
}
- void test_bug21912() {
- assertErrorsInCode(
+ test_bug21912() async {
+ await assertErrorsInCode(
'''
class A {}
class B extends A {}
@@ -317,8 +319,8 @@
]);
}
- void test_expectedOneListTypeArgument() {
- assertErrorsInCode(
+ test_expectedOneListTypeArgument() async {
+ await assertErrorsInCode(
r'''
main() {
<int, int> [];
@@ -326,8 +328,8 @@
[StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS]);
}
- void test_expectedTwoMapTypeArguments_one() {
- assertErrorsInCode(
+ test_expectedTwoMapTypeArguments_one() async {
+ await assertErrorsInCode(
r'''
main() {
<int> {};
@@ -335,8 +337,8 @@
[StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
}
- void test_expectedTwoMapTypeArguments_three() {
- assertErrorsInCode(
+ test_expectedTwoMapTypeArguments_three() async {
+ await assertErrorsInCode(
r'''
main() {
<int, int, int> {};
@@ -344,16 +346,16 @@
[StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
}
- void test_forIn_declaredVariableRightType() {
- assertNoErrorsInCode('''
+ test_forIn_declaredVariableRightType() async {
+ await assertNoErrorsInCode('''
f() {
for (int i in <int>[]) {}
}
''');
}
- void test_forIn_declaredVariableWrongType() {
- assertErrorsInCode(
+ test_forIn_declaredVariableWrongType() async {
+ await assertErrorsInCode(
'''
f() {
for (int i in <String>[]) {}
@@ -362,16 +364,16 @@
[StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
- void test_forIn_downcast() {
- assertNoErrorsInCode('''
+ test_forIn_downcast() async {
+ await assertNoErrorsInCode('''
f() {
for (int i in <num>[]) {}
}
''');
}
- void test_forIn_dynamic() {
- assertNoErrorsInCode('''
+ test_forIn_dynamic() async {
+ await assertNoErrorsInCode('''
f() {
dynamic d; // Could be [].
for (var i in d) {}
@@ -379,8 +381,8 @@
''');
}
- void test_forIn_dynamicIterable() {
- assertNoErrorsInCode('''
+ test_forIn_dynamicIterable() async {
+ await assertNoErrorsInCode('''
f() {
dynamic iterable;
for (int i in iterable) {}
@@ -388,16 +390,16 @@
''');
}
- void test_forIn_dynamicVariable() {
- assertNoErrorsInCode('''
+ test_forIn_dynamicVariable() async {
+ await assertNoErrorsInCode('''
f() {
for (var i in <int>[]) {}
}
''');
}
- void test_forIn_existingVariableRightType() {
- assertNoErrorsInCode('''
+ test_forIn_existingVariableRightType() async {
+ await assertNoErrorsInCode('''
f() {
int i;
for (i in <int>[]) {}
@@ -405,8 +407,8 @@
''');
}
- void test_forIn_existingVariableWrongType() {
- assertErrorsInCode(
+ test_forIn_existingVariableWrongType() async {
+ await assertErrorsInCode(
'''
f() {
int i;
@@ -416,16 +418,16 @@
[StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
- void test_forIn_iterableOfDynamic() {
- assertNoErrorsInCode('''
+ test_forIn_iterableOfDynamic() async {
+ await assertNoErrorsInCode('''
f() {
for (int i in []) {}
}
''');
}
- void test_forIn_notIterable() {
- assertErrorsInCode(
+ test_forIn_notIterable() async {
+ await assertErrorsInCode(
'''
f() {
for (var i in true) {}
@@ -434,8 +436,8 @@
[StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
}
- void test_forIn_object() {
- assertNoErrorsInCode('''
+ test_forIn_object() async {
+ await assertNoErrorsInCode('''
f() {
Object o; // Could be [].
for (var i in o) {}
@@ -443,8 +445,8 @@
''');
}
- void test_forIn_typeBoundBad() {
- assertErrorsInCode(
+ test_forIn_typeBoundBad() async {
+ await assertErrorsInCode(
'''
class Foo<T extends Iterable<int>> {
void method(T iterable) {
@@ -455,8 +457,8 @@
[StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
- void test_forIn_typeBoundGood() {
- assertNoErrorsInCode('''
+ test_forIn_typeBoundGood() async {
+ await assertNoErrorsInCode('''
class Foo<T extends Iterable<int>> {
void method(T iterable) {
for (var i in iterable) {}
@@ -465,25 +467,25 @@
''');
}
- void test_forIn_upcast() {
- assertNoErrorsInCode('''
+ test_forIn_upcast() async {
+ await assertNoErrorsInCode('''
f() {
for (num i in <int>[]) {}
}
''');
}
- void test_illegalAsyncGeneratorReturnType_function_nonStream() {
- assertErrorsInCode(
+ test_illegalAsyncGeneratorReturnType_function_nonStream() async {
+ await assertErrorsInCode(
'''
int f() async* {}
''',
[StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
- void test_illegalAsyncGeneratorReturnType_function_subtypeOfStream() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_illegalAsyncGeneratorReturnType_function_subtypeOfStream() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
'''
import 'dart:async';
abstract class SubStream<T> implements Stream<T> {}
@@ -492,8 +494,8 @@
[StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
- void test_illegalAsyncGeneratorReturnType_method_nonStream() {
- assertErrorsInCode(
+ test_illegalAsyncGeneratorReturnType_method_nonStream() async {
+ await assertErrorsInCode(
'''
class C {
int f() async* {}
@@ -502,9 +504,9 @@
[StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
- void test_illegalAsyncGeneratorReturnType_method_subtypeOfStream() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_illegalAsyncGeneratorReturnType_method_subtypeOfStream() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
'''
import 'dart:async';
abstract class SubStream<T> implements Stream<T> {}
@@ -515,8 +517,8 @@
[StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
- void test_illegalAsyncReturnType_function_nonFuture() {
- assertErrorsInCode(
+ test_illegalAsyncReturnType_function_nonFuture() async {
+ await assertErrorsInCode(
'''
int f() async {}
''',
@@ -526,9 +528,9 @@
]);
}
- void test_illegalAsyncReturnType_function_subtypeOfFuture() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_illegalAsyncReturnType_function_subtypeOfFuture() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
'''
import 'dart:async';
abstract class SubFuture<T> implements Future<T> {}
@@ -539,8 +541,8 @@
[StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE]);
}
- void test_illegalAsyncReturnType_method_nonFuture() {
- assertErrorsInCode(
+ test_illegalAsyncReturnType_method_nonFuture() async {
+ await assertErrorsInCode(
'''
class C {
int m() async {}
@@ -552,9 +554,9 @@
]);
}
- void test_illegalAsyncReturnType_method_subtypeOfFuture() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_illegalAsyncReturnType_method_subtypeOfFuture() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
'''
import 'dart:async';
abstract class SubFuture<T> implements Future<T> {}
@@ -567,17 +569,17 @@
[StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE]);
}
- void test_illegalSyncGeneratorReturnType_function_nonIterator() {
- assertErrorsInCode(
+ test_illegalSyncGeneratorReturnType_function_nonIterator() async {
+ await assertErrorsInCode(
'''
int f() sync* {}
''',
[StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
- void test_illegalSyncGeneratorReturnType_function_subclassOfIterator() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_illegalSyncGeneratorReturnType_function_subclassOfIterator() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
'''
abstract class SubIterator<T> implements Iterator<T> {}
SubIterator<int> f() sync* {}
@@ -585,8 +587,8 @@
[StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
- void test_illegalSyncGeneratorReturnType_method_nonIterator() {
- assertErrorsInCode(
+ test_illegalSyncGeneratorReturnType_method_nonIterator() async {
+ await assertErrorsInCode(
'''
class C {
int f() sync* {}
@@ -595,9 +597,9 @@
[StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
- void test_illegalSyncGeneratorReturnType_method_subclassOfIterator() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_illegalSyncGeneratorReturnType_method_subclassOfIterator() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
'''
abstract class SubIterator<T> implements Iterator<T> {}
class C {
@@ -607,8 +609,8 @@
[StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
- void test_inconsistentMethodInheritance_paramCount() {
- assertErrorsInCode(
+ test_inconsistentMethodInheritance_paramCount() async {
+ await assertErrorsInCode(
r'''
abstract class A {
int x();
@@ -621,8 +623,8 @@
[StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
}
- void test_inconsistentMethodInheritance_paramType() {
- assertErrorsInCode(
+ test_inconsistentMethodInheritance_paramType() async {
+ await assertErrorsInCode(
r'''
abstract class A {
x(int i);
@@ -635,8 +637,8 @@
[StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
}
- void test_inconsistentMethodInheritance_returnType() {
- assertErrorsInCode(
+ test_inconsistentMethodInheritance_returnType() async {
+ await assertErrorsInCode(
r'''
abstract class A {
int x();
@@ -649,8 +651,8 @@
[StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
}
- void test_instanceAccessToStaticMember_method_invocation() {
- assertErrorsInCode(
+ test_instanceAccessToStaticMember_method_invocation() async {
+ await assertErrorsInCode(
r'''
class A {
static m() {}
@@ -661,8 +663,8 @@
[StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
- void test_instanceAccessToStaticMember_method_reference() {
- assertErrorsInCode(
+ test_instanceAccessToStaticMember_method_reference() async {
+ await assertErrorsInCode(
r'''
class A {
static m() {}
@@ -673,8 +675,8 @@
[StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
- void test_instanceAccessToStaticMember_propertyAccess_field() {
- assertErrorsInCode(
+ test_instanceAccessToStaticMember_propertyAccess_field() async {
+ await assertErrorsInCode(
r'''
class A {
static var f;
@@ -685,8 +687,8 @@
[StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
- void test_instanceAccessToStaticMember_propertyAccess_getter() {
- assertErrorsInCode(
+ test_instanceAccessToStaticMember_propertyAccess_getter() async {
+ await assertErrorsInCode(
r'''
class A {
static get f => 42;
@@ -697,8 +699,8 @@
[StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
- void test_instanceAccessToStaticMember_propertyAccess_setter() {
- assertErrorsInCode(
+ test_instanceAccessToStaticMember_propertyAccess_setter() async {
+ await assertErrorsInCode(
r'''
class A {
static set f(x) {}
@@ -709,8 +711,8 @@
[StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
- void test_invalidAssignment_compoundAssignment() {
- assertErrorsInCode(
+ test_invalidAssignment_compoundAssignment() async {
+ await assertErrorsInCode(
r'''
class byte {
int _value;
@@ -725,24 +727,24 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_defaultValue_named() {
- assertErrorsInCode(
+ test_invalidAssignment_defaultValue_named() async {
+ await assertErrorsInCode(
r'''
f({String x: 0}) {
}''',
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_defaultValue_optional() {
- assertErrorsInCode(
+ test_invalidAssignment_defaultValue_optional() async {
+ await assertErrorsInCode(
r'''
f([String x = 0]) {
}''',
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_dynamic() {
- assertErrorsInCode(
+ test_invalidAssignment_dynamic() async {
+ await assertErrorsInCode(
r'''
main() {
dynamic = 1;
@@ -751,8 +753,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_functionExpressionInvocation() {
- assertErrorsInCode(
+ test_invalidAssignment_functionExpressionInvocation() async {
+ await assertErrorsInCode(
'''
main() {
String x = (() => 5)();
@@ -760,8 +762,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_ifNullAssignment() {
- assertErrorsInCode(
+ test_invalidAssignment_ifNullAssignment() async {
+ await assertErrorsInCode(
'''
void f(int i) {
double d;
@@ -771,8 +773,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_instanceVariable() {
- assertErrorsInCode(
+ test_invalidAssignment_instanceVariable() async {
+ await assertErrorsInCode(
r'''
class A {
int x;
@@ -784,8 +786,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_localVariable() {
- assertErrorsInCode(
+ test_invalidAssignment_localVariable() async {
+ await assertErrorsInCode(
r'''
f() {
int x;
@@ -794,9 +796,9 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_regressionInIssue18468Fix() {
+ test_invalidAssignment_regressionInIssue18468Fix() async {
// https://code.google.com/p/dart/issues/detail?id=18628
- assertErrorsInCode(
+ await assertErrorsInCode(
r'''
class C<T> {
T t = int;
@@ -804,8 +806,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_staticVariable() {
- assertErrorsInCode(
+ test_invalidAssignment_staticVariable() async {
+ await assertErrorsInCode(
r'''
class A {
static int x;
@@ -816,14 +818,14 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_topLevelVariableDeclaration() {
- assertErrorsInCode(
+ test_invalidAssignment_topLevelVariableDeclaration() async {
+ await assertErrorsInCode(
"int x = 'string';", [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_typeParameter() {
+ test_invalidAssignment_typeParameter() async {
// 14221
- assertErrorsInCode(
+ await assertErrorsInCode(
r'''
class B<T> {
T value;
@@ -834,8 +836,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invalidAssignment_variableDeclaration() {
- assertErrorsInCode(
+ test_invalidAssignment_variableDeclaration() async {
+ await assertErrorsInCode(
r'''
class A {
int x = 'string';
@@ -843,8 +845,8 @@
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
- void test_invocationOfNonFunction_class() {
- assertErrorsInCode(
+ test_invocationOfNonFunction_class() async {
+ await assertErrorsInCode(
r'''
class A {
void m() {
@@ -854,15 +856,15 @@
[StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
- void test_invocationOfNonFunction_localGenericFunction() {
+ test_invocationOfNonFunction_localGenericFunction() async {
// Objects having a specific function type may be invoked, but objects
// having type Function may not, because type Function lacks a call method
// (this is because it is impossible to know what signature the call should
// have).
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
- resetWithOptions(options);
- assertErrorsInCode(
+ resetWith(options: options);
+ await assertErrorsInCode(
'''
f(Function f) {
return f();
@@ -870,11 +872,11 @@
[StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
- void test_invocationOfNonFunction_localObject() {
+ test_invocationOfNonFunction_localObject() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
- resetWithOptions(options);
- assertErrorsInCode(
+ resetWith(options: options);
+ await assertErrorsInCode(
'''
f(Object o) {
return o();
@@ -882,8 +884,8 @@
[StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
- void test_invocationOfNonFunction_localVariable() {
- assertErrorsInCode(
+ test_invocationOfNonFunction_localVariable() async {
+ await assertErrorsInCode(
r'''
f() {
int x;
@@ -892,8 +894,8 @@
[StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
- void test_invocationOfNonFunction_ordinaryInvocation() {
- assertErrorsInCode(
+ test_invocationOfNonFunction_ordinaryInvocation() async {
+ await assertErrorsInCode(
r'''
class A {
static int x;
@@ -907,8 +909,8 @@
// A call to verify(source) fails as A.x() cannot be resolved.
}
- void test_invocationOfNonFunction_staticInvocation() {
- assertErrorsInCode(
+ test_invocationOfNonFunction_staticInvocation() async {
+ await assertErrorsInCode(
r'''
class A {
static int get g => 0;
@@ -920,8 +922,8 @@
// A call to verify(source) fails as g() cannot be resolved.
}
- void test_invocationOfNonFunction_superExpression() {
- assertErrorsInCode(
+ test_invocationOfNonFunction_superExpression() async {
+ await assertErrorsInCode(
r'''
class A {
int get g => 0;
@@ -934,8 +936,8 @@
[StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
- void test_invocationOfNonFunctionExpression_literal() {
- assertErrorsInCode(
+ test_invocationOfNonFunctionExpression_literal() async {
+ await assertErrorsInCode(
r'''
f() {
3(5);
@@ -943,13 +945,13 @@
[StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION]);
}
- void test_nonBoolCondition_conditional() {
- assertErrorsInCode("f() { return 3 ? 2 : 1; }",
+ test_nonBoolCondition_conditional() async {
+ await assertErrorsInCode("f() { return 3 ? 2 : 1; }",
[StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
- void test_nonBoolCondition_do() {
- assertErrorsInCode(
+ test_nonBoolCondition_do() async {
+ await assertErrorsInCode(
r'''
f() {
do {} while (3);
@@ -957,9 +959,9 @@
[StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
- void test_nonBoolCondition_for() {
+ test_nonBoolCondition_for() async {
// https://github.com/dart-lang/sdk/issues/24713
- assertErrorsInCode(
+ await assertErrorsInCode(
r'''
f() {
for (;3;) {}
@@ -967,8 +969,8 @@
[StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
- void test_nonBoolCondition_if() {
- assertErrorsInCode(
+ test_nonBoolCondition_if() async {
+ await assertErrorsInCode(
r'''
f() {
if (3) return 2; else return 1;
@@ -976,8 +978,8 @@
[StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
- void test_nonBoolCondition_while() {
- assertErrorsInCode(
+ test_nonBoolCondition_while() async {
+ await assertErrorsInCode(
r'''
f() {
while (3) {}
@@ -985,8 +987,8 @@
[StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
- void test_nonBoolExpression_functionType() {
- assertErrorsInCode(
+ test_nonBoolExpression_functionType() async {
+ await assertErrorsInCode(
r'''
int makeAssertion() => 1;
f() {
@@ -995,8 +997,8 @@
[StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
}
- void test_nonBoolExpression_interfaceType() {
- assertErrorsInCode(
+ test_nonBoolExpression_interfaceType() async {
+ await assertErrorsInCode(
r'''
f() {
assert(0);
@@ -1004,8 +1006,8 @@
[StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
}
- void test_nonBoolNegationExpression() {
- assertErrorsInCode(
+ test_nonBoolNegationExpression() async {
+ await assertErrorsInCode(
r'''
f() {
!42;
@@ -1013,8 +1015,8 @@
[StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION]);
}
- void test_nonBoolOperand_and_left() {
- assertErrorsInCode(
+ test_nonBoolOperand_and_left() async {
+ await assertErrorsInCode(
r'''
bool f(int left, bool right) {
return left && right;
@@ -1022,8 +1024,8 @@
[StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
- void test_nonBoolOperand_and_right() {
- assertErrorsInCode(
+ test_nonBoolOperand_and_right() async {
+ await assertErrorsInCode(
r'''
bool f(bool left, String right) {
return left && right;
@@ -1031,8 +1033,8 @@
[StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
- void test_nonBoolOperand_or_left() {
- assertErrorsInCode(
+ test_nonBoolOperand_or_left() async {
+ await assertErrorsInCode(
r'''
bool f(List<int> left, bool right) {
return left || right;
@@ -1040,8 +1042,8 @@
[StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
- void test_nonBoolOperand_or_right() {
- assertErrorsInCode(
+ test_nonBoolOperand_or_right() async {
+ await assertErrorsInCode(
r'''
bool f(bool left, double right) {
return left || right;
@@ -1049,8 +1051,8 @@
[StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
- void test_nonTypeAsTypeArgument_notAType() {
- assertErrorsInCode(
+ test_nonTypeAsTypeArgument_notAType() async {
+ await assertErrorsInCode(
r'''
int A;
class B<E> {}
@@ -1058,16 +1060,16 @@
[StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
}
- void test_nonTypeAsTypeArgument_undefinedIdentifier() {
- assertErrorsInCode(
+ test_nonTypeAsTypeArgument_undefinedIdentifier() async {
+ await assertErrorsInCode(
r'''
class B<E> {}
f(B<A> b) {}''',
[StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
}
- void test_returnOfInvalidType_async_future_int_mismatches_future_null() {
- assertErrorsInCode(
+ test_returnOfInvalidType_async_future_int_mismatches_future_null() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
Future<Null> f() async {
@@ -1077,8 +1079,8 @@
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_async_future_int_mismatches_future_string() {
- assertErrorsInCode(
+ test_returnOfInvalidType_async_future_int_mismatches_future_string() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
Future<String> f() async {
@@ -1088,8 +1090,8 @@
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_async_future_int_mismatches_int() {
- assertErrorsInCode(
+ test_returnOfInvalidType_async_future_int_mismatches_int() async {
+ await assertErrorsInCode(
'''
int f() async {
return 5;
@@ -1101,18 +1103,18 @@
]);
}
- void test_returnOfInvalidType_expressionFunctionBody_function() {
- assertErrorsInCode(
+ test_returnOfInvalidType_expressionFunctionBody_function() async {
+ await assertErrorsInCode(
"int f() => '0';", [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_expressionFunctionBody_getter() {
- assertErrorsInCode(
+ test_returnOfInvalidType_expressionFunctionBody_getter() async {
+ await assertErrorsInCode(
"int get g => '0';", [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_expressionFunctionBody_localFunction() {
- assertErrorsInCode(
+ test_returnOfInvalidType_expressionFunctionBody_localFunction() async {
+ await assertErrorsInCode(
r'''
class A {
String m() {
@@ -1123,8 +1125,8 @@
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_expressionFunctionBody_method() {
- assertErrorsInCode(
+ test_returnOfInvalidType_expressionFunctionBody_method() async {
+ await assertErrorsInCode(
r'''
class A {
int f() => '0';
@@ -1132,23 +1134,23 @@
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_expressionFunctionBody_void() {
- assertErrorsInCode(
+ test_returnOfInvalidType_expressionFunctionBody_void() async {
+ await assertErrorsInCode(
"void f() => 42;", [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_function() {
- assertErrorsInCode("int f() { return '0'; }",
+ test_returnOfInvalidType_function() async {
+ await assertErrorsInCode("int f() { return '0'; }",
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_getter() {
- assertErrorsInCode("int get g { return '0'; }",
+ test_returnOfInvalidType_getter() async {
+ await assertErrorsInCode("int get g { return '0'; }",
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_localFunction() {
- assertErrorsInCode(
+ test_returnOfInvalidType_localFunction() async {
+ await assertErrorsInCode(
r'''
class A {
String m() {
@@ -1159,8 +1161,8 @@
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_method() {
- assertErrorsInCode(
+ test_returnOfInvalidType_method() async {
+ await assertErrorsInCode(
r'''
class A {
int f() { return '0'; }
@@ -1168,8 +1170,8 @@
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_returnOfInvalidType_not_issued_for_valid_generic_return() {
- assertNoErrorsInCode(r'''
+ test_returnOfInvalidType_not_issued_for_valid_generic_return() async {
+ await assertNoErrorsInCode(r'''
abstract class F<T, U> {
U get value;
}
@@ -1185,13 +1187,13 @@
void main() { }''');
}
- void test_returnOfInvalidType_void() {
- assertErrorsInCode("void f() { return 42; }",
+ test_returnOfInvalidType_void() async {
+ await assertErrorsInCode("void f() { return 42; }",
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- void test_typeArgumentNotMatchingBounds_classTypeAlias() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_classTypeAlias() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1202,8 +1204,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_extends() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_extends() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1213,9 +1215,9 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_extends_regressionInIssue18468Fix() {
+ test_typeArgumentNotMatchingBounds_extends_regressionInIssue18468Fix() async {
// https://code.google.com/p/dart/issues/detail?id=18628
- assertErrorsInCode(
+ await assertErrorsInCode(
r'''
class X<T extends Type> {}
class Y<U> extends X<U> {}
@@ -1223,8 +1225,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_fieldFormalParameter() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_fieldFormalParameter() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1236,8 +1238,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_functionReturnType() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_functionReturnType() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1247,8 +1249,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_functionTypeAlias() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_functionTypeAlias() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1258,8 +1260,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1269,8 +1271,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_implements() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_implements() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1280,8 +1282,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_is() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_is() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1291,9 +1293,9 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_methodInvocation_localFunction() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_methodInvocation_localFunction() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
r'''
class Point<T extends num> {
Point(T x, T y);
@@ -1309,9 +1311,9 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_methodInvocation_method() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_methodInvocation_method() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
r'''
class Point<T extends num> {
Point(T x, T y);
@@ -1330,9 +1332,9 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_methodInvocation_topLevelFunction() {
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_methodInvocation_topLevelFunction() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ await assertErrorsInCode(
r'''
class Point<T extends num> {
Point(T x, T y);
@@ -1349,8 +1351,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_methodReturnType() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_methodReturnType() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1361,8 +1363,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_new() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_new() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1372,8 +1374,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() async {
+ await assertErrorsInCode(
r'''
class A {}
class B extends A {}
@@ -1384,8 +1386,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_parameter() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_parameter() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1395,8 +1397,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_redirectingConstructor() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_redirectingConstructor() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1410,8 +1412,8 @@
]);
}
- void test_typeArgumentNotMatchingBounds_typeArgumentList() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_typeArgumentList() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1422,8 +1424,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_typeParameter() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_typeParameter() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1434,8 +1436,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_variableDeclaration() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_variableDeclaration() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1445,8 +1447,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeArgumentNotMatchingBounds_with() {
- assertErrorsInCode(
+ test_typeArgumentNotMatchingBounds_with() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {}
@@ -1456,8 +1458,8 @@
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
- void test_typeParameterSupertypeOfItsBound() {
- assertErrorsInCode(
+ test_typeParameterSupertypeOfItsBound() async {
+ await assertErrorsInCode(
r'''
class A<T extends T> {
}
@@ -1465,9 +1467,8 @@
[StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND]);
}
- void
- test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_mutated() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_mutated() async {
+ await assertErrorsInUnverifiedCode(
r'''
callMe(f()) { f(); }
main(Object p) {
@@ -1477,8 +1478,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_booleanAnd_useInRight_mutatedInLeft() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_booleanAnd_useInRight_mutatedInLeft() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
((p is String) && ((p = 42) == 42)) && p.length != 0;
@@ -1486,8 +1487,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_booleanAnd_useInRight_mutatedInRight() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_booleanAnd_useInRight_mutatedInRight() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
(p is String) && (((p = 42) == 42) && p.length != 0);
@@ -1495,9 +1496,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void
- test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_after() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_after() async {
+ await assertErrorsInUnverifiedCode(
r'''
callMe(f()) { f(); }
main(Object p) {
@@ -1507,9 +1507,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void
- test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_before() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_before() async {
+ await assertErrorsInUnverifiedCode(
r'''
callMe(f()) { f(); }
main(Object p) {
@@ -1519,8 +1518,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_conditional_useInThen_hasAssignment() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_conditional_useInThen_hasAssignment() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
p is String ? (p.length + (p = 42)) : 0;
@@ -1528,8 +1527,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_accessedInClosure_hasAssignment() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_accessedInClosure_hasAssignment() async {
+ await assertErrorsInUnverifiedCode(
r'''
callMe(f()) { f(); }
main(Object p) {
@@ -1543,8 +1542,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_and_right_hasAssignment() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_and_right_hasAssignment() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
if (p is String && (p = null) == null) {
@@ -1554,8 +1553,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_extends_notMoreSpecific_dynamic() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_extends_notMoreSpecific_dynamic() async {
+ await assertErrorsInUnverifiedCode(
r'''
class V {}
class A<T> {}
@@ -1571,8 +1570,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_extends_notMoreSpecific_notMoreSpecificTypeArg() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_extends_notMoreSpecific_notMoreSpecificTypeArg() async {
+ await assertErrorsInUnverifiedCode(
r'''
class V {}
class A<T> {}
@@ -1588,8 +1587,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_hasAssignment_after() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_hasAssignment_after() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
if (p is String) {
@@ -1600,8 +1599,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_hasAssignment_before() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_hasAssignment_before() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
if (p is String) {
@@ -1612,8 +1611,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_hasAssignment_inClosure_anonymous_after() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_hasAssignment_inClosure_anonymous_after() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
if (p is String) {
@@ -1624,8 +1623,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_hasAssignment_inClosure_anonymous_before() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_hasAssignment_inClosure_anonymous_before() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
() {p = 0;};
@@ -1636,8 +1635,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_hasAssignment_inClosure_function_after() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_hasAssignment_inClosure_function_after() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
if (p is String) {
@@ -1648,8 +1647,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_hasAssignment_inClosure_function_before() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_hasAssignment_inClosure_function_before() async {
+ await assertErrorsInUnverifiedCode(
r'''
main(Object p) {
f() {p = 0;};
@@ -1660,8 +1659,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_implements_notMoreSpecific_dynamic() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_implements_notMoreSpecific_dynamic() async {
+ await assertErrorsInUnverifiedCode(
r'''
class V {}
class A<T> {}
@@ -1677,8 +1676,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_typePromotion_if_with_notMoreSpecific_dynamic() {
- assertErrorsInUnverifiedCode(
+ test_typePromotion_if_with_notMoreSpecific_dynamic() async {
+ await assertErrorsInUnverifiedCode(
r'''
class V {}
class A<T> {}
@@ -1694,8 +1693,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedFunction() {
- assertErrorsInCode(
+ test_undefinedFunction() async {
+ await assertErrorsInCode(
r'''
void f() {
g();
@@ -1703,8 +1702,8 @@
[StaticTypeWarningCode.UNDEFINED_FUNCTION]);
}
- void test_undefinedFunction_inCatch() {
- assertErrorsInCode(
+ test_undefinedFunction_inCatch() async {
+ await assertErrorsInCode(
r'''
void f() {
try {
@@ -1715,7 +1714,7 @@
[StaticTypeWarningCode.UNDEFINED_FUNCTION]);
}
- void test_undefinedFunction_inImportedLib() {
+ test_undefinedFunction_inImportedLib() async {
Source source = addSource(r'''
import 'lib.dart' as f;
main() { return f.g(); }''');
@@ -1724,26 +1723,26 @@
r'''
library lib;
h() {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_FUNCTION]);
}
- void test_undefinedGetter() {
- assertErrorsInUnverifiedCode(
+ test_undefinedGetter() async {
+ await assertErrorsInUnverifiedCode(
r'''
class T {}
f(T e) { return e.m; }''',
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_generic_function_call() {
+ test_undefinedGetter_generic_function_call() async {
// Objects having a specific function type have a call() method, but
// objects having type Function do not (this is because it is impossible to
// know what signature the call should have).
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
- resetWithOptions(options);
- assertErrorsInUnverifiedCode(
+ resetWith(options: options);
+ await assertErrorsInUnverifiedCode(
'''
f(Function f) {
return f.call;
@@ -1752,11 +1751,11 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_object_call() {
+ test_undefinedGetter_object_call() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
- resetWithOptions(options);
- assertErrorsInUnverifiedCode(
+ resetWith(options: options);
+ await assertErrorsInUnverifiedCode(
'''
f(Object o) {
return o.call;
@@ -1765,8 +1764,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_proxy_annotation_fakeProxy() {
- assertErrorsInCode(
+ test_undefinedGetter_proxy_annotation_fakeProxy() async {
+ await assertErrorsInCode(
r'''
library L;
class Fake {
@@ -1780,16 +1779,16 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_static() {
- assertErrorsInUnverifiedCode(
+ test_undefinedGetter_static() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
var a = A.B;''',
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_typeLiteral_cascadeTarget() {
- assertErrorsInCode(
+ test_undefinedGetter_typeLiteral_cascadeTarget() async {
+ await assertErrorsInCode(
r'''
class T {
static int get foo => 42;
@@ -1800,10 +1799,10 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_typeLiteral_conditionalAccess() {
+ test_undefinedGetter_typeLiteral_conditionalAccess() async {
// When applied to a type literal, the conditional access operator '?.'
// cannot be used to access instance getters of Type.
- assertErrorsInCode(
+ await assertErrorsInCode(
'''
class A {}
f() => A?.hashCode;
@@ -1811,8 +1810,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_void() {
- assertErrorsInCode(
+ test_undefinedGetter_void() async {
+ await assertErrorsInCode(
r'''
class T {
void m() {}
@@ -1821,8 +1820,8 @@
[StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedGetter_wrongNumberOfTypeArguments_tooLittle() {
- assertErrorsInCode(
+ test_undefinedGetter_wrongNumberOfTypeArguments_tooLittle() async {
+ await assertErrorsInCode(
r'''
class A<K, V> {
K element;
@@ -1833,8 +1832,8 @@
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_undefinedGetter_wrongNumberOfTypeArguments_tooMany() {
- assertErrorsInCode(
+ test_undefinedGetter_wrongNumberOfTypeArguments_tooMany() async {
+ await assertErrorsInCode(
r'''
class A<E> {
E element;
@@ -1845,8 +1844,8 @@
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_undefinedGetter_wrongOfTypeArgument() {
- assertErrorsInCode(
+ test_undefinedGetter_wrongOfTypeArgument() async {
+ await assertErrorsInCode(
r'''
class A<E> {
E element;
@@ -1857,8 +1856,8 @@
[StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
}
- void test_undefinedMethod() {
- assertErrorsInCode(
+ test_undefinedMethod() async {
+ await assertErrorsInCode(
r'''
class A {
void m() {
@@ -1868,8 +1867,8 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_assignmentExpression() {
- assertErrorsInCode(
+ test_undefinedMethod_assignmentExpression() async {
+ await assertErrorsInCode(
r'''
class A {}
class B {
@@ -1881,14 +1880,14 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_generic_function_call() {
+ test_undefinedMethod_generic_function_call() async {
// Objects having a specific function type have a call() method, but
// objects having type Function do not (this is because it is impossible to
// know what signature the call should have).
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
- resetWithOptions(options);
- assertErrorsInCode(
+ resetWith(options: options);
+ await assertErrorsInCode(
'''
f(Function f) {
f.call();
@@ -1897,8 +1896,8 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_ignoreTypePropagation() {
- assertErrorsInCode(
+ test_undefinedMethod_ignoreTypePropagation() async {
+ await assertErrorsInCode(
r'''
class A {}
class B extends A {
@@ -1913,16 +1912,16 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_leastUpperBoundWithNull() {
- assertErrorsInCode('f(bool b, int i) => (b ? null : i).foo();',
+ test_undefinedMethod_leastUpperBoundWithNull() async {
+ await assertErrorsInCode('f(bool b, int i) => (b ? null : i).foo();',
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_object_call() {
+ test_undefinedMethod_object_call() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
- resetWithOptions(options);
- assertErrorsInCode(
+ resetWith(options: options);
+ await assertErrorsInCode(
'''
f(Object o) {
o.call();
@@ -1931,7 +1930,7 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_private() {
+ test_undefinedMethod_private() async {
addNamedSource(
"/lib.dart",
r'''
@@ -1939,7 +1938,7 @@
class A {
_foo() {}
}''');
- assertErrorsInCode(
+ await assertErrorsInCode(
r'''
import 'lib.dart';
class B extends A {
@@ -1950,8 +1949,8 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_proxy_annotation_fakeProxy() {
- assertErrorsInCode(
+ test_undefinedMethod_proxy_annotation_fakeProxy() async {
+ await assertErrorsInCode(
r'''
library L;
class Fake {
@@ -1965,8 +1964,8 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_typeLiteral_cascadeTarget() {
- assertErrorsInCode(
+ test_undefinedMethod_typeLiteral_cascadeTarget() async {
+ await assertErrorsInCode(
'''
class T {
static void foo() {}
@@ -1978,10 +1977,10 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethod_typeLiteral_conditionalAccess() {
+ test_undefinedMethod_typeLiteral_conditionalAccess() async {
// When applied to a type literal, the conditional access operator '?.'
// cannot be used to access instance methods of Type.
- assertErrorsInCode(
+ await assertErrorsInCode(
'''
class A {}
f() => A?.toString();
@@ -1989,8 +1988,8 @@
[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedMethodWithConstructor() {
- assertErrorsInCode(
+ test_undefinedMethodWithConstructor() async {
+ await assertErrorsInCode(
r'''
class C {
C.m();
@@ -2001,8 +2000,8 @@
[StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR]);
}
- void test_undefinedOperator_indexBoth() {
- assertErrorsInUnverifiedCode(
+ test_undefinedOperator_indexBoth() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
f(A a) {
@@ -2011,8 +2010,8 @@
[StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_indexGetter() {
- assertErrorsInUnverifiedCode(
+ test_undefinedOperator_indexGetter() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
f(A a) {
@@ -2021,8 +2020,8 @@
[StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_indexSetter() {
- assertErrorsInUnverifiedCode(
+ test_undefinedOperator_indexSetter() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
f(A a) {
@@ -2031,8 +2030,8 @@
[StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_plus() {
- assertErrorsInUnverifiedCode(
+ test_undefinedOperator_plus() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
f(A a) {
@@ -2041,8 +2040,8 @@
[StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_postfixExpression() {
- assertErrorsInCode(
+ test_undefinedOperator_postfixExpression() async {
+ await assertErrorsInCode(
r'''
class A {}
f(A a) {
@@ -2051,8 +2050,8 @@
[StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedOperator_prefixExpression() {
- assertErrorsInCode(
+ test_undefinedOperator_prefixExpression() async {
+ await assertErrorsInCode(
r'''
class A {}
f(A a) {
@@ -2061,24 +2060,24 @@
[StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
- void test_undefinedSetter() {
- assertErrorsInUnverifiedCode(
+ test_undefinedSetter() async {
+ await assertErrorsInUnverifiedCode(
r'''
class T {}
f(T e1) { e1.m = 0; }''',
[StaticTypeWarningCode.UNDEFINED_SETTER]);
}
- void test_undefinedSetter_static() {
- assertErrorsInUnverifiedCode(
+ test_undefinedSetter_static() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
f() { A.B = 0;}''',
[StaticTypeWarningCode.UNDEFINED_SETTER]);
}
- void test_undefinedSetter_typeLiteral_cascadeTarget() {
- assertErrorsInCode(
+ test_undefinedSetter_typeLiteral_cascadeTarget() async {
+ await assertErrorsInCode(
r'''
class T {
static void set foo(_) {}
@@ -2089,8 +2088,8 @@
[StaticTypeWarningCode.UNDEFINED_SETTER]);
}
- void test_undefinedSetter_void() {
- assertErrorsInCode(
+ test_undefinedSetter_void() async {
+ await assertErrorsInCode(
r'''
class T {
void m() {}
@@ -2099,8 +2098,8 @@
[StaticTypeWarningCode.UNDEFINED_SETTER]);
}
- void test_undefinedSuperGetter() {
- assertErrorsInCode(
+ test_undefinedSuperGetter() async {
+ await assertErrorsInCode(
r'''
class A {}
class B extends A {
@@ -2111,8 +2110,8 @@
[StaticTypeWarningCode.UNDEFINED_SUPER_GETTER]);
}
- void test_undefinedSuperMethod() {
- assertErrorsInCode(
+ test_undefinedSuperMethod() async {
+ await assertErrorsInCode(
r'''
class A {}
class B extends A {
@@ -2121,8 +2120,8 @@
[StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]);
}
- void test_undefinedSuperOperator_binaryExpression() {
- assertErrorsInUnverifiedCode(
+ test_undefinedSuperOperator_binaryExpression() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
class B extends A {
@@ -2133,8 +2132,8 @@
[StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
- void test_undefinedSuperOperator_indexBoth() {
- assertErrorsInUnverifiedCode(
+ test_undefinedSuperOperator_indexBoth() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
class B extends A {
@@ -2145,8 +2144,8 @@
[StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
- void test_undefinedSuperOperator_indexGetter() {
- assertErrorsInUnverifiedCode(
+ test_undefinedSuperOperator_indexGetter() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
class B extends A {
@@ -2157,8 +2156,8 @@
[StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
- void test_undefinedSuperOperator_indexSetter() {
- assertErrorsInUnverifiedCode(
+ test_undefinedSuperOperator_indexSetter() async {
+ await assertErrorsInUnverifiedCode(
r'''
class A {}
class B extends A {
@@ -2169,8 +2168,8 @@
[StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
- void test_undefinedSuperSetter() {
- assertErrorsInCode(
+ test_undefinedSuperSetter() async {
+ await assertErrorsInCode(
r'''
class A {}
class B extends A {
@@ -2181,8 +2180,8 @@
[StaticTypeWarningCode.UNDEFINED_SUPER_SETTER]);
}
- void test_unqualifiedReferenceToNonLocalStaticMember_getter() {
- assertErrorsInCode(
+ test_unqualifiedReferenceToNonLocalStaticMember_getter() async {
+ await assertErrorsInCode(
r'''
class A {
static int get a => 0;
@@ -2197,8 +2196,8 @@
]);
}
- void test_unqualifiedReferenceToNonLocalStaticMember_getter_invokeTarget() {
- assertErrorsInCode(
+ test_unqualifiedReferenceToNonLocalStaticMember_getter_invokeTarget() async {
+ await assertErrorsInCode(
r'''
class A {
static int foo;
@@ -2215,8 +2214,8 @@
]);
}
- void test_unqualifiedReferenceToNonLocalStaticMember_method() {
- assertErrorsInCode(
+ test_unqualifiedReferenceToNonLocalStaticMember_method() async {
+ await assertErrorsInCode(
r'''
class A {
static void a() {}
@@ -2231,8 +2230,8 @@
]);
}
- void test_unqualifiedReferenceToNonLocalStaticMember_setter() {
- assertErrorsInCode(
+ test_unqualifiedReferenceToNonLocalStaticMember_setter() async {
+ await assertErrorsInCode(
r'''
class A {
static set a(x) {}
@@ -2247,8 +2246,8 @@
]);
}
- void test_wrongNumberOfTypeArguments_classAlias() {
- assertErrorsInCode(
+ test_wrongNumberOfTypeArguments_classAlias() async {
+ await assertErrorsInCode(
r'''
class A {}
class M {}
@@ -2256,24 +2255,24 @@
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_wrongNumberOfTypeArguments_tooFew() {
- assertErrorsInCode(
+ test_wrongNumberOfTypeArguments_tooFew() async {
+ await assertErrorsInCode(
r'''
class A<E, F> {}
A<A> a = null;''',
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_wrongNumberOfTypeArguments_tooMany() {
- assertErrorsInCode(
+ test_wrongNumberOfTypeArguments_tooMany() async {
+ await assertErrorsInCode(
r'''
class A<E> {}
A<A, A> a = null;''',
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_wrongNumberOfTypeArguments_typeTest_tooFew() {
- assertErrorsInCode(
+ test_wrongNumberOfTypeArguments_typeTest_tooFew() async {
+ await assertErrorsInCode(
r'''
class A {}
class C<K, V> {}
@@ -2283,8 +2282,8 @@
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_wrongNumberOfTypeArguments_typeTest_tooMany() {
- assertErrorsInCode(
+ test_wrongNumberOfTypeArguments_typeTest_tooMany() async {
+ await assertErrorsInCode(
r'''
class A {}
class C<E> {}
@@ -2294,8 +2293,8 @@
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_yield_async_to_basic_type() {
- assertErrorsInCode(
+ test_yield_async_to_basic_type() async {
+ await assertErrorsInCode(
'''
int f() async* {
yield 3;
@@ -2307,8 +2306,8 @@
]);
}
- void test_yield_async_to_iterable() {
- assertErrorsInCode(
+ test_yield_async_to_iterable() async {
+ await assertErrorsInCode(
'''
Iterable<int> f() async* {
yield 3;
@@ -2320,8 +2319,8 @@
]);
}
- void test_yield_async_to_mistyped_stream() {
- assertErrorsInCode(
+ test_yield_async_to_mistyped_stream() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
Stream<int> f() async* {
@@ -2331,8 +2330,8 @@
[StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
- void test_yield_each_async_non_stream() {
- assertErrorsInCode(
+ test_yield_each_async_non_stream() async {
+ await assertErrorsInCode(
'''
f() async* {
yield* 0;
@@ -2341,8 +2340,8 @@
[StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
- void test_yield_each_async_to_mistyped_stream() {
- assertErrorsInCode(
+ test_yield_each_async_to_mistyped_stream() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
Stream<int> f() async* {
@@ -2353,8 +2352,8 @@
[StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
- void test_yield_each_sync_non_iterable() {
- assertErrorsInCode(
+ test_yield_each_sync_non_iterable() async {
+ await assertErrorsInCode(
'''
f() sync* {
yield* 0;
@@ -2363,8 +2362,8 @@
[StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
- void test_yield_each_sync_to_mistyped_iterable() {
- assertErrorsInCode(
+ test_yield_each_sync_to_mistyped_iterable() async {
+ await assertErrorsInCode(
'''
Iterable<int> f() sync* {
yield* g();
@@ -2374,8 +2373,8 @@
[StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
- void test_yield_sync_to_basic_type() {
- assertErrorsInCode(
+ test_yield_sync_to_basic_type() async {
+ await assertErrorsInCode(
'''
int f() sync* {
yield 3;
@@ -2387,8 +2386,8 @@
]);
}
- void test_yield_sync_to_mistyped_iterable() {
- assertErrorsInCode(
+ test_yield_sync_to_mistyped_iterable() async {
+ await assertErrorsInCode(
'''
Iterable<int> f() sync* {
yield "foo";
@@ -2397,8 +2396,8 @@
[StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
- void test_yield_sync_to_stream() {
- assertErrorsInCode(
+ test_yield_sync_to_stream() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
Stream<int> f() sync* {
@@ -2413,22 +2412,28 @@
}
@reflectiveTest
+class StaticTypeWarningCodeTest_Driver extends StaticTypeWarningCodeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
+
+@reflectiveTest
class StrongModeStaticTypeWarningCodeTest extends ResolverTestCase {
void setUp() {
super.setUp();
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.strongMode = true;
- resetWithOptions(options);
+ resetWith(options: options);
}
- void test_genericMethodWrongNumberOfTypeArguments() {
+ test_genericMethodWrongNumberOfTypeArguments() async {
Source source = addSource('''
f() {}
main() {
f/*<int>*/();
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD]);
for (AnalysisError error in analysisContext2.computeErrors(source)) {
@@ -2441,8 +2446,8 @@
verify([source]);
}
- void test_legalAsyncGeneratorReturnType_function_supertypeOfStream() {
- assertErrorsInCode(
+ test_legalAsyncGeneratorReturnType_function_supertypeOfStream() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
f() async* { yield 42; }
@@ -2457,8 +2462,8 @@
[]);
}
- void test_legalAsyncReturnType_function_supertypeOfFuture() {
- assertErrorsInCode(
+ test_legalAsyncReturnType_function_supertypeOfFuture() async {
+ await assertErrorsInCode(
'''
import 'dart:async';
f() async { return 42; }
@@ -2473,8 +2478,8 @@
[]);
}
- void test_legalSyncGeneratorReturnType_function_supertypeOfIterable() {
- assertErrorsInCode(
+ test_legalSyncGeneratorReturnType_function_supertypeOfIterable() async {
+ await assertErrorsInCode(
'''
f() sync* { yield 42; }
dynamic f2() sync* { yield 42; }
@@ -2488,3 +2493,16 @@
[]);
}
}
+
+@reflectiveTest
+class StrongModeStaticTypeWarningCodeTest_Driver
+ extends StrongModeStaticTypeWarningCodeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ @failingTest
+ @override
+ test_genericMethodWrongNumberOfTypeArguments() {
+ return super.test_genericMethodWrongNumberOfTypeArguments();
+ }
+}
diff --git a/pkg/analyzer/test/generated/static_warning_code_driver_test.dart b/pkg/analyzer/test/generated/static_warning_code_driver_test.dart
new file mode 100644
index 0000000..90869fb
--- /dev/null
+++ b/pkg/analyzer/test/generated/static_warning_code_driver_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2017, 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:test_reflective_loader/test_reflective_loader.dart';
+
+import 'static_warning_code_test.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(StaticWarningCodeTest_Driver);
+ });
+}
+
+@reflectiveTest
+class StaticWarningCodeTest_Driver extends StaticWarningCodeTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ @failingTest
+ @override
+ test_argumentTypeNotAssignable_ambiguousClassName() {
+ return super.test_argumentTypeNotAssignable_ambiguousClassName();
+ }
+
+ @failingTest
+ @override
+ test_importOfNonLibrary() {
+ return super.test_importOfNonLibrary();
+ }
+}
diff --git a/pkg/analyzer/test/generated/static_warning_code_test.dart b/pkg/analyzer/test/generated/static_warning_code_test.dart
index 1fc56f4..794ebf5 100644
--- a/pkg/analyzer/test/generated/static_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_warning_code_test.dart
@@ -21,7 +21,7 @@
@reflectiveTest
class StaticWarningCodeTest extends ResolverTestCase {
- void fail_argumentTypeNotAssignable_tearOff_required() {
+ fail_argumentTypeNotAssignable_tearOff_required() async {
Source source = addSource(r'''
class C {
Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x;
@@ -31,43 +31,43 @@
print(h('s'));
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void fail_undefinedGetter() {
+ fail_undefinedGetter() async {
Source source = addSource(r'''
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]);
verify([source]);
}
- void fail_undefinedIdentifier_commentReference() {
+ fail_undefinedIdentifier_commentReference() async {
Source source = addSource(r'''
/** [m] xxx [new B.c] */
class A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.UNDEFINED_IDENTIFIER,
StaticWarningCode.UNDEFINED_IDENTIFIER
]);
}
- void fail_undefinedSetter() {
+ fail_undefinedSetter() async {
Source source = addSource(r'''
class C {}
f(var p) {
C.m = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]);
verify([source]);
}
- void test_ambiguousImport_as() {
+ test_ambiguousImport_as() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -82,11 +82,11 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_extends() {
+ test_ambiguousImport_extends() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -101,14 +101,14 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.AMBIGUOUS_IMPORT,
CompileTimeErrorCode.EXTENDS_NON_CLASS
]);
}
- void test_ambiguousImport_implements() {
+ test_ambiguousImport_implements() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -123,14 +123,14 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.AMBIGUOUS_IMPORT,
CompileTimeErrorCode.IMPLEMENTS_NON_CLASS
]);
}
- void test_ambiguousImport_inPart() {
+ test_ambiguousImport_inPart() async {
Source source = addSource(r'''
library lib;
import 'lib1.dart';
@@ -151,14 +151,16 @@
r'''
part of lib;
class A extends N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
+ await computeAnalysisResult(partSource);
+ assertNoErrors(source);
assertErrors(partSource, [
StaticWarningCode.AMBIGUOUS_IMPORT,
CompileTimeErrorCode.EXTENDS_NON_CLASS
]);
}
- void test_ambiguousImport_instanceCreation() {
+ test_ambiguousImport_instanceCreation() async {
Source source = addSource(r'''
library L;
import 'lib1.dart';
@@ -174,11 +176,11 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_is() {
+ test_ambiguousImport_is() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -193,11 +195,11 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_qualifier() {
+ test_ambiguousImport_qualifier() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -212,11 +214,11 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_typeAnnotation() {
+ test_ambiguousImport_typeAnnotation() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -239,7 +241,7 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.AMBIGUOUS_IMPORT,
StaticWarningCode.AMBIGUOUS_IMPORT,
@@ -251,7 +253,7 @@
]);
}
- void test_ambiguousImport_typeArgument_annotation() {
+ test_ambiguousImport_typeArgument_annotation() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -267,11 +269,11 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_typeArgument_instanceCreation() {
+ test_ambiguousImport_typeArgument_instanceCreation() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -287,11 +289,11 @@
r'''
library lib2;
class N {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_varRead() {
+ test_ambiguousImport_varRead() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -307,11 +309,11 @@
r'''
library lib2;
var v;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_varWrite() {
+ test_ambiguousImport_varWrite() async {
Source source = addSource(r'''
import 'lib1.dart';
import 'lib2.dart';
@@ -326,11 +328,11 @@
r'''
library lib2;
var v;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_ambiguousImport_withPrefix() {
+ test_ambiguousImport_withPrefix() async {
Source source = addSource(r'''
library test;
import 'lib1.dart' as p;
@@ -348,11 +350,11 @@
r'''
library lib2;
f() {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
}
- void test_argumentTypeNotAssignable_ambiguousClassName() {
+ test_argumentTypeNotAssignable_ambiguousClassName() async {
// See dartbug.com/19624
Source source = addNamedSource(
"/lib1.dart",
@@ -369,7 +371,6 @@
library lib2;
class _A {}
g(h(_A a)) {}''');
- computeLibrarySourceErrors(source);
// The name _A is private to the library it's defined in, so this is a type
// mismatch. Furthermore, the error message should mention both _A and the
// filenames so the user can figure out what's going on.
@@ -383,7 +384,7 @@
expect(message.indexOf("lib2.dart") != -1, isTrue);
}
- void test_argumentTypeNotAssignable_annotation_namedConstructor() {
+ test_argumentTypeNotAssignable_annotation_namedConstructor() async {
Source source = addSource(r'''
class A {
const A.fromInt(int p);
@@ -391,12 +392,12 @@
@A.fromInt('0')
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_annotation_unnamedConstructor() {
+ test_argumentTypeNotAssignable_annotation_unnamedConstructor() async {
Source source = addSource(r'''
class A {
const A(int p);
@@ -404,12 +405,12 @@
@A('0')
main() {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_binary() {
+ test_argumentTypeNotAssignable_binary() async {
Source source = addSource(r'''
class A {
operator +(int p) {}
@@ -417,12 +418,12 @@
f(A a) {
a + '0';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_cascadeSecond() {
+ test_argumentTypeNotAssignable_cascadeSecond() async {
Source source = addSource(r'''
// filler filler filler filler filler filler filler filler filler filler
class A {
@@ -436,12 +437,12 @@
A a = new A();
a.. ma().mb(0);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_const() {
+ test_argumentTypeNotAssignable_const() async {
Source source = addSource(r'''
class A {
const A(String p);
@@ -449,7 +450,7 @@
main() {
const A(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
@@ -457,7 +458,7 @@
verify([source]);
}
- void test_argumentTypeNotAssignable_const_super() {
+ test_argumentTypeNotAssignable_const_super() async {
Source source = addSource(r'''
class A {
const A(String p);
@@ -465,22 +466,22 @@
class B extends A {
const B() : super(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_functionExpressionInvocation_required() {
+ test_argumentTypeNotAssignable_functionExpressionInvocation_required() async {
Source source = addSource(r'''
main() {
(int x) {} ('');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_index() {
+ test_argumentTypeNotAssignable_index() async {
Source source = addSource(r'''
class A {
operator [](int index) {}
@@ -488,12 +489,12 @@
f(A a) {
a['0'];
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_callParameter() {
+ test_argumentTypeNotAssignable_invocation_callParameter() async {
Source source = addSource(r'''
class A {
call(int p) {}
@@ -501,12 +502,12 @@
f(A a) {
a('0');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_callVariable() {
+ test_argumentTypeNotAssignable_invocation_callVariable() async {
Source source = addSource(r'''
class A {
call(int p) {}
@@ -515,46 +516,46 @@
A a = new A();
a('0');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_functionParameter() {
+ test_argumentTypeNotAssignable_invocation_functionParameter() async {
Source source = addSource(r'''
a(b(int p)) {
b('0');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_functionParameter_generic() {
+ test_argumentTypeNotAssignable_invocation_functionParameter_generic() async {
Source source = addSource(r'''
class A<K, V> {
m(f(K k), V v) {
f(v);
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_functionTypes_optional() {
+ test_argumentTypeNotAssignable_invocation_functionTypes_optional() async {
Source source = addSource(r'''
void acceptFunNumOptBool(void funNumOptBool([bool b])) {}
void funNumBool(bool b) {}
main() {
acceptFunNumOptBool(funNumBool);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_generic() {
+ test_argumentTypeNotAssignable_invocation_generic() async {
Source source = addSource(r'''
class A<T> {
m(T t) {}
@@ -562,56 +563,56 @@
f(A<String> a) {
a.m(1);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_named() {
+ test_argumentTypeNotAssignable_invocation_named() async {
Source source = addSource(r'''
f({String p}) {}
main() {
f(p: 42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_optional() {
+ test_argumentTypeNotAssignable_invocation_optional() async {
Source source = addSource(r'''
f([String p]) {}
main() {
f(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_required() {
+ test_argumentTypeNotAssignable_invocation_required() async {
Source source = addSource(r'''
f(String p) {}
main() {
f(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_typedef_generic() {
+ test_argumentTypeNotAssignable_invocation_typedef_generic() async {
Source source = addSource(r'''
typedef A<T>(T p);
f(A<int> a) {
a('1');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_typedef_local() {
+ test_argumentTypeNotAssignable_invocation_typedef_local() async {
Source source = addSource(r'''
typedef A(int p);
A getA() => null;
@@ -619,23 +620,23 @@
A a = getA();
a('1');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_invocation_typedef_parameter() {
+ test_argumentTypeNotAssignable_invocation_typedef_parameter() async {
Source source = addSource(r'''
typedef A(int p);
f(A a) {
a('1');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_new_generic() {
+ test_argumentTypeNotAssignable_new_generic() async {
Source source = addSource(r'''
class A<T> {
A(T p) {}
@@ -643,12 +644,12 @@
main() {
new A<String>(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_new_optional() {
+ test_argumentTypeNotAssignable_new_optional() async {
Source source = addSource(r'''
class A {
A([String p]) {}
@@ -656,12 +657,12 @@
main() {
new A(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_argumentTypeNotAssignable_new_required() {
+ test_argumentTypeNotAssignable_new_required() async {
Source source = addSource(r'''
class A {
A(String p) {}
@@ -669,23 +670,23 @@
main() {
new A(42);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_assignmentToClass() {
+ test_assignmentToClass() async {
Source source = addSource('''
class C {}
main() {
C = null;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
}
- void test_assignmentToConst_instanceVariable() {
+ test_assignmentToConst_instanceVariable() async {
Source source = addSource(r'''
class A {
static const v = 0;
@@ -693,12 +694,12 @@
f() {
A.v = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
verify([source]);
}
- void test_assignmentToConst_instanceVariable_plusEq() {
+ test_assignmentToConst_instanceVariable_plusEq() async {
Source source = addSource(r'''
class A {
static const v = 0;
@@ -706,45 +707,45 @@
f() {
A.v += 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
verify([source]);
}
- void test_assignmentToConst_localVariable() {
+ test_assignmentToConst_localVariable() async {
Source source = addSource(r'''
f() {
const x = 0;
x = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
verify([source]);
}
- void test_assignmentToConst_localVariable_plusEq() {
+ test_assignmentToConst_localVariable_plusEq() async {
Source source = addSource(r'''
f() {
const x = 0;
x += 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
verify([source]);
}
- void test_assignmentToEnumType() {
+ test_assignmentToEnumType() async {
Source source = addSource('''
enum E { e }
main() {
E = null;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
}
- void test_assignmentToFinal_instanceVariable() {
+ test_assignmentToFinal_instanceVariable() async {
Source source = addSource(r'''
class A {
final v = 0;
@@ -753,12 +754,12 @@
A a = new A();
a.v = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_instanceVariable_plusEq() {
+ test_assignmentToFinal_instanceVariable_plusEq() async {
Source source = addSource(r'''
class A {
final v = 0;
@@ -767,109 +768,109 @@
A a = new A();
a.v += 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_localVariable() {
+ test_assignmentToFinal_localVariable() async {
Source source = addSource(r'''
f() {
final x = 0;
x = 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_localVariable_plusEq() {
+ test_assignmentToFinal_localVariable_plusEq() async {
Source source = addSource(r'''
f() {
final x = 0;
x += 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_postfixMinusMinus() {
+ test_assignmentToFinal_postfixMinusMinus() async {
Source source = addSource(r'''
f() {
final x = 0;
x--;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_postfixPlusPlus() {
+ test_assignmentToFinal_postfixPlusPlus() async {
Source source = addSource(r'''
f() {
final x = 0;
x++;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_prefixMinusMinus() {
+ test_assignmentToFinal_prefixMinusMinus() async {
Source source = addSource(r'''
f() {
final x = 0;
--x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_prefixPlusPlus() {
+ test_assignmentToFinal_prefixPlusPlus() async {
Source source = addSource(r'''
f() {
final x = 0;
++x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_suffixMinusMinus() {
+ test_assignmentToFinal_suffixMinusMinus() async {
Source source = addSource(r'''
f() {
final x = 0;
x--;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_suffixPlusPlus() {
+ test_assignmentToFinal_suffixPlusPlus() async {
Source source = addSource(r'''
f() {
final x = 0;
x++;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinal_topLevelVariable() {
+ test_assignmentToFinal_topLevelVariable() async {
Source source = addSource(r'''
final x = 0;
f() { x = 1; }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
- void test_assignmentToFinalNoSetter_prefixedIdentifier() {
+ test_assignmentToFinalNoSetter_prefixedIdentifier() async {
Source source = addSource(r'''
class A {
int get x => 0;
@@ -878,12 +879,12 @@
A a = new A();
a.x = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER]);
verify([source]);
}
- void test_assignmentToFinalNoSetter_propertyAccess() {
+ test_assignmentToFinalNoSetter_propertyAccess() async {
Source source = addSource(r'''
class A {
int get x => 0;
@@ -894,23 +895,23 @@
main() {
B.a.x = 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER]);
verify([source]);
}
- void test_assignmentToFunction() {
+ test_assignmentToFunction() async {
Source source = addSource(r'''
f() {}
main() {
f = null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FUNCTION]);
verify([source]);
}
- void test_assignmentToMethod() {
+ test_assignmentToMethod() async {
Source source = addSource(r'''
class A {
m() {}
@@ -918,23 +919,23 @@
f(A a) {
a.m = () {};
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_METHOD]);
verify([source]);
}
- void test_assignmentToTypedef() {
+ test_assignmentToTypedef() async {
Source source = addSource('''
typedef void F();
main() {
F = null;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
}
- void test_assignmentToTypeParameter() {
+ test_assignmentToTypeParameter() async {
Source source = addSource('''
class C<T> {
f() {
@@ -942,11 +943,11 @@
}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
}
- void test_caseBlockNotTerminated() {
+ test_caseBlockNotTerminated() async {
Source source = addSource(r'''
f(int p) {
switch (p) {
@@ -956,32 +957,32 @@
break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
verify([source]);
}
- void test_castToNonType() {
+ test_castToNonType() async {
Source source = addSource(r'''
var A = 0;
f(String s) { var x = s as A; }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.CAST_TO_NON_TYPE]);
verify([source]);
}
- void test_concreteClassWithAbstractMember() {
+ test_concreteClassWithAbstractMember() async {
Source source = addSource(r'''
class A {
m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
verify([source]);
}
- void test_concreteClassWithAbstractMember_noSuchMethod_interface() {
+ test_concreteClassWithAbstractMember_noSuchMethod_interface() async {
Source source = addSource(r'''
class I {
noSuchMethod(v) => '';
@@ -989,13 +990,13 @@
class A implements I {
m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
verify([source]);
}
- void test_conflictingDartImport() {
+ test_conflictingDartImport() async {
Source source = addSource(r'''
import 'lib.dart';
import 'dart:async';
@@ -1006,12 +1007,11 @@
r'''
library lib;
class Future {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]);
}
- void
- test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter() {
+ test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter() async {
Source source = addSource(r'''
class A {
static set v(x) {}
@@ -1019,14 +1019,13 @@
class B extends A {
var v;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void
- test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_getter() {
+ test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_getter() async {
Source source = addSource(r'''
class A {
static get v => 0;
@@ -1034,14 +1033,13 @@
class B extends A {
get v => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void
- test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_method() {
+ test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_method() async {
Source source = addSource(r'''
class A {
static v() {}
@@ -1049,14 +1047,13 @@
class B extends A {
get v => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void
- test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_setter() {
+ test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_setter() async {
Source source = addSource(r'''
class A {
static set v(x) {}
@@ -1064,13 +1061,13 @@
class B extends A {
get v => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void test_conflictingInstanceGetterAndSuperclassMember_declGetter_indirect() {
+ test_conflictingInstanceGetterAndSuperclassMember_declGetter_indirect() async {
Source source = addSource(r'''
class A {
static int v;
@@ -1079,13 +1076,13 @@
class C extends B {
get v => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void test_conflictingInstanceGetterAndSuperclassMember_declGetter_mixin() {
+ test_conflictingInstanceGetterAndSuperclassMember_declGetter_mixin() async {
Source source = addSource(r'''
class M {
static int v;
@@ -1093,13 +1090,13 @@
class B extends Object with M {
get v => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void test_conflictingInstanceGetterAndSuperclassMember_direct_field() {
+ test_conflictingInstanceGetterAndSuperclassMember_direct_field() async {
Source source = addSource(r'''
class A {
static int v;
@@ -1107,37 +1104,37 @@
class B extends A {
get v => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void test_conflictingInstanceMethodSetter2() {
+ test_conflictingInstanceMethodSetter2() async {
Source source = addSource(r'''
class A {
foo() {}
set foo(a) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER2]);
verify([source]);
}
- void test_conflictingInstanceMethodSetter_sameClass() {
+ test_conflictingInstanceMethodSetter_sameClass() async {
Source source = addSource(r'''
class A {
set foo(a) {}
foo() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]);
verify([source]);
}
- void test_conflictingInstanceMethodSetter_setterInInterface() {
+ test_conflictingInstanceMethodSetter_setterInInterface() async {
Source source = addSource(r'''
abstract class A {
set foo(a);
@@ -1145,13 +1142,13 @@
abstract class B implements A {
foo() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]);
verify([source]);
}
- void test_conflictingInstanceMethodSetter_setterInSuper() {
+ test_conflictingInstanceMethodSetter_setterInSuper() async {
Source source = addSource(r'''
class A {
set foo(a) {}
@@ -1159,13 +1156,13 @@
class B extends A {
foo() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER]);
verify([source]);
}
- void test_conflictingInstanceSetterAndSuperclassMember() {
+ test_conflictingInstanceSetterAndSuperclassMember() async {
Source source = addSource(r'''
class A {
static int v;
@@ -1173,13 +1170,13 @@
class B extends A {
set v(x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
- void test_conflictingStaticGetterAndInstanceSetter_mixin() {
+ test_conflictingStaticGetterAndInstanceSetter_mixin() async {
Source source = addSource(r'''
class A {
set x(int p) {}
@@ -1187,13 +1184,13 @@
class B extends Object with A {
static get x => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]);
verify([source]);
}
- void test_conflictingStaticGetterAndInstanceSetter_superClass() {
+ test_conflictingStaticGetterAndInstanceSetter_superClass() async {
Source source = addSource(r'''
class A {
set x(int p) {}
@@ -1201,49 +1198,49 @@
class B extends A {
static get x => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]);
verify([source]);
}
- void test_conflictingStaticGetterAndInstanceSetter_thisClass() {
+ test_conflictingStaticGetterAndInstanceSetter_thisClass() async {
Source source = addSource(r'''
class A {
static get x => 0;
set x(int p) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]);
verify([source]);
}
- void test_conflictingStaticSetterAndInstanceMember_thisClass_getter() {
+ test_conflictingStaticSetterAndInstanceMember_thisClass_getter() async {
Source source = addSource(r'''
class A {
get x => 0;
static set x(int p) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER]);
verify([source]);
}
- void test_conflictingStaticSetterAndInstanceMember_thisClass_method() {
+ test_conflictingStaticSetterAndInstanceMember_thisClass_method() async {
Source source = addSource(r'''
class A {
x() {}
static set x(int p) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER]);
verify([source]);
}
- void test_constWithAbstractClass() {
+ test_constWithAbstractClass() async {
Source source = addSource(r'''
abstract class A {
const A();
@@ -1251,30 +1248,30 @@
void f() {
A a = const A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]);
verify([source]);
}
- void test_equalKeysInMap() {
+ test_equalKeysInMap() async {
Source source = addSource("var m = {'a' : 0, 'b' : 1, 'a' : 2};");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]);
verify([source]);
}
- void test_equalKeysInMap_withEqualTypeParams() {
+ test_equalKeysInMap_withEqualTypeParams() async {
Source source = addSource(r'''
class A<T> {
const A();
}
var m = {const A<int>(): 0, const A<int>(): 1};''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]);
verify([source]);
}
- void test_equalKeysInMap_withUnequalTypeParams() {
+ test_equalKeysInMap_withUnequalTypeParams() async {
// No error should be produced because A<int> and A<num> are different
// types.
Source source = addSource(r'''
@@ -1282,74 +1279,74 @@
const A();
}
var m = {const A<int>(): 0, const A<num>(): 1};''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_exportDuplicatedLibraryNamed() {
+ test_exportDuplicatedLibraryNamed() async {
Source source = addSource(r'''
library test;
export 'lib1.dart';
export 'lib2.dart';''');
addNamedSource("/lib1.dart", "library lib;");
addNamedSource("/lib2.dart", "library lib;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED]);
verify([source]);
}
- void test_extraPositionalArguments() {
+ test_extraPositionalArguments() async {
Source source = addSource(r'''
f() {}
main() {
f(0, 1, '2');
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]);
verify([source]);
}
- void test_extraPositionalArguments_functionExpression() {
+ test_extraPositionalArguments_functionExpression() async {
Source source = addSource(r'''
main() {
(int x) {} (0, 1);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]);
verify([source]);
}
- void test_fieldInitializedInInitializerAndDeclaration_final() {
+ test_fieldInitializedInInitializerAndDeclaration_final() async {
Source source = addSource(r'''
class A {
final int x = 0;
A() : x = 1 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
verify([source]);
}
- void test_fieldInitializerNotAssignable() {
+ test_fieldInitializerNotAssignable() async {
Source source = addSource(r'''
class A {
int x;
A() : x = '';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_fieldInitializingFormalNotAssignable() {
+ test_fieldInitializingFormalNotAssignable() async {
Source source = addSource(r'''
class A {
int x;
A(String this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE]);
verify([source]);
@@ -1364,56 +1361,56 @@
* FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, we use it instead of
* the broader code
*/
- void test_finalInitializedInDeclarationAndConstructor_initializers() {
+ test_finalInitializedInDeclarationAndConstructor_initializers() async {
Source source = addSource(r'''
class A {
final x = 0;
A() : x = 0 {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
verify([source]);
}
- void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
+ test_finalInitializedInDeclarationAndConstructor_initializingFormal() async {
Source source = addSource(r'''
class A {
final x = 0;
A(this.x) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR]);
verify([source]);
}
- void test_finalNotInitialized_inConstructor_1() {
+ test_finalNotInitialized_inConstructor_1() async {
Source source = addSource(r'''
class A {
final int x;
A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1]);
verify([source]);
}
- void test_finalNotInitialized_inConstructor_2() {
+ test_finalNotInitialized_inConstructor_2() async {
Source source = addSource(r'''
class A {
final int a;
final int b;
A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2]);
verify([source]);
}
- void test_finalNotInitialized_inConstructor_3() {
+ test_finalNotInitialized_inConstructor_3() async {
Source source = addSource(r'''
class A {
final int a;
@@ -1421,88 +1418,88 @@
final int c;
A() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS]);
verify([source]);
}
- void test_finalNotInitialized_instanceField_final() {
+ test_finalNotInitialized_instanceField_final() async {
Source source = addSource(r'''
class A {
final F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
- void test_finalNotInitialized_instanceField_final_static() {
+ test_finalNotInitialized_instanceField_final_static() async {
Source source = addSource(r'''
class A {
static final F;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
- void test_finalNotInitialized_library_final() {
+ test_finalNotInitialized_library_final() async {
Source source = addSource("final F;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
- void test_finalNotInitialized_local_final() {
+ test_finalNotInitialized_local_final() async {
Source source = addSource(r'''
f() {
final int x;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
- void test_functionWithoutCall_direct() {
+ test_functionWithoutCall_direct() async {
Source source = addSource(r'''
class A implements Function {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
verify([source]);
}
- void test_functionWithoutCall_indirect_extends() {
+ test_functionWithoutCall_indirect_extends() async {
Source source = addSource(r'''
abstract class A implements Function {
}
class B extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
verify([source]);
}
- void test_functionWithoutCall_indirect_implements() {
+ test_functionWithoutCall_indirect_implements() async {
Source source = addSource(r'''
abstract class A implements Function {
}
class B implements A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
verify([source]);
}
- void test_importDuplicatedLibraryNamed() {
+ test_importDuplicatedLibraryNamed() async {
Source source = addSource(r'''
library test;
import 'lib1.dart';
import 'lib2.dart';''');
addNamedSource("/lib1.dart", "library lib;");
addNamedSource("/lib2.dart", "library lib;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED,
HintCode.UNUSED_IMPORT,
@@ -1511,8 +1508,8 @@
verify([source]);
}
- void test_importOfNonLibrary() {
- resolveWithErrors(<String>[
+ test_importOfNonLibrary() async {
+ await resolveWithErrors(<String>[
r'''
part of lib;
class A {}''',
@@ -1525,7 +1522,7 @@
]);
}
- void test_inconsistentMethodInheritanceGetterAndMethod() {
+ test_inconsistentMethodInheritanceGetterAndMethod() async {
Source source = addSource(r'''
abstract class A {
int x();
@@ -1535,13 +1532,13 @@
}
class C implements A, B {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_field() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_field() async {
Source source = addSource(r'''
class A {
static var n;
@@ -1549,14 +1546,14 @@
class B extends A {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_field2() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_field2() async {
Source source = addSource(r'''
class A {
static var n;
@@ -1566,14 +1563,14 @@
class C extends B {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_getter() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_getter() async {
Source source = addSource(r'''
class A {
static get n {return 0;}
@@ -1581,14 +1578,14 @@
class B extends A {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_getter2() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_getter2() async {
Source source = addSource(r'''
class A {
static get n {return 0;}
@@ -1598,14 +1595,14 @@
class C extends B {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_interface() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_interface() async {
Source source = addSource(r'''
class Base {
static foo() {}
@@ -1617,14 +1614,14 @@
foo() {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_method() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_method() async {
Source source = addSource(r'''
class A {
static n () {}
@@ -1632,14 +1629,14 @@
class B extends A {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_method2() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_method2() async {
Source source = addSource(r'''
class A {
static n () {}
@@ -1649,14 +1646,14 @@
class C extends B {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_setter() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_setter() async {
Source source = addSource(r'''
class A {
static set n(int x) {}
@@ -1664,14 +1661,14 @@
class B extends A {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() {
+ test_instanceMethodNameCollidesWithSuperclassStatic_setter2() async {
Source source = addSource(r'''
class A {
static set n(int x) {}
@@ -1681,14 +1678,14 @@
class C extends B {
void n() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC
]);
verify([source]);
}
- void test_invalidGetterOverrideReturnType() {
+ test_invalidGetterOverrideReturnType() async {
Source source = addSource(r'''
class A {
int get g { return 0; }
@@ -1696,13 +1693,13 @@
class B extends A {
String get g { return 'a'; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidGetterOverrideReturnType_implicit() {
+ test_invalidGetterOverrideReturnType_implicit() async {
Source source = addSource(r'''
class A {
String f;
@@ -1710,7 +1707,7 @@
class B extends A {
int f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE,
StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE
@@ -1718,7 +1715,7 @@
verify([source]);
}
- void test_invalidGetterOverrideReturnType_twoInterfaces() {
+ test_invalidGetterOverrideReturnType_twoInterfaces() async {
// test from language/override_inheritance_field_test_11.dart
Source source = addSource(r'''
abstract class I {
@@ -1731,13 +1728,13 @@
class B extends A {
String get getter => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidGetterOverrideReturnType_twoInterfaces_conflicting() {
+ test_invalidGetterOverrideReturnType_twoInterfaces_conflicting() async {
Source source = addSource(r'''
abstract class I<U> {
U get g => null;
@@ -1748,13 +1745,13 @@
class B implements I<int>, J<String> {
double get g => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideNamedParamType() {
+ test_invalidMethodOverrideNamedParamType() async {
Source source = addSource(r'''
class A {
m({int a}) {}
@@ -1762,13 +1759,13 @@
class B implements A {
m({String a}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideNormalParamType_interface() {
+ test_invalidMethodOverrideNormalParamType_interface() async {
Source source = addSource(r'''
class A {
m(int a) {}
@@ -1776,13 +1773,13 @@
class B implements A {
m(String a) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideNormalParamType_superclass() {
+ test_invalidMethodOverrideNormalParamType_superclass() async {
Source source = addSource(r'''
class A {
m(int a) {}
@@ -1790,13 +1787,13 @@
class B extends A {
m(String a) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideNormalParamType_superclass_interface() {
+ test_invalidMethodOverrideNormalParamType_superclass_interface() async {
Source source = addSource(r'''
abstract class I<U> {
m(U u) => null;
@@ -1807,13 +1804,13 @@
class B extends I<int> implements J<String> {
m(double d) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideNormalParamType_twoInterfaces() {
+ test_invalidMethodOverrideNormalParamType_twoInterfaces() async {
Source source = addSource(r'''
abstract class I {
m(int n);
@@ -1825,13 +1822,13 @@
class B extends A {
m(String n) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideNormalParamType_twoInterfaces_conflicting() {
+ test_invalidMethodOverrideNormalParamType_twoInterfaces_conflicting() async {
// language/override_inheritance_generic_test/08
Source source = addSource(r'''
abstract class I<U> {
@@ -1843,13 +1840,13 @@
class B implements I<int>, J<String> {
m(double d) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideOptionalParamType() {
+ test_invalidMethodOverrideOptionalParamType() async {
Source source = addSource(r'''
class A {
m([int a]) {}
@@ -1857,13 +1854,13 @@
class B implements A {
m([String a]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideOptionalParamType_twoInterfaces() {
+ test_invalidMethodOverrideOptionalParamType_twoInterfaces() async {
Source source = addSource(r'''
abstract class I {
m([int n]);
@@ -1875,13 +1872,13 @@
class B extends A {
m([String n]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideReturnType_interface() {
+ test_invalidMethodOverrideReturnType_interface() async {
Source source = addSource(r'''
class A {
int m() { return 0; }
@@ -1889,13 +1886,13 @@
class B implements A {
String m() { return 'a'; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideReturnType_interface_grandparent() {
+ test_invalidMethodOverrideReturnType_interface_grandparent() async {
Source source = addSource(r'''
abstract class A {
int m();
@@ -1905,13 +1902,13 @@
class C implements B {
String m() { return 'a'; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideReturnType_mixin() {
+ test_invalidMethodOverrideReturnType_mixin() async {
Source source = addSource(r'''
class A {
int m() { return 0; }
@@ -1919,13 +1916,13 @@
class B extends Object with A {
String m() { return 'a'; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideReturnType_superclass() {
+ test_invalidMethodOverrideReturnType_superclass() async {
Source source = addSource(r'''
class A {
int m() { return 0; }
@@ -1933,13 +1930,13 @@
class B extends A {
String m() { return 'a'; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideReturnType_superclass_grandparent() {
+ test_invalidMethodOverrideReturnType_superclass_grandparent() async {
Source source = addSource(r'''
class A {
int m() { return 0; }
@@ -1949,13 +1946,13 @@
class C extends B {
String m() { return 'a'; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideReturnType_twoInterfaces() {
+ test_invalidMethodOverrideReturnType_twoInterfaces() async {
Source source = addSource(r'''
abstract class I {
int m();
@@ -1967,13 +1964,13 @@
class B extends A {
String m() => '';
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidMethodOverrideReturnType_void() {
+ test_invalidMethodOverrideReturnType_void() async {
Source source = addSource(r'''
class A {
int m() { return 0; }
@@ -1981,13 +1978,13 @@
class B extends A {
void m() {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
- void test_invalidOverride_defaultOverridesNonDefault() {
+ test_invalidOverride_defaultOverridesNonDefault() async {
// If the base class provided an explicit value for a default parameter,
// then it is a static warning for the derived class to provide a different
// value, even if implicitly.
@@ -1999,14 +1996,14 @@
foo([x]) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL
]);
verify([source]);
}
- void test_invalidOverride_defaultOverridesNonDefault_named() {
+ test_invalidOverride_defaultOverridesNonDefault_named() async {
// If the base class provided an explicit value for a default parameter,
// then it is a static warning for the derived class to provide a different
// value, even if implicitly.
@@ -2018,13 +2015,13 @@
foo({x}) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED]);
verify([source]);
}
- void test_invalidOverride_defaultOverridesNonDefaultNull() {
+ test_invalidOverride_defaultOverridesNonDefaultNull() async {
// If the base class provided an explicit null value for a default
// parameter, then it is ok for the derived class to let the default value
// be implicit, because the implicit default value of null matches the
@@ -2037,12 +2034,12 @@
foo([x]) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverride_defaultOverridesNonDefaultNull_named() {
+ test_invalidOverride_defaultOverridesNonDefaultNull_named() async {
// If the base class provided an explicit null value for a default
// parameter, then it is ok for the derived class to let the default value
// be implicit, because the implicit default value of null matches the
@@ -2055,12 +2052,12 @@
foo({x}) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverride_nonDefaultOverridesDefault() {
+ test_invalidOverride_nonDefaultOverridesDefault() async {
// If the base class lets the default parameter be implicit, then it is ok
// for the derived class to provide an explicit default value, even if it's
// not null.
@@ -2072,12 +2069,12 @@
foo([x = 1]) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverride_nonDefaultOverridesDefault_named() {
+ test_invalidOverride_nonDefaultOverridesDefault_named() async {
// If the base class lets the default parameter be implicit, then it is ok
// for the derived class to provide an explicit default value, even if it's
// not null.
@@ -2089,12 +2086,12 @@
foo({x: 1}) {}
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_invalidOverrideDifferentDefaultValues_named() {
+ test_invalidOverrideDifferentDefaultValues_named() async {
Source source = addSource(r'''
class A {
m({int p : 0}) {}
@@ -2102,13 +2099,13 @@
class B extends A {
m({int p : 1}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED]);
verify([source]);
}
- void test_invalidOverrideDifferentDefaultValues_positional() {
+ test_invalidOverrideDifferentDefaultValues_positional() async {
Source source = addSource(r'''
class A {
m([int p = 0]) {}
@@ -2116,14 +2113,14 @@
class B extends A {
m([int p = 1]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL
]);
verify([source]);
}
- void test_invalidOverrideNamed_fewerNamedParameters() {
+ test_invalidOverrideNamed_fewerNamedParameters() async {
Source source = addSource(r'''
class A {
m({a, b}) {}
@@ -2131,12 +2128,12 @@
class B extends A {
m({a}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]);
verify([source]);
}
- void test_invalidOverrideNamed_missingNamedParameter() {
+ test_invalidOverrideNamed_missingNamedParameter() async {
Source source = addSource(r'''
class A {
m({a, b}) {}
@@ -2144,12 +2141,12 @@
class B extends A {
m({a, c}) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]);
verify([source]);
}
- void test_invalidOverridePositional_optional() {
+ test_invalidOverridePositional_optional() async {
Source source = addSource(r'''
class A {
m([a, b]) {}
@@ -2157,12 +2154,12 @@
class B extends A {
m([a]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
verify([source]);
}
- void test_invalidOverridePositional_optionalAndRequired() {
+ test_invalidOverridePositional_optionalAndRequired() async {
Source source = addSource(r'''
class A {
m(a, b, [c, d]) {}
@@ -2170,12 +2167,12 @@
class B extends A {
m(a, b, [c]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
verify([source]);
}
- void test_invalidOverridePositional_optionalAndRequired2() {
+ test_invalidOverridePositional_optionalAndRequired2() async {
Source source = addSource(r'''
class A {
m(a, b, [c, d]) {}
@@ -2183,12 +2180,12 @@
class B extends A {
m(a, [c, d]) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
verify([source]);
}
- void test_invalidOverrideRequired() {
+ test_invalidOverrideRequired() async {
Source source = addSource(r'''
class A {
m(a) {}
@@ -2196,12 +2193,12 @@
class B extends A {
m(a, b) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_REQUIRED]);
verify([source]);
}
- void test_invalidSetterOverrideNormalParamType() {
+ test_invalidSetterOverrideNormalParamType() async {
Source source = addSource(r'''
class A {
void set s(int v) {}
@@ -2209,13 +2206,13 @@
class B extends A {
void set s(String v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidSetterOverrideNormalParamType_superclass_interface() {
+ test_invalidSetterOverrideNormalParamType_superclass_interface() async {
Source source = addSource(r'''
abstract class I {
set setter14(int _) => null;
@@ -2227,13 +2224,13 @@
class B extends A {
set setter14(String _) => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidSetterOverrideNormalParamType_twoInterfaces() {
+ test_invalidSetterOverrideNormalParamType_twoInterfaces() async {
// test from language/override_inheritance_field_test_34.dart
Source source = addSource(r'''
abstract class I {
@@ -2246,13 +2243,13 @@
class B extends A {
set setter14(String _) => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_invalidSetterOverrideNormalParamType_twoInterfaces_conflicting() {
+ test_invalidSetterOverrideNormalParamType_twoInterfaces_conflicting() async {
Source source = addSource(r'''
abstract class I<U> {
set s(U u) {}
@@ -2263,46 +2260,46 @@
class B implements I<int>, J<String> {
set s(double d) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
verify([source]);
}
- void test_listElementTypeNotAssignable() {
+ test_listElementTypeNotAssignable() async {
Source source = addSource("var v = <String> [42];");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_mapKeyTypeNotAssignable() {
+ test_mapKeyTypeNotAssignable() async {
Source source = addSource("var v = <String, int > {1 : 2};");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_mapValueTypeNotAssignable() {
+ test_mapValueTypeNotAssignable() async {
Source source = addSource("var v = <String, String> {'a' : 2};");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_mismatchedAccessorTypes_class() {
+ test_mismatchedAccessorTypes_class() async {
Source source = addSource(r'''
class A {
int get g { return 0; }
set g(String v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
verify([source]);
}
- void test_mismatchedAccessorTypes_getterAndSuperSetter() {
+ test_mismatchedAccessorTypes_getterAndSuperSetter() async {
Source source = addSource(r'''
class A {
int get g { return 0; }
@@ -2310,13 +2307,13 @@
class B extends A {
set g(String v) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE]);
verify([source]);
}
- void test_mismatchedAccessorTypes_setterAndSuperGetter() {
+ test_mismatchedAccessorTypes_setterAndSuperGetter() async {
Source source = addSource(r'''
class A {
set g(int v) {}
@@ -2324,23 +2321,23 @@
class B extends A {
String get g { return ''; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE]);
verify([source]);
}
- void test_mismatchedAccessorTypes_topLevel() {
+ test_mismatchedAccessorTypes_topLevel() async {
Source source = addSource(r'''
int get g { return 0; }
set g(String v) {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
verify([source]);
}
- void test_missingEnumConstantInSwitch() {
+ test_missingEnumConstantInSwitch() async {
Source source = addSource(r'''
enum E { ONE, TWO, THREE, FOUR }
bool odd(E e) {
@@ -2350,7 +2347,7 @@
}
return false;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH,
StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH
@@ -2358,7 +2355,7 @@
verify([source]);
}
- void test_mixedReturnTypes_localFunction() {
+ test_mixedReturnTypes_localFunction() async {
Source source = addSource(r'''
class C {
m(int x) {
@@ -2370,7 +2367,7 @@
};
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.MIXED_RETURN_TYPES,
StaticWarningCode.MIXED_RETURN_TYPES
@@ -2378,7 +2375,7 @@
verify([source]);
}
- void test_mixedReturnTypes_method() {
+ test_mixedReturnTypes_method() async {
Source source = addSource(r'''
class C {
m(int x) {
@@ -2388,7 +2385,7 @@
return 0;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.MIXED_RETURN_TYPES,
StaticWarningCode.MIXED_RETURN_TYPES
@@ -2396,7 +2393,7 @@
verify([source]);
}
- void test_mixedReturnTypes_topLevelFunction() {
+ test_mixedReturnTypes_topLevelFunction() async {
Source source = addSource(r'''
f(int x) {
if (x < 0) {
@@ -2404,7 +2401,7 @@
}
return 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.MIXED_RETURN_TYPES,
StaticWarningCode.MIXED_RETURN_TYPES
@@ -2412,62 +2409,62 @@
verify([source]);
}
- void test_newWithAbstractClass() {
+ test_newWithAbstractClass() async {
Source source = addSource(r'''
abstract class A {}
void f() {
A a = new A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]);
verify([source]);
}
- void test_newWithInvalidTypeParameters() {
+ test_newWithInvalidTypeParameters() async {
Source source = addSource(r'''
class A {}
f() { return new A<A>(); }''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
- void test_newWithInvalidTypeParameters_tooFew() {
+ test_newWithInvalidTypeParameters_tooFew() async {
Source source = addSource(r'''
class A {}
class C<K, V> {}
f(p) {
return new C<A>();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
- void test_newWithInvalidTypeParameters_tooMany() {
+ test_newWithInvalidTypeParameters_tooMany() async {
Source source = addSource(r'''
class A {}
class C<E> {}
f(p) {
return new C<A, A>();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
- void test_newWithNonType() {
+ test_newWithNonType() async {
Source source = addSource(r'''
var A = 0;
void f() {
var a = new A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]);
verify([source]);
}
- void test_newWithNonType_fromLibrary() {
+ test_newWithNonType_fromLibrary() async {
Source source1 = addNamedSource("/lib.dart", "class B {}");
Source source2 = addNamedSource(
"/lib2.dart",
@@ -2477,13 +2474,13 @@
var a = new lib.A();
}
lib.B b;''');
- computeLibrarySourceErrors(source1);
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source1);
+ await computeAnalysisResult(source2);
assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]);
verify([source1]);
}
- void test_newWithUndefinedConstructor() {
+ test_newWithUndefinedConstructor() async {
Source source = addSource(r'''
class A {
A() {}
@@ -2491,12 +2488,12 @@
f() {
new A.name();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
// no verify(), 'name' is not resolved
}
- void test_newWithUndefinedConstructorDefault() {
+ test_newWithUndefinedConstructorDefault() async {
Source source = addSource(r'''
class A {
A.name() {}
@@ -2504,13 +2501,13 @@
f() {
new A();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberFivePlus() {
+ test_nonAbstractClassInheritsAbstractMemberFivePlus() async {
Source source = addSource(r'''
abstract class A {
m();
@@ -2521,14 +2518,14 @@
}
class C extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS
]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberFour() {
+ test_nonAbstractClassInheritsAbstractMemberFour() async {
Source source = addSource(r'''
abstract class A {
m();
@@ -2538,14 +2535,13 @@
}
class C extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() {
+ test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() async {
// 15979
Source source = addSource(r'''
abstract class M {}
@@ -2554,13 +2550,13 @@
m();
}
class B = A with M implements I;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() {
+ test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() async {
// 15979
Source source = addSource(r'''
abstract class M {
@@ -2568,14 +2564,13 @@
}
abstract class A {}
class B = A with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() {
+ test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() async {
// 15979
Source source = addSource(r'''
class M {}
@@ -2583,14 +2578,13 @@
m();
}
class B = A with M;''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_ensureCorrectFunctionSubtypeIsUsedInImplementation() {
+ test_nonAbstractClassInheritsAbstractMemberOne_ensureCorrectFunctionSubtypeIsUsedInImplementation() async {
// 15028
Source source = addSource(r'''
class C {
@@ -2600,66 +2594,65 @@
foo(x, [y]);
}
class E extends C implements D {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() {
+ test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() async {
Source source = addSource(r'''
class I {
int get g {return 1;}
}
class C implements I {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() {
+ test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() async {
Source source = addSource(r'''
abstract class A {
int get g;
}
class C extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() {
+ test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() async {
Source source = addSource(r'''
class I {
m(p) {}
}
class C implements I {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() {
+ test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() async {
Source source = addSource(r'''
abstract class A {
m(p);
}
class C extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount() {
+ test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount() async {
// 7640
Source source = addSource(r'''
abstract class A {
@@ -2670,46 +2663,46 @@
}
class C implements A, B {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_getter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_getter() async {
// 15001
Source source = addSource(r'''
abstract class A { get g1; get g2; }
abstract class B implements A { get g1 => 1; }
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_method() {
+ test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_method() async {
// 15001
Source source = addSource(r'''
abstract class A { m1(); m2(); }
abstract class B implements A { m1() => 1; }
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_setter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_mixinInherits_setter() async {
// 15001
Source source = addSource(r'''
abstract class A { set s1(v); set s2(v); }
abstract class B implements A { set s1(v) {} }
class C extends Object with B {}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_interface() {
+ test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_interface() async {
// 15979
Source source = addSource(r'''
class I {
@@ -2720,14 +2713,13 @@
}
class B extends A implements I {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_setter_and_implicitSetter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_setter_and_implicitSetter() async {
// test from language/override_inheritance_abstract_test_14.dart
Source source = addSource(r'''
abstract class A {
@@ -2739,39 +2731,39 @@
class B extends A implements I {
get field => 0;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() {
+ test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() async {
Source source = addSource(r'''
class I {
set s(int i) {}
}
class C implements I {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() {
+ test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() async {
Source source = addSource(r'''
abstract class A {
set s(int i);
}
class C extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() {
+ test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() async {
// bug 11154
Source source = addSource(r'''
class A {
@@ -2782,14 +2774,13 @@
}
class C extends B {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingGetter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingGetter() async {
// 16133
Source source = addSource(r'''
class I {
@@ -2798,14 +2789,13 @@
class C implements I {
set v(_) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingSetter() {
+ test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_missingSetter() async {
// 16133
Source source = addSource(r'''
class I {
@@ -2814,13 +2804,13 @@
class C implements I {
get v => 1;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberThree() {
+ test_nonAbstractClassInheritsAbstractMemberThree() async {
Source source = addSource(r'''
abstract class A {
m();
@@ -2829,13 +2819,13 @@
}
class C extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE]);
verify([source]);
}
- void test_nonAbstractClassInheritsAbstractMemberTwo() {
+ test_nonAbstractClassInheritsAbstractMemberTwo() async {
Source source = addSource(r'''
abstract class A {
m();
@@ -2843,14 +2833,13 @@
}
class C extends A {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromInterface_missingBoth() {
+ test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromInterface_missingBoth() async {
// 16133
Source source = addSource(r'''
class I {
@@ -2858,16 +2847,15 @@
}
class C implements I {
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
verify([source]);
}
- void
- test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromMixin_missingBoth() {
+ test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromMixin_missingBoth() async {
// 26411
- resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
+ resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
Source source = addSource(r'''
class A {
int f;
@@ -2875,25 +2863,25 @@
class B extends A {}
class C extends Object with B {}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
verify([source]);
}
- void test_nonTypeInCatchClause_noElement() {
+ test_nonTypeInCatchClause_noElement() async {
Source source = addSource(r'''
f() {
try {
} on T catch (e) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
verify([source]);
}
- void test_nonTypeInCatchClause_notType() {
+ test_nonTypeInCatchClause_notType() async {
Source source = addSource(r'''
var T = 0;
f() {
@@ -2901,98 +2889,98 @@
} on T catch (e) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
verify([source]);
}
- void test_nonVoidReturnForOperator() {
+ test_nonVoidReturnForOperator() async {
Source source = addSource(r'''
class A {
int operator []=(a, b) { return a; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]);
verify([source]);
}
- void test_nonVoidReturnForSetter_function() {
+ test_nonVoidReturnForSetter_function() async {
Source source = addSource(r'''
int set x(int v) {
return 42;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
verify([source]);
}
- void test_nonVoidReturnForSetter_method() {
+ test_nonVoidReturnForSetter_method() async {
Source source = addSource(r'''
class A {
int set x(int v) {
return 42;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
verify([source]);
}
- void test_notAType() {
+ test_notAType() async {
Source source = addSource(r'''
f() {}
main() {
f v = null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NOT_A_TYPE]);
verify([source]);
}
- void test_notEnoughRequiredArguments() {
+ test_notEnoughRequiredArguments() async {
Source source = addSource(r'''
f(int a, String b) {}
main() {
f();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
verify([source]);
}
- void test_notEnoughRequiredArguments_functionExpression() {
+ test_notEnoughRequiredArguments_functionExpression() async {
Source source = addSource(r'''
main() {
(int x) {} ();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
verify([source]);
}
- void test_notEnoughRequiredArguments_getterReturningFunction() {
+ test_notEnoughRequiredArguments_getterReturningFunction() async {
Source source = addSource(r'''
typedef Getter(self);
Getter getter = (x) => x;
main() {
getter();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
verify([source]);
}
- void test_partOfDifferentLibrary() {
+ test_partOfDifferentLibrary() async {
Source source = addSource(r'''
library lib;
part 'part.dart';''');
addNamedSource("/part.dart", "part of lub;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]);
verify([source]);
}
- void test_redirectToInvalidFunctionType() {
+ test_redirectToInvalidFunctionType() async {
Source source = addSource(r'''
class A implements B {
A(int p) {}
@@ -3000,12 +2988,12 @@
class B {
factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]);
verify([source]);
}
- void test_redirectToInvalidReturnType() {
+ test_redirectToInvalidReturnType() async {
Source source = addSource(r'''
class A {
A() {}
@@ -3013,12 +3001,12 @@
class B {
factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]);
verify([source]);
}
- void test_redirectToMissingConstructor_named() {
+ test_redirectToMissingConstructor_named() async {
Source source = addSource(r'''
class A implements B{
A() {}
@@ -3026,11 +3014,11 @@
class B {
factory B() = A.name;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
}
- void test_redirectToMissingConstructor_unnamed() {
+ test_redirectToMissingConstructor_unnamed() async {
Source source = addSource(r'''
class A implements B{
A.name() {}
@@ -3038,65 +3026,65 @@
class B {
factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
}
- void test_redirectToNonClass_notAType() {
+ test_redirectToNonClass_notAType() async {
Source source = addSource(r'''
class B {
int A;
factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]);
verify([source]);
}
- void test_redirectToNonClass_undefinedIdentifier() {
+ test_redirectToNonClass_undefinedIdentifier() async {
Source source = addSource(r'''
class B {
factory B() = A;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]);
verify([source]);
}
- void test_returnWithoutValue_async() {
+ test_returnWithoutValue_async() async {
Source source = addSource('''
import 'dart:async';
Future<int> f() async {
return;
}
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
verify([source]);
}
- void test_returnWithoutValue_factoryConstructor() {
+ test_returnWithoutValue_factoryConstructor() async {
Source source = addSource("class A { factory A() { return; } }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
verify([source]);
}
- void test_returnWithoutValue_function() {
+ test_returnWithoutValue_function() async {
Source source = addSource("int f() { return; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
verify([source]);
}
- void test_returnWithoutValue_method() {
+ test_returnWithoutValue_method() async {
Source source = addSource("class A { int m() { return; } }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
verify([source]);
}
- void test_returnWithoutValue_mixedReturnTypes_function() {
+ test_returnWithoutValue_mixedReturnTypes_function() async {
// Tests that only the RETURN_WITHOUT_VALUE warning is created, and no
// MIXED_RETURN_TYPES are created.
Source source = addSource(r'''
@@ -3106,12 +3094,12 @@
}
return;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
verify([source]);
}
- void test_staticAccessToInstanceMember_method_invocation() {
+ test_staticAccessToInstanceMember_method_invocation() async {
Source source = addSource(r'''
class A {
m() {}
@@ -3119,12 +3107,12 @@
main() {
A.m();
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
verify([source]);
}
- void test_staticAccessToInstanceMember_method_reference() {
+ test_staticAccessToInstanceMember_method_reference() async {
Source source = addSource(r'''
class A {
m() {}
@@ -3132,12 +3120,12 @@
main() {
A.m;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
verify([source]);
}
- void test_staticAccessToInstanceMember_propertyAccess_field() {
+ test_staticAccessToInstanceMember_propertyAccess_field() async {
Source source = addSource(r'''
class A {
var f;
@@ -3145,12 +3133,12 @@
main() {
A.f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
verify([source]);
}
- void test_staticAccessToInstanceMember_propertyAccess_getter() {
+ test_staticAccessToInstanceMember_propertyAccess_getter() async {
Source source = addSource(r'''
class A {
get f => 42;
@@ -3158,12 +3146,12 @@
main() {
A.f;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
verify([source]);
}
- void test_staticAccessToInstanceMember_propertyAccess_setter() {
+ test_staticAccessToInstanceMember_propertyAccess_setter() async {
Source source = addSource(r'''
class A {
set f(x) {}
@@ -3171,25 +3159,25 @@
main() {
A.f = 42;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
verify([source]);
}
- void test_switchExpressionNotAssignable() {
+ test_switchExpressionNotAssignable() async {
Source source = addSource(r'''
f(int p) {
switch (p) {
case 'a': break;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]);
verify([source]);
}
- void test_typeAnnotationDeferredClass_asExpression() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_asExpression() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3204,8 +3192,8 @@
]);
}
- void test_typeAnnotationDeferredClass_catchClause() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_catchClause() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3222,8 +3210,8 @@
]);
}
- void test_typeAnnotationDeferredClass_fieldFormalParameter() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_fieldFormalParameter() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3239,8 +3227,8 @@
]);
}
- void test_typeAnnotationDeferredClass_functionDeclaration_returnType() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_functionDeclaration_returnType() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3253,9 +3241,8 @@
]);
}
- void
- test_typeAnnotationDeferredClass_functionTypedFormalParameter_returnType() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_functionTypedFormalParameter_returnType() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3268,8 +3255,8 @@
]);
}
- void test_typeAnnotationDeferredClass_isExpression() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_isExpression() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3284,8 +3271,8 @@
]);
}
- void test_typeAnnotationDeferredClass_methodDeclaration_returnType() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_methodDeclaration_returnType() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3300,8 +3287,8 @@
]);
}
- void test_typeAnnotationDeferredClass_simpleFormalParameter() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_simpleFormalParameter() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3314,8 +3301,8 @@
]);
}
- void test_typeAnnotationDeferredClass_typeArgumentList() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_typeArgumentList() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3329,8 +3316,8 @@
]);
}
- void test_typeAnnotationDeferredClass_typeArgumentList2() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_typeArgumentList2() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3345,8 +3332,8 @@
]);
}
- void test_typeAnnotationDeferredClass_typeParameter_bound() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_typeParameter_bound() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3359,8 +3346,8 @@
]);
}
- void test_typeAnnotationDeferredClass_variableDeclarationList() {
- resolveWithErrors(<String>[
+ test_typeAnnotationDeferredClass_variableDeclarationList() async {
+ await resolveWithErrors(<String>[
r'''
library lib1;
class A {}''',
@@ -3373,7 +3360,7 @@
]);
}
- void test_typeAnnotationGenericFunctionParameter_localFunction() {
+ test_typeAnnotationGenericFunctionParameter_localFunction() async {
Source source = addSource(r'''
class A {
void method() {
@@ -3382,105 +3369,105 @@
}
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
verify([source]);
}
- void test_typeAnnotationGenericFunctionParameter_method() {
+ test_typeAnnotationGenericFunctionParameter_method() async {
Source source = addSource(r'''
class A {
T method<T>(Object t) {
return (t is T) ? t : null;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
verify([source]);
}
- void test_typeAnnotationGenericFunctionParameter_topLevelFunction() {
+ test_typeAnnotationGenericFunctionParameter_topLevelFunction() async {
Source source = addSource(r'''
T function<T>(Object t) {
return (t is T) ? t : null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
verify([source]);
}
- void test_typeParameterReferencedByStatic_field() {
+ test_typeParameterReferencedByStatic_field() async {
Source source = addSource(r'''
class A<K> {
static K k;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
verify([source]);
}
- void test_typeParameterReferencedByStatic_getter() {
+ test_typeParameterReferencedByStatic_getter() async {
Source source = addSource(r'''
class A<K> {
static K get k => null;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
verify([source]);
}
- void test_typeParameterReferencedByStatic_methodBodyReference() {
+ test_typeParameterReferencedByStatic_methodBodyReference() async {
Source source = addSource(r'''
class A<K> {
static m() {
K k;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
verify([source]);
}
- void test_typeParameterReferencedByStatic_methodParameter() {
+ test_typeParameterReferencedByStatic_methodParameter() async {
Source source = addSource(r'''
class A<K> {
static m(K k) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
verify([source]);
}
- void test_typeParameterReferencedByStatic_methodReturn() {
+ test_typeParameterReferencedByStatic_methodReturn() async {
Source source = addSource(r'''
class A<K> {
static K m() { return null; }
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
verify([source]);
}
- void test_typeParameterReferencedByStatic_setter() {
+ test_typeParameterReferencedByStatic_setter() async {
Source source = addSource(r'''
class A<K> {
static set s(K k) {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(
source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
verify([source]);
}
- void test_typePromotion_functionType_arg_InterToDyn() {
+ test_typePromotion_functionType_arg_InterToDyn() async {
Source source = addSource(r'''
typedef FuncDyn(x);
typedef FuncA(A a);
@@ -3491,52 +3478,52 @@
f(new B());
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
}
- void test_typeTestNonType() {
+ test_typeTestNonType() async {
Source source = addSource(r'''
var A = 0;
f(var p) {
if (p is A) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.TYPE_TEST_WITH_NON_TYPE]);
verify([source]);
}
- void test_typeTestWithUndefinedName() {
+ test_typeTestWithUndefinedName() async {
Source source = addSource(r'''
f(var p) {
if (p is A) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.TYPE_TEST_WITH_UNDEFINED_NAME]);
verify([source]);
}
- void test_undefinedClass_instanceCreation() {
+ test_undefinedClass_instanceCreation() async {
Source source = addSource("f() { new C(); }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
}
- void test_undefinedClass_variableDeclaration() {
+ test_undefinedClass_variableDeclaration() async {
Source source = addSource("f() { C c; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
}
- void test_undefinedClassBoolean_variableDeclaration() {
+ test_undefinedClassBoolean_variableDeclaration() async {
Source source = addSource("f() { boolean v; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]);
}
- void test_undefinedGetter_fromLibrary() {
+ test_undefinedGetter_fromLibrary() async {
Source source1 = addNamedSource("/lib.dart", "");
Source source2 = addNamedSource(
"/lib2.dart",
@@ -3545,52 +3532,52 @@
void f() {
var g = lib.gg;
}''');
- computeLibrarySourceErrors(source1);
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source1);
+ await computeAnalysisResult(source2);
assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]);
verify([source1]);
}
- void test_undefinedIdentifier_for() {
+ test_undefinedIdentifier_for() async {
Source source = addSource(r'''
f(var l) {
for (e in l) {
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
- void test_undefinedIdentifier_function() {
+ test_undefinedIdentifier_function() async {
Source source = addSource("int a() => b;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
- void test_undefinedIdentifier_importCore_withShow() {
+ test_undefinedIdentifier_importCore_withShow() async {
Source source = addSource(r'''
import 'dart:core' show List;
main() {
List;
String;
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
- void test_undefinedIdentifier_initializer() {
+ test_undefinedIdentifier_initializer() async {
Source source = addSource("var a = b;");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
- void test_undefinedIdentifier_methodInvocation() {
+ test_undefinedIdentifier_methodInvocation() async {
Source source = addSource("f() { C.m(); }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
- void test_undefinedIdentifier_private_getter() {
+ test_undefinedIdentifier_private_getter() async {
addNamedSource(
"/lib.dart",
r'''
@@ -3605,11 +3592,11 @@
var v = _foo;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
- void test_undefinedIdentifier_private_setter() {
+ test_undefinedIdentifier_private_setter() async {
addNamedSource(
"/lib.dart",
r'''
@@ -3624,29 +3611,29 @@
_foo = 42;
}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
- void test_undefinedIdentifierAwait_function() {
+ test_undefinedIdentifierAwait_function() async {
Source source = addSource("void a() { await; }");
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT]);
}
- void test_undefinedNamedParameter() {
+ test_undefinedNamedParameter() async {
Source source = addSource(r'''
f({a, b}) {}
main() {
f(c: 1);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]);
// no verify(), 'c' is not resolved
}
- void test_undefinedSetter() {
- Source source1 = addNamedSource("/lib.dart", "");
+ test_undefinedSetter() async {
+ addNamedSource("/lib.dart", "");
Source source2 = addNamedSource(
"/lib2.dart",
r'''
@@ -3654,22 +3641,21 @@
void f() {
lib.gg = null;
}''');
- computeLibrarySourceErrors(source1);
- computeLibrarySourceErrors(source2);
+ await computeAnalysisResult(source2);
assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]);
}
- void test_undefinedStaticMethodOrGetter_getter() {
+ test_undefinedStaticMethodOrGetter_getter() async {
Source source = addSource(r'''
class C {}
f(var p) {
f(C.m);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedStaticMethodOrGetter_getter_inSuperclass() {
+ test_undefinedStaticMethodOrGetter_getter_inSuperclass() async {
Source source = addSource(r'''
class S {
static int get g => 0;
@@ -3678,21 +3664,21 @@
f(var p) {
f(C.g);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
- void test_undefinedStaticMethodOrGetter_method() {
+ test_undefinedStaticMethodOrGetter_method() async {
Source source = addSource(r'''
class C {}
f(var p) {
f(C.m());
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedStaticMethodOrGetter_method_inSuperclass() {
+ test_undefinedStaticMethodOrGetter_method_inSuperclass() async {
Source source = addSource(r'''
class S {
static m() {}
@@ -3701,11 +3687,11 @@
f(var p) {
f(C.m());
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
- void test_undefinedStaticMethodOrGetter_setter_inSuperclass() {
+ test_undefinedStaticMethodOrGetter_setter_inSuperclass() async {
Source source = addSource(r'''
class S {
static set s(int i) {}
@@ -3714,16 +3700,16 @@
f(var p) {
f(C.s = 1);
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
- void test_voidReturnForGetter() {
+ test_voidReturnForGetter() async {
Source source = addSource(r'''
class S {
void get value {}
}''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]);
}
}
diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart
index 3d1948f..920eb12 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -4,6 +4,8 @@
library analyzer.test.generated.strong_mode_test;
+import 'dart:async';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -23,6 +25,9 @@
defineReflectiveTests(StrongModeDownwardsInferenceTest);
defineReflectiveTests(StrongModeStaticTypeAnalyzer2Test);
defineReflectiveTests(StrongModeTypePropagationTest);
+ defineReflectiveTests(StrongModeDownwardsInferenceTest_Driver);
+ defineReflectiveTests(StrongModeStaticTypeAnalyzer2Test_Driver);
+ defineReflectiveTests(StrongModeTypePropagationTest_Driver);
});
}
@@ -52,14 +57,14 @@
AsserterBuilder<DartType, DartType> _isType;
AsserterBuilder<Element, DartType> _hasElement;
- AsserterBuilder<DartType, DartType> _sameElement;
+ AsserterBuilder<DartType, DartType> _hasElementOf;
@override
void setUp() {
super.setUp();
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.strongMode = true;
- resetWithOptions(options);
+ resetWith(options: options);
_assertions = new TypeAssertions(typeProvider);
_isType = _assertions.isType;
_hasElement = _assertions.hasElement;
@@ -71,14 +76,14 @@
_isListOf = _assertions.isListOf;
_isMapOf = _assertions.isMapOf;
_isFunction2Of = _assertions.isFunction2Of;
- _sameElement = _assertions.sameElement;
- _isFutureOf = _isInstantiationOf(_sameElement(typeProvider.futureType));
+ _hasElementOf = _assertions.hasElementOf;
+ _isFutureOf = _isInstantiationOf(_hasElementOf(typeProvider.futureType));
_isFutureOfDynamic = _isFutureOf([_isDynamic]);
_isFutureOfInt = _isFutureOf([_isInt]);
- _isStreamOf = _isInstantiationOf(_sameElement(typeProvider.streamType));
+ _isStreamOf = _isInstantiationOf(_hasElementOf(typeProvider.streamType));
}
- void test_async_method_propagation() {
+ test_async_method_propagation() async {
String code = r'''
import "dart:async";
class A {
@@ -99,7 +104,7 @@
Future<int> g5() async { return await new Future.value(3); }
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
void check(String name, Asserter<InterfaceType> typeTest) {
MethodDeclaration test = AstFinder.getMethodInClass(unit, "A", name);
@@ -135,7 +140,7 @@
check("g5", _isFutureOfInt);
}
- void test_async_propagation() {
+ test_async_propagation() async {
String code = r'''
import "dart:async";
@@ -155,7 +160,7 @@
Future<int> g4() async { return new Future.value(3); }
Future<int> g5() async { return await new Future.value(3); }
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
void check(String name, Asserter<InterfaceType> typeTest) {
FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, name);
@@ -191,7 +196,7 @@
check("g5", _isFutureOfInt);
}
- void test_async_star_method_propagation() {
+ test_async_star_method_propagation() async {
String code = r'''
import "dart:async";
class A {
@@ -202,7 +207,7 @@
Stream<List<int>> g3() async* { yield* new Stream(); }
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
void check(String name, Asserter<InterfaceType> typeTest) {
MethodDeclaration test = AstFinder.getMethodInClass(unit, "A", name);
@@ -219,7 +224,7 @@
check("g3", _isStreamOf([(DartType type) => _isListOf(_isInt)(type)]));
}
- void test_async_star_propagation() {
+ test_async_star_propagation() async {
String code = r'''
import "dart:async";
@@ -229,7 +234,7 @@
Stream<List<int>> g2() async* { yield []; }
Stream<List<int>> g3() async* { yield* new Stream(); }
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
void check(String name, Asserter<InterfaceType> typeTest) {
FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, name);
@@ -246,7 +251,7 @@
check("g3", _isStreamOf([(DartType type) => _isListOf(_isInt)(type)]));
}
- void test_cascadeExpression() {
+ test_cascadeExpression() async {
String code = r'''
class A<T> {
List<T> map(T a, List<T> mapper(T x)) => mapper(a);
@@ -256,7 +261,7 @@
A<int> a = new A()..map(0, (x) => [x]);
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
CascadeExpression fetch(int i) {
@@ -277,14 +282,14 @@
expect(f0.type.normalParameterTypes[0], typeProvider.intType);
}
- void test_constructorInitializer_propagation() {
+ test_constructorInitializer_propagation() async {
String code = r'''
class A {
List<String> x;
A() : this.x = [];
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
ConstructorDeclaration constructor =
AstFinder.getConstructorInClass(unit, "A", null);
ConstructorFieldInitializer assignment = constructor.initializers[0];
@@ -292,14 +297,14 @@
_isListOf(_isString)(exp.staticType);
}
- void test_factoryConstructor_propagation() {
+ test_factoryConstructor_propagation() async {
String code = r'''
class A<T> {
factory A() { return new B(); }
}
class B<S> extends A<S> {}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
ConstructorDeclaration constructor =
AstFinder.getConstructorInClass(unit, "A", null);
@@ -314,20 +319,20 @@
[_isType(elementA.typeParameters[0].type)])(exp.staticType);
}
- void test_fieldDeclaration_propagation() {
+ test_fieldDeclaration_propagation() async {
String code = r'''
class A {
List<String> f0 = ["hello"];
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
VariableDeclaration field = AstFinder.getFieldInClass(unit, "A", "f0");
_isListOf(_isString)(field.initializer.staticType);
}
- void test_functionDeclaration_body_propagation() {
+ test_functionDeclaration_body_propagation() async {
String code = r'''
typedef T Function2<S, T>(S x);
@@ -340,7 +345,7 @@
return (x) => x;
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt);
@@ -367,7 +372,7 @@
expect(type1.normalParameterTypes[0], typeProvider.intType);
}
- void test_functionLiteral_assignment_typedArguments() {
+ test_functionLiteral_assignment_typedArguments() async {
String code = r'''
typedef T Function2<S, T>(S x);
@@ -379,7 +384,7 @@
Function2<int, String> l4 = (int x) {return 3;};
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -396,7 +401,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_assignment_unTypedArguments() {
+ test_functionLiteral_assignment_unTypedArguments() async {
String code = r'''
typedef T Function2<S, T>(S x);
@@ -408,7 +413,7 @@
Function2<int, String> l4 = (x) {return 3;};
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -425,7 +430,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_body_propagation() {
+ test_functionLiteral_body_propagation() async {
String code = r'''
typedef T Function2<S, T>(S x);
@@ -436,7 +441,7 @@
Function2<int, List<String>> l3 = (int x) {return [3];};
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
Expression functionReturnValue(int i) {
@@ -459,7 +464,7 @@
assertListOfString(functionReturnValue(3).staticType);
}
- void test_functionLiteral_functionExpressionInvocation_typedArguments() {
+ test_functionLiteral_functionExpressionInvocation_typedArguments() async {
String code = r'''
class Mapper<F, T> {
T map(T mapper(F x)) => mapper(null);
@@ -473,7 +478,7 @@
(new Mapper<int, String>().map)((int x) {return 3;});
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -490,7 +495,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_functionExpressionInvocation_unTypedArguments() {
+ test_functionLiteral_functionExpressionInvocation_unTypedArguments() async {
String code = r'''
class Mapper<F, T> {
T map(T mapper(F x)) => mapper(null);
@@ -504,7 +509,7 @@
(new Mapper<int, String>().map)((x) {return 3;});
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -521,7 +526,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_functionInvocation_typedArguments() {
+ test_functionLiteral_functionInvocation_typedArguments() async {
String code = r'''
String map(String mapper(int x)) => mapper(null);
@@ -533,7 +538,7 @@
map((int x) {return 3;});
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -550,7 +555,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_functionInvocation_unTypedArguments() {
+ test_functionLiteral_functionInvocation_unTypedArguments() async {
String code = r'''
String map(String mapper(int x)) => mapper(null);
@@ -562,7 +567,7 @@
map((x) {return 3;});
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -579,7 +584,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_methodInvocation_typedArguments() {
+ test_functionLiteral_methodInvocation_typedArguments() async {
String code = r'''
class Mapper<F, T> {
T map(T mapper(F x)) => mapper(null);
@@ -593,7 +598,7 @@
new Mapper<int, String>().map((int x) {return 3;});
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -610,7 +615,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_methodInvocation_unTypedArguments() {
+ test_functionLiteral_methodInvocation_unTypedArguments() async {
String code = r'''
class Mapper<F, T> {
T map(T mapper(F x)) => mapper(null);
@@ -624,7 +629,7 @@
new Mapper<int, String>().map((x) {return 3;});
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -641,7 +646,7 @@
_isFunction2Of(_isInt, _isString)(literal(4));
}
- void test_functionLiteral_unTypedArgument_propagation() {
+ test_functionLiteral_unTypedArgument_propagation() async {
String code = r'''
typedef T Function2<S, T>(S x);
@@ -653,7 +658,7 @@
Function2<String, String> l4 = (x) => x.toLowerCase();
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
Expression functionReturnValue(int i) {
@@ -676,7 +681,7 @@
expect(functionReturnValue(4).staticType, typeProvider.stringType);
}
- void test_inference_hints() {
+ test_inference_hints() async {
Source source = addSource(r'''
void main () {
var x = 3;
@@ -684,11 +689,12 @@
}
''');
resolve2(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_inferredFieldDeclaration_propagation() {
+ test_inferredFieldDeclaration_propagation() async {
// Regression test for https://github.com/dart-lang/sdk/issues/25546
String code = r'''
abstract class A {
@@ -701,7 +707,7 @@
get map => { 43: [] };
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt);
Asserter<InterfaceType> assertMapOfIntToListOfInt =
@@ -725,7 +731,7 @@
assertListOfInt(listLiteralC.staticType);
}
- void test_instanceCreation() {
+ test_instanceCreation() async {
String code = r'''
class A<S, T> {
S x;
@@ -818,7 +824,7 @@
A<int, String> a5 = new F.named(3, "hello", "hello");
}
}''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
Expression rhs(VariableDeclarationStatement stmt) {
VariableDeclaration decl = stmt.variables.variables[0];
@@ -944,7 +950,7 @@
}
}
- void test_listLiteral_nested() {
+ test_listLiteral_nested() async {
String code = r'''
void main () {
List<List<int>> l0 = [[]];
@@ -953,7 +959,7 @@
List<List<int>> l3 = [["hello", 3], []];
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
ListLiteral literal(int i) {
@@ -977,7 +983,7 @@
assertListOfInt(literal(3).elements[0].staticType);
}
- void test_listLiteral_simple() {
+ test_listLiteral_simple() async {
String code = r'''
void main () {
List<int> l0 = [];
@@ -986,7 +992,7 @@
List<int> l3 = ["hello", 3];
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -1004,7 +1010,7 @@
assertListOfInt(literal(3));
}
- void test_listLiteral_simple_const() {
+ test_listLiteral_simple_const() async {
String code = r'''
void main () {
const List<int> c0 = const [];
@@ -1013,7 +1019,7 @@
const List<int> c3 = const ["hello", 3];
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -1031,7 +1037,7 @@
assertListOfInt(literal(3));
}
- void test_listLiteral_simple_disabled() {
+ test_listLiteral_simple_disabled() async {
String code = r'''
void main () {
List<int> l0 = <num>[];
@@ -1040,7 +1046,7 @@
List<int> l3 = <dynamic>["hello", 3];
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -1056,7 +1062,7 @@
_isListOf(_isDynamic)(literal(3));
}
- void test_listLiteral_simple_subtype() {
+ test_listLiteral_simple_subtype() async {
String code = r'''
void main () {
Iterable<int> l0 = [];
@@ -1065,7 +1071,7 @@
Iterable<int> l3 = ["hello", 3];
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -1083,7 +1089,7 @@
assertListOfInt(literal(3));
}
- void test_mapLiteral_nested() {
+ test_mapLiteral_nested() async {
String code = r'''
void main () {
Map<int, List<String>> l0 = {};
@@ -1093,7 +1099,7 @@
Map<int, List<String>> l4 = {3:["hello"], "hello": [3]};
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
MapLiteral literal(int i) {
@@ -1119,7 +1125,7 @@
assertListOfString(literal(4).entries[0].value.staticType);
}
- void test_mapLiteral_simple() {
+ test_mapLiteral_simple() async {
String code = r'''
void main () {
Map<int, String> l0 = {};
@@ -1129,7 +1135,7 @@
Map<int, String> l4 = {3:"hello", "hello": 3};
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -1148,7 +1154,7 @@
assertMapOfIntToString(literal(3));
}
- void test_mapLiteral_simple_disabled() {
+ test_mapLiteral_simple_disabled() async {
String code = r'''
void main () {
Map<int, String> l0 = <int, dynamic>{};
@@ -1157,7 +1163,7 @@
Map<int, String> l3 = <int, dynamic>{3: 3};
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
List<Statement> statements =
AstFinder.getStatementsInTopLevelFunction(unit, "main");
DartType literal(int i) {
@@ -1176,14 +1182,14 @@
assertMapOfIntToDynamic(literal(3));
}
- void test_methodDeclaration_body_propagation() {
+ test_methodDeclaration_body_propagation() async {
String code = r'''
class A {
List<String> m0(int x) => ["hello"];
List<String> m1(int x) {return [3];};
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
Expression methodReturnValue(String methodName) {
MethodDeclaration method =
AstFinder.getMethodInClass(unit, "A", methodName);
@@ -1201,14 +1207,14 @@
assertListOfString(methodReturnValue("m1").staticType);
}
- void test_redirectingConstructor_propagation() {
+ test_redirectingConstructor_propagation() async {
String code = r'''
class A {
A() : this.named([]);
A.named(List<String> x);
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
ConstructorDeclaration constructor =
AstFinder.getConstructorInClass(unit, "A", null);
@@ -1217,7 +1223,7 @@
_isListOf(_isString)(exp.staticType);
}
- void test_superConstructorInvocation_propagation() {
+ test_superConstructorInvocation_propagation() async {
String code = r'''
class B {
B(List<String>);
@@ -1226,7 +1232,7 @@
A() : super([]);
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
ConstructorDeclaration constructor =
AstFinder.getConstructorInClass(unit, "A", null);
@@ -1235,7 +1241,7 @@
_isListOf(_isString)(exp.staticType);
}
- void test_sync_star_method_propagation() {
+ test_sync_star_method_propagation() async {
String code = r'''
import "dart:async";
class A {
@@ -1246,7 +1252,7 @@
Iterable<List<int>> f3() sync* { yield* new List(); }
}
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
void check(String name, Asserter<InterfaceType> typeTest) {
MethodDeclaration test = AstFinder.getMethodInClass(unit, "A", name);
@@ -1263,7 +1269,7 @@
check("f3", _isListOf((DartType type) => _isListOf(_isInt)(type)));
}
- void test_sync_star_propagation() {
+ test_sync_star_propagation() async {
String code = r'''
import "dart:async";
@@ -1273,7 +1279,7 @@
Iterable<List<int>> f2() sync* { yield []; }
Iterable<List<int>> f3() sync* { yield* new List(); }
''';
- CompilationUnit unit = resolveSource(code);
+ CompilationUnit unit = await resolveSource(code);
void check(String name, Asserter<InterfaceType> typeTest) {
FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, name);
@@ -1291,13 +1297,26 @@
}
}
+@reflectiveTest
+class StrongModeDownwardsInferenceTest_Driver
+ extends StrongModeDownwardsInferenceTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ @failingTest
+ @override
+ test_inference_hints() {
+ return super.test_inference_hints();
+ }
+}
+
/**
* Strong mode static analyzer end to end tests
*/
@reflectiveTest
class StrongModeStaticTypeAnalyzer2Test extends StaticTypeAnalyzer2TestShared {
- void fail_genericMethod_tearoff_instantiated() {
- resolveTestUnit(r'''
+ fail_genericMethod_tearoff_instantiated() async {
+ await resolveTestUnit(r'''
class C<E> {
/*=T*/ f/*<T>*/(E e) => null;
static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
@@ -1327,47 +1346,37 @@
expectIdentifierType('paramTearOffInst', "(int) → int");
}
- void objectMethodOnFunctions_helper(String code) {
- resolveTestUnit(code);
- expectIdentifierType('t0', "String");
- expectIdentifierType('t1', "() → String");
- expectIdentifierType('t2', "int");
- expectIdentifierType('t3', "String");
- expectIdentifierType('t4', "() → String");
- expectIdentifierType('t5', "int");
- }
-
void setUp() {
super.setUp();
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.strongMode = true;
- resetWithOptions(options);
+ resetWith(options: options);
}
- void test_dynamicObjectGetter_hashCode() {
+ test_dynamicObjectGetter_hashCode() async {
String code = r'''
main() {
dynamic a = null;
var foo = a.hashCode;
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'int', isNull);
}
- void test_dynamicObjectMethod_toString() {
+ test_dynamicObjectMethod_toString() async {
String code = r'''
main() {
dynamic a = null;
var foo = a.toString();
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'String', isNull);
}
- void test_genericFunction() {
- resolveTestUnit(r'/*=T*/ f/*<T>*/(/*=T*/ x) => null;');
+ test_genericFunction() async {
+ await resolveTestUnit(r'/*=T*/ f/*<T>*/(/*=T*/ x) => null;');
expectFunctionType('f', '<T>(T) → T',
elementTypeParams: '[T]', typeFormals: '[T]');
SimpleIdentifier f = findIdentifier('f');
@@ -1376,14 +1385,14 @@
expect(ft.toString(), '(String) → String');
}
- void test_genericFunction_bounds() {
- resolveTestUnit(r'/*=T*/ f/*<T extends num>*/(/*=T*/ x) => null;');
+ test_genericFunction_bounds() async {
+ await resolveTestUnit(r'/*=T*/ f/*<T extends num>*/(/*=T*/ x) => null;');
expectFunctionType('f', '<T extends num>(T) → T',
elementTypeParams: '[T extends num]', typeFormals: '[T extends num]');
}
- void test_genericFunction_parameter() {
- resolveTestUnit(r'''
+ test_genericFunction_parameter() async {
+ await resolveTestUnit(r'''
void g(/*=T*/ f/*<T>*/(/*=T*/ x)) {}
''');
expectFunctionType('f', '<T>(T) → T',
@@ -1395,8 +1404,8 @@
expect(ft.toString(), '(String) → String');
}
- void test_genericFunction_static() {
- resolveTestUnit(r'''
+ test_genericFunction_static() async {
+ await resolveTestUnit(r'''
class C<E> {
static /*=T*/ f/*<T>*/(/*=T*/ x) => null;
}
@@ -1409,7 +1418,7 @@
expect(ft.toString(), '(String) → String');
}
- void test_genericFunction_typedef() {
+ test_genericFunction_typedef() async {
String code = r'''
typedef T F<T>(T x);
F f0;
@@ -1440,7 +1449,7 @@
}
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
checkBody(String className) {
List<Statement> statements =
@@ -1456,14 +1465,14 @@
checkBody("D");
}
- void test_genericFunction_upwardsAndDownwards() {
+ test_genericFunction_upwardsAndDownwards() async {
// Regression tests for https://github.com/dart-lang/sdk/issues/27151.
- resolveTestUnit(r'List<num> x = [1, 2];');
+ await resolveTestUnit(r'List<num> x = [1, 2];');
expectInitializerType('x', 'List<int>');
}
- void test_genericMethod() {
- resolveTestUnit(r'''
+ test_genericMethod() async {
+ await resolveTestUnit(r'''
class C<E> {
List/*<T>*/ f/*<T>*/(E e) => null;
}
@@ -1484,8 +1493,8 @@
expect('${ft.typeArguments}/${ft.typeParameters}', '[String, int]/[E, T]');
}
- void test_genericMethod_explicitTypeParams() {
- resolveTestUnit(r'''
+ test_genericMethod_explicitTypeParams() async {
+ await resolveTestUnit(r'''
class C<E> {
List/*<T>*/ f/*<T>*/(E e) => null;
}
@@ -1504,8 +1513,8 @@
typeProvider.listType.instantiate([typeProvider.intType]));
}
- void test_genericMethod_functionExpressionInvocation_explicit() {
- resolveTestUnit(r'''
+ test_genericMethod_functionExpressionInvocation_explicit() async {
+ await resolveTestUnit(r'''
class C<E> {
/*=T*/ f/*<T>*/(/*=T*/ e) => null;
static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
@@ -1538,8 +1547,8 @@
expectIdentifierType('lambdaCall', "int");
}
- void test_genericMethod_functionExpressionInvocation_inferred() {
- resolveTestUnit(r'''
+ test_genericMethod_functionExpressionInvocation_inferred() async {
+ await resolveTestUnit(r'''
class C<E> {
/*=T*/ f/*<T>*/(/*=T*/ e) => null;
static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
@@ -1572,8 +1581,8 @@
expectIdentifierType('lambdaCall', "int");
}
- void test_genericMethod_functionInvocation_explicit() {
- resolveTestUnit(r'''
+ test_genericMethod_functionInvocation_explicit() async {
+ await resolveTestUnit(r'''
class C<E> {
/*=T*/ f/*<T>*/(/*=T*/ e) => null;
static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
@@ -1603,8 +1612,8 @@
expectIdentifierType('paramCall', "int");
}
- void test_genericMethod_functionInvocation_inferred() {
- resolveTestUnit(r'''
+ test_genericMethod_functionInvocation_inferred() async {
+ await resolveTestUnit(r'''
class C<E> {
/*=T*/ f/*<T>*/(/*=T*/ e) => null;
static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
@@ -1634,8 +1643,8 @@
expectIdentifierType('paramCall', "int");
}
- void test_genericMethod_functionTypedParameter() {
- resolveTestUnit(r'''
+ test_genericMethod_functionTypedParameter() async {
+ await resolveTestUnit(r'''
class C<E> {
List/*<T>*/ f/*<T>*/(/*=T*/ f(E e)) => null;
}
@@ -1656,11 +1665,11 @@
expect(ft.toString(), '((String) → int) → List<int>');
}
- void test_genericMethod_implicitDynamic() {
+ test_genericMethod_implicitDynamic() async {
// Regression test for:
// https://github.com/dart-lang/sdk/issues/25100#issuecomment-162047588
// These should not cause any hints or warnings.
- resolveTestUnit(r'''
+ await resolveTestUnit(r'''
class List<E> {
/*=T*/ map/*<T>*/(/*=T*/ f(E e)) => null;
}
@@ -1678,62 +1687,62 @@
expect(m2.staticInvokeType.toString(), '((dynamic) → int) → int');
}
- void test_genericMethod_max_doubleDouble() {
+ test_genericMethod_max_doubleDouble() async {
String code = r'''
import 'dart:math';
main() {
var foo = max(1.0, 2.0);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'double', isNull);
}
- void test_genericMethod_max_doubleDouble_prefixed() {
+ test_genericMethod_max_doubleDouble_prefixed() async {
String code = r'''
import 'dart:math' as math;
main() {
var foo = math.max(1.0, 2.0);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'double', isNull);
}
- void test_genericMethod_max_doubleInt() {
+ test_genericMethod_max_doubleInt() async {
String code = r'''
import 'dart:math';
main() {
var foo = max(1.0, 2);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'num', isNull);
}
- void test_genericMethod_max_intDouble() {
+ test_genericMethod_max_intDouble() async {
String code = r'''
import 'dart:math';
main() {
var foo = max(1, 2.0);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'num', isNull);
}
- void test_genericMethod_max_intInt() {
+ test_genericMethod_max_intInt() async {
String code = r'''
import 'dart:math';
main() {
var foo = max(1, 2);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'int', isNull);
}
- void test_genericMethod_nestedBound() {
+ test_genericMethod_nestedBound() async {
String code = r'''
class Foo<T extends num> {
void method/*<U extends T>*/(dynamic/*=U*/ u) {
@@ -1742,11 +1751,11 @@
}
''';
// Just validate that there is no warning on the call to `.abs()`.
- resolveTestUnit(code);
+ await resolveTestUnit(code);
}
- void test_genericMethod_nestedCapture() {
- resolveTestUnit(r'''
+ test_genericMethod_nestedCapture() async {
+ await resolveTestUnit(r'''
class C<T> {
/*=T*/ f/*<S>*/(/*=S*/ x) {
new C<S>().f/*<int>*/(3);
@@ -1763,8 +1772,8 @@
expectIdentifierType('f;', '<Sâ‚€>(Sâ‚€) → S');
}
- void test_genericMethod_nestedFunctions() {
- resolveTestUnit(r'''
+ test_genericMethod_nestedFunctions() async {
+ await resolveTestUnit(r'''
/*=S*/ f/*<S>*/(/*=S*/ x) {
g/*<S>*/(/*=S*/ x) => f;
return null;
@@ -1774,8 +1783,8 @@
expectIdentifierType('g', '<S>(S) → <S>(S) → S');
}
- void test_genericMethod_override() {
- resolveTestUnit(r'''
+ test_genericMethod_override() async {
+ await resolveTestUnit(r'''
class C {
/*=T*/ f/*<T>*/(/*=T*/ x) => null;
}
@@ -1792,8 +1801,8 @@
expect(ft.toString(), '(String) → String');
}
- void test_genericMethod_override_bounds() {
- resolveTestUnit(r'''
+ test_genericMethod_override_bounds() async {
+ await resolveTestUnit(r'''
class A {}
class B extends A {}
class C {
@@ -1805,7 +1814,7 @@
''');
}
- void test_genericMethod_override_invalidReturnType() {
+ test_genericMethod_override_invalidReturnType() async {
Source source = addSource(r'''
class C {
Iterable/*<T>*/ f/*<T>*/(/*=T*/ x) => null;
@@ -1813,11 +1822,12 @@
class D extends C {
String f/*<S>*/(/*=S*/ x) => null;
}''');
+ await computeAnalysisResult(source);
assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]);
verify([source]);
}
- void test_genericMethod_override_invalidTypeParamBounds() {
+ test_genericMethod_override_invalidTypeParamBounds() async {
Source source = addSource(r'''
class A {}
class B extends A {}
@@ -1827,11 +1837,12 @@
class D extends C {
/*=T*/ f/*<T extends B>*/(/*=T*/ x) => null;
}''');
+ await computeAnalysisResult(source);
assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]);
verify([source]);
}
- void test_genericMethod_override_invalidTypeParamCount() {
+ test_genericMethod_override_invalidTypeParamCount() async {
Source source = addSource(r'''
class C {
/*=T*/ f/*<T>*/(/*=T*/ x) => null;
@@ -1839,11 +1850,12 @@
class D extends C {
/*=S*/ f/*<T, S>*/(/*=T*/ x) => null;
}''');
+ await computeAnalysisResult(source);
assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]);
verify([source]);
}
- void test_genericMethod_propagatedType_promotion() {
+ test_genericMethod_propagatedType_promotion() async {
// Regression test for:
// https://github.com/dart-lang/sdk/issues/25340
@@ -1851,7 +1863,7 @@
// example won't work, as we now compute a static type and therefore discard
// the propagated type. So a new test was created that doesn't run under
// strong mode.
- resolveTestUnit(r'''
+ await resolveTestUnit(r'''
abstract class Iter {
List/*<S>*/ map/*<S>*/(/*=S*/ f(x));
}
@@ -1865,8 +1877,8 @@
expectIdentifierType('y = ', 'List<C>', isNull);
}
- void test_genericMethod_tearoff() {
- resolveTestUnit(r'''
+ test_genericMethod_tearoff() async {
+ await resolveTestUnit(r'''
class C<E> {
/*=T*/ f/*<T>*/(E e) => null;
static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
@@ -1896,7 +1908,7 @@
expectIdentifierType('paramTearOff', "<T>(T) → T");
}
- void test_genericMethod_then() {
+ test_genericMethod_then() async {
String code = r'''
import 'dart:async';
String toString(int x) => x.toString();
@@ -1905,11 +1917,11 @@
var foo = bar.then(toString);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'Future<String>', isNull);
}
- void test_genericMethod_then_prefixed() {
+ test_genericMethod_then_prefixed() async {
String code = r'''
import 'dart:async' as async;
String toString(int x) => x.toString();
@@ -1918,11 +1930,11 @@
var foo = bar.then(toString);
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'Future<String>', isNull);
}
- void test_genericMethod_then_propagatedType() {
+ test_genericMethod_then_propagatedType() async {
// Regression test for https://github.com/dart-lang/sdk/issues/25482.
String code = r'''
import 'dart:async';
@@ -1932,11 +1944,11 @@
}
''';
// This should produce no hints or warnings.
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'Future<String>', isNull);
}
- void test_implicitBounds() {
+ test_implicitBounds() async {
String code = r'''
class A<T> {}
@@ -1954,7 +1966,7 @@
var cc = new C();
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectIdentifierType('ai', "A<dynamic>");
expectIdentifierType('bi', "B<num>");
expectIdentifierType('ci', "C<int, B<int>, B<dynamic>>");
@@ -1963,7 +1975,7 @@
expectIdentifierType('cc', "C<int, B<int>, B<dynamic>>");
}
- void test_objectMethodOnFunctions_Anonymous() {
+ test_objectMethodOnFunctions_Anonymous() async {
String code = r'''
void main() {
var f = (x) => 3;
@@ -1987,10 +1999,10 @@
(f)..toString;
(f)..hashCode;
}''';
- objectMethodOnFunctions_helper(code);
+ await _objectMethodOnFunctions_helper2(code);
}
- void test_objectMethodOnFunctions_Function() {
+ test_objectMethodOnFunctions_Function() async {
String code = r'''
void main() {
Function f;
@@ -2014,10 +2026,10 @@
(f)..toString;
(f)..hashCode;
}''';
- objectMethodOnFunctions_helper(code);
+ await _objectMethodOnFunctions_helper2(code);
}
- void test_objectMethodOnFunctions_Static() {
+ test_objectMethodOnFunctions_Static() async {
String code = r'''
int f(int x) => null;
void main() {
@@ -2041,10 +2053,10 @@
(f)..toString;
(f)..hashCode;
}''';
- objectMethodOnFunctions_helper(code);
+ await _objectMethodOnFunctions_helper2(code);
}
- void test_objectMethodOnFunctions_Typedef() {
+ test_objectMethodOnFunctions_Typedef() async {
String code = r'''
typedef bool Predicate<T>(T object);
@@ -2070,17 +2082,17 @@
(f)..toString;
(f)..hashCode;
}''';
- objectMethodOnFunctions_helper(code);
+ await _objectMethodOnFunctions_helper2(code);
}
- void test_setterWithDynamicTypeIsError() {
+ test_setterWithDynamicTypeIsError() async {
Source source = addSource(r'''
class A {
dynamic set f(String s) => null;
}
dynamic set g(int x) => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.NON_VOID_RETURN_FOR_SETTER,
StaticWarningCode.NON_VOID_RETURN_FOR_SETTER
@@ -2088,7 +2100,7 @@
verify([source]);
}
- void test_setterWithExplicitVoidType_returningVoid() {
+ test_setterWithExplicitVoidType_returningVoid() async {
Source source = addSource(r'''
void returnsVoid() {}
class A {
@@ -2096,12 +2108,12 @@
}
void set g(int x) => returnsVoid();
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_setterWithNoVoidType() {
+ test_setterWithNoVoidType() async {
Source source = addSource(r'''
class A {
set f(String s) {
@@ -2110,14 +2122,14 @@
}
set g(int x) => 42;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticTypeWarningCode.RETURN_OF_INVALID_TYPE,
]);
verify([source]);
}
- void test_setterWithNoVoidType_returningVoid() {
+ test_setterWithNoVoidType_returningVoid() async {
Source source = addSource(r'''
void returnsVoid() {}
class A {
@@ -2125,19 +2137,19 @@
}
set g(int x) => returnsVoid();
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
- void test_setterWithOtherTypeIsError() {
+ test_setterWithOtherTypeIsError() async {
Source source = addSource(r'''
class A {
String set f(String s) => null;
}
Object set g(x) => null;
''');
- computeLibrarySourceErrors(source);
+ await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.NON_VOID_RETURN_FOR_SETTER,
StaticWarningCode.NON_VOID_RETURN_FOR_SETTER
@@ -2145,25 +2157,78 @@
verify([source]);
}
- void test_ternaryOperator_null_left() {
+ test_ternaryOperator_null_left() async {
String code = r'''
main() {
var foo = (true) ? null : 3;
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'int', isNull);
}
- void test_ternaryOperator_null_right() {
+ test_ternaryOperator_null_right() async {
String code = r'''
main() {
var foo = (true) ? 3 : null;
}
''';
- resolveTestUnit(code);
+ await resolveTestUnit(code);
expectInitializerType('foo', 'int', isNull);
}
+
+ Future<Null> _objectMethodOnFunctions_helper2(String code) async {
+ await resolveTestUnit(code);
+ expectIdentifierType('t0', "String");
+ expectIdentifierType('t1', "() → String");
+ expectIdentifierType('t2', "int");
+ expectIdentifierType('t3', "String");
+ expectIdentifierType('t4', "() → String");
+ expectIdentifierType('t5', "int");
+ }
+}
+
+@reflectiveTest
+class StrongModeStaticTypeAnalyzer2Test_Driver
+ extends StrongModeStaticTypeAnalyzer2Test {
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ @failingTest
+ @override
+ test_genericFunction_parameter() {
+ return super.test_genericFunction_parameter();
+ }
+
+ @failingTest
+ @override
+ test_genericMethod_functionExpressionInvocation_explicit() {
+ return super.test_genericMethod_functionExpressionInvocation_explicit();
+ }
+
+ @failingTest
+ @override
+ test_genericMethod_functionExpressionInvocation_inferred() {
+ return super.test_genericMethod_functionExpressionInvocation_inferred();
+ }
+
+ @failingTest
+ @override
+ test_genericMethod_functionInvocation_explicit() {
+ return super.test_genericMethod_functionInvocation_explicit();
+ }
+
+ @failingTest
+ @override
+ test_genericMethod_functionInvocation_inferred() {
+ return super.test_genericMethod_functionInvocation_inferred();
+ }
+
+ @failingTest
+ @override
+ test_genericMethod_tearoff() {
+ return super.test_genericMethod_tearoff();
+ }
}
@reflectiveTest
@@ -2173,10 +2238,10 @@
super.setUp();
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.strongMode = true;
- resetWithOptions(options);
+ resetWith(options: options);
}
- void test_foreachInference_dynamic_disabled() {
+ test_foreachInference_dynamic_disabled() async {
String code = r'''
main() {
var list = <int>[];
@@ -2184,11 +2249,11 @@
v; // marker
}
}''';
- assertPropagatedIterationType(code, typeProvider.dynamicType, null);
- assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
+ await assertPropagatedIterationType(code, typeProvider.dynamicType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
}
- void test_foreachInference_reusedVar_disabled() {
+ test_foreachInference_reusedVar_disabled() async {
String code = r'''
main() {
var list = <int>[];
@@ -2197,11 +2262,11 @@
v; // marker
}
}''';
- assertPropagatedIterationType(code, typeProvider.dynamicType, null);
- assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
+ await assertPropagatedIterationType(code, typeProvider.dynamicType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
}
- void test_foreachInference_var() {
+ test_foreachInference_var() async {
String code = r'''
main() {
var list = <int>[];
@@ -2209,11 +2274,11 @@
v; // marker
}
}''';
- assertPropagatedIterationType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedIterationType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_foreachInference_var_iterable() {
+ test_foreachInference_var_iterable() async {
String code = r'''
main() {
Iterable<int> list = <int>[];
@@ -2221,11 +2286,11 @@
v; // marker
}
}''';
- assertPropagatedIterationType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedIterationType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_foreachInference_var_stream() {
+ test_foreachInference_var_stream() async {
String code = r'''
import 'dart:async';
main() async {
@@ -2234,52 +2299,52 @@
v; // marker
}
}''';
- assertPropagatedIterationType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedIterationType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_bottom_disabled() {
+ test_localVariableInference_bottom_disabled() async {
String code = r'''
main() {
var v = null;
v; // marker
}''';
- assertPropagatedAssignedType(code, typeProvider.dynamicType, null);
- assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
+ await assertPropagatedAssignedType(code, typeProvider.dynamicType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
}
- void test_localVariableInference_constant() {
+ test_localVariableInference_constant() async {
String code = r'''
main() {
var v = 3;
v; // marker
}''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_declaredType_disabled() {
+ test_localVariableInference_declaredType_disabled() async {
String code = r'''
main() {
dynamic v = 3;
v; // marker
}''';
- assertPropagatedAssignedType(code, typeProvider.dynamicType, null);
- assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
+ await assertPropagatedAssignedType(code, typeProvider.dynamicType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
}
- void test_localVariableInference_noInitializer_disabled() {
+ test_localVariableInference_noInitializer_disabled() async {
String code = r'''
main() {
var v;
v = 3;
v; // marker
}''';
- assertPropagatedAssignedType(code, typeProvider.dynamicType, null);
- assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
+ await assertPropagatedAssignedType(code, typeProvider.dynamicType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.dynamicType, null);
}
- void test_localVariableInference_transitive_field_inferred_lexical() {
+ test_localVariableInference_transitive_field_inferred_lexical() async {
String code = r'''
class A {
final x = 3;
@@ -2291,11 +2356,11 @@
main() {
}
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_field_inferred_reversed() {
+ test_localVariableInference_transitive_field_inferred_reversed() async {
String code = r'''
class A {
f() {
@@ -2307,11 +2372,11 @@
main() {
}
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_field_lexical() {
+ test_localVariableInference_transitive_field_lexical() async {
String code = r'''
class A {
int x = 3;
@@ -2323,11 +2388,11 @@
main() {
}
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_field_reversed() {
+ test_localVariableInference_transitive_field_reversed() async {
String code = r'''
class A {
f() {
@@ -2339,33 +2404,33 @@
main() {
}
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_list_local() {
+ test_localVariableInference_transitive_list_local() async {
String code = r'''
main() {
var x = <int>[3];
var v = x[0];
v; // marker
}''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_local() {
+ test_localVariableInference_transitive_local() async {
String code = r'''
main() {
var x = 3;
var v = x;
v; // marker
}''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_toplevel_inferred_lexical() {
+ test_localVariableInference_transitive_toplevel_inferred_lexical() async {
String code = r'''
final x = 3;
main() {
@@ -2373,11 +2438,11 @@
v; // marker
}
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_toplevel_inferred_reversed() {
+ test_localVariableInference_transitive_toplevel_inferred_reversed() async {
String code = r'''
main() {
var v = x;
@@ -2385,11 +2450,11 @@
}
final x = 3;
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_toplevel_lexical() {
+ test_localVariableInference_transitive_toplevel_lexical() async {
String code = r'''
int x = 3;
main() {
@@ -2397,11 +2462,11 @@
v; // marker
}
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
- void test_localVariableInference_transitive_toplevel_reversed() {
+ test_localVariableInference_transitive_toplevel_reversed() async {
String code = r'''
main() {
var v = x;
@@ -2409,7 +2474,14 @@
}
int x = 3;
''';
- assertPropagatedAssignedType(code, typeProvider.intType, null);
- assertTypeOfMarkedExpression(code, typeProvider.intType, null);
+ await assertPropagatedAssignedType(code, typeProvider.intType, null);
+ await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
}
}
+
+@reflectiveTest
+class StrongModeTypePropagationTest_Driver
+ extends StrongModeTypePropagationTest {
+ @override
+ bool get enableNewAnalysisDriver => true;
+}
diff --git a/pkg/analyzer/test/generated/test_all.dart b/pkg/analyzer/test/generated/test_all.dart
index 37c9268..4bac8af 100644
--- a/pkg/analyzer/test/generated/test_all.dart
+++ b/pkg/analyzer/test/generated/test_all.dart
@@ -10,17 +10,21 @@
import 'bazel_test.dart' as bazel_test;
import 'checked_mode_compile_time_error_code_test.dart'
as checked_mode_compile_time_error_code_test;
+import 'compile_time_error_code_driver_test.dart'
+ as compile_time_error_code_driver_test;
import 'compile_time_error_code_test.dart' as compile_time_error_code_test;
import 'constant_test.dart' as constant_test;
import 'declaration_resolver_test.dart' as declaration_resolver_test;
import 'element_resolver_test.dart' as element_resolver_test;
import 'engine_test.dart' as engine_test;
import 'error_suppression_test.dart' as error_suppression_test;
+import 'hint_code_driver_test.dart' as hint_code_driver_test;
import 'hint_code_test.dart' as hint_code_test;
import 'incremental_resolver_test.dart' as incremental_resolver_test;
import 'inheritance_manager_test.dart' as inheritance_manager_test;
import 'java_core_test.dart' as java_core_test;
import 'java_io_test.dart' as java_io_test;
+import 'non_error_resolver_driver_test.dart' as non_error_resolver_driver_test;
import 'non_error_resolver_test.dart' as non_error_resolver_test;
import 'non_hint_code_test.dart' as non_hint_code_test;
import 'parser_test.dart' as parser_test;
@@ -31,6 +35,8 @@
import 'source_factory_test.dart' as source_factory_test;
import 'static_type_analyzer_test.dart' as static_type_analyzer_test;
import 'static_type_warning_code_test.dart' as static_type_warning_code_test;
+import 'static_warning_code_driver_test.dart'
+ as static_warning_code_driver_test;
import 'static_warning_code_test.dart' as static_warning_code_test;
import 'strong_mode_test.dart' as strong_mode_test;
import 'type_system_test.dart' as type_system_test;
@@ -43,17 +49,20 @@
all_the_rest.main();
bazel_test.main();
checked_mode_compile_time_error_code_test.main();
+ compile_time_error_code_driver_test.main();
compile_time_error_code_test.main();
constant_test.main();
declaration_resolver_test.main();
element_resolver_test.main();
engine_test.main();
error_suppression_test.main();
+ hint_code_driver_test.main();
hint_code_test.main();
incremental_resolver_test.main();
inheritance_manager_test.main();
java_core_test.main();
java_io_test.main();
+ non_error_resolver_driver_test.main();
non_error_resolver_test.main();
non_hint_code_test.main();
parser_test.main();
@@ -64,6 +73,7 @@
source_factory_test.main();
static_type_analyzer_test.main();
static_type_warning_code_test.main();
+ static_warning_code_driver_test.main();
static_warning_code_test.main();
strong_mode_test.main();
type_system_test.main();
diff --git a/pkg/analyzer/test/generated/utilities_test.dart b/pkg/analyzer/test/generated/utilities_test.dart
index 050a6c1..51c4a560 100644
--- a/pkg/analyzer/test/generated/utilities_test.dart
+++ b/pkg/analyzer/test/generated/utilities_test.dart
@@ -1631,9 +1631,9 @@
}
class Getter_NodeReplacerTest_test_asExpression
- implements NodeReplacerTest_Getter<AsExpression, TypeName> {
+ implements NodeReplacerTest_Getter<AsExpression, TypeAnnotation> {
@override
- TypeName get(AsExpression node) => node.type;
+ TypeAnnotation get(AsExpression node) => node.type;
}
class Getter_NodeReplacerTest_test_asExpression_2
@@ -1715,9 +1715,9 @@
}
class Getter_NodeReplacerTest_test_catchClause_3
- implements NodeReplacerTest_Getter<CatchClause, TypeName> {
+ implements NodeReplacerTest_Getter<CatchClause, TypeAnnotation> {
@override
- TypeName get(CatchClause node) => node.exceptionType;
+ TypeAnnotation get(CatchClause node) => node.exceptionType;
}
class Getter_NodeReplacerTest_test_classDeclaration
@@ -1883,9 +1883,9 @@
}
class Getter_NodeReplacerTest_test_declaredIdentifier
- implements NodeReplacerTest_Getter<DeclaredIdentifier, TypeName> {
+ implements NodeReplacerTest_Getter<DeclaredIdentifier, TypeAnnotation> {
@override
- TypeName get(DeclaredIdentifier node) => node.type;
+ TypeAnnotation get(DeclaredIdentifier node) => node.type;
}
class Getter_NodeReplacerTest_test_declaredIdentifier_2
@@ -1965,9 +1965,9 @@
}
class Getter_NodeReplacerTest_test_fieldFormalParameter_2
- implements NodeReplacerTest_Getter<FieldFormalParameter, TypeName> {
+ implements NodeReplacerTest_Getter<FieldFormalParameter, TypeAnnotation> {
@override
- TypeName get(FieldFormalParameter node) => node.type;
+ TypeAnnotation get(FieldFormalParameter node) => node.type;
}
class Getter_NodeReplacerTest_test_forEachStatement_withIdentifier
@@ -2043,9 +2043,9 @@
}
class Getter_NodeReplacerTest_test_functionDeclaration
- implements NodeReplacerTest_Getter<FunctionDeclaration, TypeName> {
+ implements NodeReplacerTest_Getter<FunctionDeclaration, TypeAnnotation> {
@override
- TypeName get(FunctionDeclaration node) => node.returnType;
+ TypeAnnotation get(FunctionDeclaration node) => node.returnType;
}
class Getter_NodeReplacerTest_test_functionDeclaration_2
@@ -2110,9 +2110,9 @@
}
class Getter_NodeReplacerTest_test_functionTypeAlias_3
- implements NodeReplacerTest_Getter<FunctionTypeAlias, TypeName> {
+ implements NodeReplacerTest_Getter<FunctionTypeAlias, TypeAnnotation> {
@override
- TypeName get(FunctionTypeAlias node) => node.returnType;
+ TypeAnnotation get(FunctionTypeAlias node) => node.returnType;
}
class Getter_NodeReplacerTest_test_functionTypeAlias_4
@@ -2122,9 +2122,10 @@
}
class Getter_NodeReplacerTest_test_functionTypedFormalParameter
- implements NodeReplacerTest_Getter<FunctionTypedFormalParameter, TypeName> {
+ implements
+ NodeReplacerTest_Getter<FunctionTypedFormalParameter, TypeAnnotation> {
@override
- TypeName get(FunctionTypedFormalParameter node) => node.returnType;
+ TypeAnnotation get(FunctionTypedFormalParameter node) => node.returnType;
}
class Getter_NodeReplacerTest_test_functionTypedFormalParameter_2
@@ -2198,9 +2199,9 @@
}
class Getter_NodeReplacerTest_test_isExpression_2
- implements NodeReplacerTest_Getter<IsExpression, TypeName> {
+ implements NodeReplacerTest_Getter<IsExpression, TypeAnnotation> {
@override
- TypeName get(IsExpression node) => node.type;
+ TypeAnnotation get(IsExpression node) => node.type;
}
class Getter_NodeReplacerTest_test_label
@@ -2234,9 +2235,9 @@
}
class Getter_NodeReplacerTest_test_methodDeclaration
- implements NodeReplacerTest_Getter<MethodDeclaration, TypeName> {
+ implements NodeReplacerTest_Getter<MethodDeclaration, TypeAnnotation> {
@override
- TypeName get(MethodDeclaration node) => node.returnType;
+ TypeAnnotation get(MethodDeclaration node) => node.returnType;
}
class Getter_NodeReplacerTest_test_methodDeclaration_2
@@ -2371,9 +2372,9 @@
}
class Getter_NodeReplacerTest_test_simpleFormalParameter
- implements NodeReplacerTest_Getter<SimpleFormalParameter, TypeName> {
+ implements NodeReplacerTest_Getter<SimpleFormalParameter, TypeAnnotation> {
@override
- TypeName get(SimpleFormalParameter node) => node.type;
+ TypeAnnotation get(SimpleFormalParameter node) => node.type;
}
class Getter_NodeReplacerTest_test_superConstructorInvocation
@@ -2442,9 +2443,9 @@
}
class Getter_NodeReplacerTest_test_typeParameter
- implements NodeReplacerTest_Getter<TypeParameter, TypeName> {
+ implements NodeReplacerTest_Getter<TypeParameter, TypeAnnotation> {
@override
- TypeName get(TypeParameter node) => node.bound;
+ TypeAnnotation get(TypeParameter node) => node.bound;
}
class Getter_NodeReplacerTest_test_typeParameter_2
@@ -2466,9 +2467,10 @@
}
class Getter_NodeReplacerTest_test_variableDeclarationList
- implements NodeReplacerTest_Getter<VariableDeclarationList, TypeName> {
+ implements
+ NodeReplacerTest_Getter<VariableDeclarationList, TypeAnnotation> {
@override
- TypeName get(VariableDeclarationList node) => node.type;
+ TypeAnnotation get(VariableDeclarationList node) => node.type;
}
class Getter_NodeReplacerTest_test_variableDeclarationStatement
@@ -2764,11 +2766,11 @@
}
class ListGetter_NodeReplacerTest_test_typeArgumentList
- extends NodeReplacerTest_ListGetter<TypeArgumentList, TypeName> {
+ extends NodeReplacerTest_ListGetter<TypeArgumentList, TypeAnnotation> {
ListGetter_NodeReplacerTest_test_typeArgumentList(int arg0) : super(arg0);
@override
- NodeList<TypeName> getList(TypeArgumentList node) => node.arguments;
+ NodeList<TypeAnnotation> getList(TypeArgumentList node) => node.arguments;
}
class ListGetter_NodeReplacerTest_test_typeParameterList
diff --git a/pkg/analyzer/test/src/dart/analysis/base.dart b/pkg/analyzer/test/src/dart/analysis/base.dart
index bb716cf..341d4f6 100644
--- a/pkg/analyzer/test/src/dart/analysis/base.dart
+++ b/pkg/analyzer/test/src/dart/analysis/base.dart
@@ -17,7 +17,7 @@
import 'package:analyzer/src/generated/source.dart';
import 'package:test/test.dart';
-import '../../context/mock_sdk.dart';
+import 'physical_sdk.dart';
/**
* Finds an [Element] with the given [name].
@@ -44,8 +44,6 @@
typedef void _ElementVisitorFunction(Element element);
class BaseAnalysisDriverTest {
- static final MockSdk sdk = new MockSdk();
-
final MemoryResourceProvider provider = new MemoryResourceProvider();
final ByteStore byteStore = new MemoryByteStore();
final FileContentOverlay contentOverlay = new FileContentOverlay();
@@ -102,7 +100,6 @@
}
void setUp() {
- new MockSdk();
testProject = _p('/test/lib');
testFile = _p('/test/lib/test.dart');
logger = new PerformanceLog(logBuffer);
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 05b7cb2..cc79745 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -28,8 +28,8 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../context/mock_sdk.dart';
import 'base.dart';
+import 'physical_sdk.dart';
main() {
defineReflectiveSuite(() {
@@ -54,8 +54,6 @@
@reflectiveTest
class AnalysisDriverSchedulerTest {
- static final MockSdk sdk = new MockSdk();
-
final MemoryResourceProvider provider = new MemoryResourceProvider();
final ByteStore byteStore = new MemoryByteStore();
final FileContentOverlay contentOverlay = new FileContentOverlay();
diff --git a/pkg/analyzer/test/src/dart/analysis/physical_sdk.dart b/pkg/analyzer/test/src/dart/analysis/physical_sdk.dart
new file mode 100644
index 0000000..665c80a
--- /dev/null
+++ b/pkg/analyzer/test/src/dart/analysis/physical_sdk.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2016, 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/file_system/physical_file_system.dart';
+import 'package:analyzer/src/dart/sdk/sdk.dart';
+import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
+import 'package:analyzer/src/generated/sdk.dart';
+
+final DartSdk sdk = new FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE,
+ FolderBasedDartSdk.defaultSdkDirectory(PhysicalResourceProvider.INSTANCE))
+ ..useSummary = true;
+
+final DartSdk strongSdk = new FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE,
+ FolderBasedDartSdk.defaultSdkDirectory(PhysicalResourceProvider.INSTANCE))
+ ..analysisOptions = (new AnalysisOptionsImpl()..strongMode = true)
+ ..useSummary = true;
diff --git a/pkg/analyzer/test/src/dart/ast/utilities_test.dart b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
index 8ccaa8a..f4016bc 100644
--- a/pkg/analyzer/test/src/dart/ast/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
@@ -196,23 +196,13 @@
expect(value, true);
}
- void test_binary_plus_string() {
- Object value = _getConstantValue("'hello ' + 'world'");
- expect(value, 'hello world');
- }
-
void test_binary_plus_double() {
Object value = _getConstantValue("2.3 + 3.2");
expect(value, 2.3 + 3.2);
}
- void test_binary_plus_integer() {
- Object value = _getConstantValue("2 + 3");
- expect(value, 5);
- }
-
- void test_binary_plus_string_int() {
- Object value = _getConstantValue("5 + 'world'");
+ void test_binary_plus_double_string() {
+ Object value = _getConstantValue("'world' + 5.5");
expect(value, ConstantEvaluator.NOT_A_CONSTANT);
}
@@ -221,9 +211,14 @@
expect(value, ConstantEvaluator.NOT_A_CONSTANT);
}
- void test_binary_plus_double_string() {
- Object value = _getConstantValue("'world' + 5.5");
- expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ void test_binary_plus_integer() {
+ Object value = _getConstantValue("2 + 3");
+ expect(value, 5);
+ }
+
+ void test_binary_plus_string() {
+ Object value = _getConstantValue("'hello ' + 'world'");
+ expect(value, 'hello world');
}
void test_binary_plus_string_double() {
@@ -231,6 +226,11 @@
expect(value, ConstantEvaluator.NOT_A_CONSTANT);
}
+ void test_binary_plus_string_int() {
+ Object value = _getConstantValue("5 + 'world'");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
void test_binary_remainder_double() {
Object value = _getConstantValue("3.2 % 2.3");
expect(value, 3.2 % 2.3);
@@ -372,7 +372,7 @@
CompilationUnit unit = ParserTestCase.parseCompilationUnit(code);
TopLevelVariableDeclaration declaration = unit.declarations[0];
VariableDeclarationList variableList = declaration.variables;
- Identifier typeName = variableList.type.name;
+ Identifier typeName = (variableList.type as TypeName).name;
SimpleIdentifier varName = variableList.variables[0].name;
expect(new NodeLocator2(0).searchWithin(unit), same(unit));
expect(new NodeLocator2(1).searchWithin(unit), same(typeName));
@@ -393,7 +393,7 @@
CompilationUnit unit = ParserTestCase.parseCompilationUnit(code);
TopLevelVariableDeclaration declaration = unit.declarations[0];
VariableDeclarationList variableList = declaration.variables;
- Identifier typeName = variableList.type.name;
+ Identifier typeName = (variableList.type as TypeName).name;
SimpleIdentifier varName = variableList.variables[0].name;
expect(new NodeLocator2(-1, 2).searchWithin(unit), isNull);
expect(new NodeLocator2(0, 2).searchWithin(unit), same(unit));
@@ -696,9 +696,9 @@
.functionExpressionInvocation(AstTestFactory.identifier3("f"));
ClassElement elementT = ElementFactory.classElement2('T');
fromNode.typeArguments = AstTestFactory
- .typeArgumentList(<TypeName>[AstTestFactory.typeName(elementT)]);
+ .typeArgumentList(<TypeAnnotation>[AstTestFactory.typeName(elementT)]);
toNode.typeArguments = AstTestFactory
- .typeArgumentList(<TypeName>[AstTestFactory.typeName4('T')]);
+ .typeArgumentList(<TypeAnnotation>[AstTestFactory.typeName4('T')]);
_copyAndVerifyInvocation(fromNode, toNode);
@@ -831,9 +831,9 @@
MethodInvocation toNode = AstTestFactory.methodInvocation2("m");
ClassElement elementT = ElementFactory.classElement2('T');
fromNode.typeArguments = AstTestFactory
- .typeArgumentList(<TypeName>[AstTestFactory.typeName(elementT)]);
+ .typeArgumentList(<TypeAnnotation>[AstTestFactory.typeName(elementT)]);
toNode.typeArguments = AstTestFactory
- .typeArgumentList(<TypeName>[AstTestFactory.typeName4('T')]);
+ .typeArgumentList(<TypeAnnotation>[AstTestFactory.typeName4('T')]);
_copyAndVerifyInvocation(fromNode, toNode);
}
@@ -1130,12 +1130,12 @@
expect(toNode.staticType, same(staticType));
expect(toNode.propagatedInvokeType, same(propagatedInvokeType));
expect(toNode.staticInvokeType, same(staticInvokeType));
- List<TypeName> fromTypeArguments = toNode.typeArguments.arguments;
- List<TypeName> toTypeArguments = fromNode.typeArguments.arguments;
+ List<TypeAnnotation> fromTypeArguments = toNode.typeArguments.arguments;
+ List<TypeAnnotation> toTypeArguments = fromNode.typeArguments.arguments;
if (fromTypeArguments != null) {
for (int i = 0; i < fromTypeArguments.length; i++) {
- TypeName toArgument = fromTypeArguments[i];
- TypeName fromArgument = toTypeArguments[i];
+ TypeAnnotation toArgument = fromTypeArguments[i];
+ TypeAnnotation fromArgument = toTypeArguments[i];
expect(toArgument.type, same(fromArgument.type));
}
}
diff --git a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
index 665dbb9..5d0bb32 100644
--- a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
@@ -4,6 +4,8 @@
library analyzer.test.constant_test;
+import 'dart:async';
+
import 'package:analyzer/context/declared_variables.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/standard_resolution_map.dart';
@@ -92,8 +94,8 @@
@reflectiveTest
class ConstantValueComputerTest extends ResolverTestCase {
- void test_annotation_constConstructor() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_annotation_constConstructor() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
final int i;
const A(this.i);
@@ -110,8 +112,8 @@
_assertIntField(annotationFields, 'i', 5);
}
- void test_annotation_constConstructor_named() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_annotation_constConstructor_named() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
final int i;
const A.named(this.i);
@@ -128,10 +130,10 @@
_assertIntField(annotationFields, 'i', 5);
}
- void test_annotation_constConstructor_noArgs() {
+ test_annotation_constConstructor_noArgs() async {
// Failing to pass arguments to an annotation which is a constant
// constructor is illegal, but shouldn't crash analysis.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
final int i;
const A(this.i);
@@ -145,10 +147,10 @@
_evaluateAnnotation(compilationUnit, "C", "f");
}
- void test_annotation_constConstructor_noArgs_named() {
+ test_annotation_constConstructor_noArgs_named() async {
// Failing to pass arguments to an annotation which is a constant
// constructor is illegal, but shouldn't crash analysis.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
final int i;
const A.named(this.i);
@@ -162,10 +164,10 @@
_evaluateAnnotation(compilationUnit, "C", "f");
}
- void test_annotation_nonConstConstructor() {
+ test_annotation_nonConstConstructor() async {
// Calling a non-const constructor from an annotation that is illegal, but
// shouldn't crash analysis.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
final int i;
A(this.i);
@@ -179,8 +181,8 @@
_evaluateAnnotation(compilationUnit, "C", "f");
}
- void test_annotation_staticConst() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_annotation_staticConst() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
class C {
static const int i = 5;
@@ -193,10 +195,10 @@
expect(_assertValidInt(result), 5);
}
- void test_annotation_staticConst_args() {
+ test_annotation_staticConst_args() async {
// Applying arguments to an annotation that is a static const is
// illegal, but shouldn't crash analysis.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
class C {
static const int i = 5;
@@ -207,8 +209,8 @@
_evaluateAnnotation(compilationUnit, "C", "f");
}
- void test_annotation_staticConst_otherClass() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_annotation_staticConst_otherClass() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
static const int i = 5;
}
@@ -223,10 +225,10 @@
expect(_assertValidInt(result), 5);
}
- void test_annotation_staticConst_otherClass_args() {
+ test_annotation_staticConst_otherClass_args() async {
// Applying arguments to an annotation that is a static const is
// illegal, but shouldn't crash analysis.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
static const int i = 5;
}
@@ -239,8 +241,8 @@
_evaluateAnnotation(compilationUnit, "C", "f");
}
- void test_annotation_topLevelVariable() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_annotation_topLevelVariable() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const int i = 5;
class C {
@i
@@ -252,10 +254,10 @@
expect(_assertValidInt(result), 5);
}
- void test_annotation_topLevelVariable_args() {
+ test_annotation_topLevelVariable_args() async {
// Applying arguments to an annotation that is a top-level variable is
// illegal, but shouldn't crash analysis.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
const int i = 5;
class C {
@i(1)
@@ -265,7 +267,7 @@
_evaluateAnnotation(compilationUnit, "C", "f");
}
- void test_computeValues_cycle() {
+ test_computeValues_cycle() async {
TestLogger logger = new TestLogger();
AnalysisEngine.instance.logger = logger;
try {
@@ -291,7 +293,7 @@
}
}
- void test_computeValues_dependentVariables() {
+ test_computeValues_dependentVariables() async {
Source source = addSource(r'''
const int b = a;
const int a = 0;''');
@@ -308,12 +310,12 @@
_validate(true, (members[1] as TopLevelVariableDeclaration).variables);
}
- void test_computeValues_empty() {
+ test_computeValues_empty() async {
ConstantValueComputer computer = _makeConstantValueComputer();
computer.computeValues();
}
- void test_computeValues_multipleSources() {
+ test_computeValues_multipleSources() async {
Source librarySource = addNamedSource(
"/lib.dart",
r'''
@@ -350,7 +352,7 @@
_validate(true, (partMembers[1] as TopLevelVariableDeclaration).variables);
}
- void test_computeValues_singleVariable() {
+ test_computeValues_singleVariable() async {
Source source = addSource("const int a = 0;");
LibraryElement libraryElement = resolve2(source);
CompilationUnit unit =
@@ -364,7 +366,7 @@
_validate(true, (members[0] as TopLevelVariableDeclaration).variables);
}
- void test_computeValues_value_depends_on_enum() {
+ test_computeValues_value_depends_on_enum() async {
Source source = addSource('''
enum E { id0, id1 }
const E e = E.id0;
@@ -381,18 +383,18 @@
_validate(true, declaration.variables);
}
- void test_dependencyOnConstructor() {
+ test_dependencyOnConstructor() async {
// x depends on "const A()"
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
class A {
const A();
}
const x = const A();''');
}
- void test_dependencyOnConstructorArgument() {
+ test_dependencyOnConstructorArgument() async {
// "const A(x)" depends on x
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
class A {
const A(this.next);
final A next;
@@ -401,9 +403,9 @@
const A y = const A(x);''');
}
- void test_dependencyOnConstructorArgument_unresolvedConstructor() {
+ test_dependencyOnConstructorArgument_unresolvedConstructor() async {
// "const A.a(x)" depends on x even if the constructor A.a can't be found.
- _assertProperDependencies(
+ await _assertProperDependencies(
r'''
class A {
}
@@ -412,9 +414,9 @@
[CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
}
- void test_dependencyOnConstructorInitializer() {
+ test_dependencyOnConstructorInitializer() async {
// "const A()" depends on x
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const int x = 1;
class A {
const A() : v = x;
@@ -422,9 +424,9 @@
}''');
}
- void test_dependencyOnExplicitSuperConstructor() {
+ test_dependencyOnExplicitSuperConstructor() async {
// b depends on B() depends on A()
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
class A {
const A(this.x);
final int x;
@@ -435,9 +437,9 @@
const B b = const B();''');
}
- void test_dependencyOnExplicitSuperConstructorParameters() {
+ test_dependencyOnExplicitSuperConstructorParameters() async {
// b depends on B() depends on i
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
class A {
const A(this.x);
final int x;
@@ -449,9 +451,9 @@
const int i = 5;''');
}
- void test_dependencyOnFactoryRedirect() {
+ test_dependencyOnFactoryRedirect() async {
// a depends on A.foo() depends on A.bar()
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const A a = const A.foo();
class A {
factory const A.foo() = A.bar;
@@ -459,8 +461,8 @@
}''');
}
- void test_dependencyOnFactoryRedirectWithTypeParams() {
- _assertProperDependencies(r'''
+ test_dependencyOnFactoryRedirectWithTypeParams() async {
+ await _assertProperDependencies(r'''
class A {
const factory A(var a) = B<int>;
}
@@ -473,9 +475,9 @@
const A a = const A(10);''');
}
- void test_dependencyOnImplicitSuperConstructor() {
+ test_dependencyOnImplicitSuperConstructor() async {
// b depends on B() depends on A()
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
class A {
const A() : x = 5;
final int x;
@@ -486,9 +488,9 @@
const B b = const B();''');
}
- void test_dependencyOnInitializedFinal() {
+ test_dependencyOnInitializedFinal() async {
// a depends on A() depends on A.x
- _assertProperDependencies('''
+ await _assertProperDependencies('''
class A {
const A();
final int x = 1;
@@ -497,11 +499,11 @@
''');
}
- void test_dependencyOnInitializedNonStaticConst() {
+ test_dependencyOnInitializedNonStaticConst() async {
// Even though non-static consts are not allowed by the language, we need
// to handle them for error recovery purposes.
// a depends on A() depends on A.x
- _assertProperDependencies(
+ await _assertProperDependencies(
'''
class A {
const A();
@@ -512,9 +514,9 @@
[CompileTimeErrorCode.CONST_INSTANCE_FIELD]);
}
- void test_dependencyOnNonFactoryRedirect() {
+ test_dependencyOnNonFactoryRedirect() async {
// a depends on A.foo() depends on A.bar()
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const A a = const A.foo();
class A {
const A.foo() : this.bar();
@@ -522,9 +524,9 @@
}''');
}
- void test_dependencyOnNonFactoryRedirect_arg() {
+ test_dependencyOnNonFactoryRedirect_arg() async {
// a depends on A.foo() depends on b
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const A a = const A.foo();
const int b = 1;
class A {
@@ -534,9 +536,9 @@
}''');
}
- void test_dependencyOnNonFactoryRedirect_defaultValue() {
+ test_dependencyOnNonFactoryRedirect_defaultValue() async {
// a depends on A.foo() depends on A.bar() depends on b
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const A a = const A.foo();
const int b = 1;
class A {
@@ -546,10 +548,10 @@
}''');
}
- void test_dependencyOnNonFactoryRedirect_toMissing() {
+ test_dependencyOnNonFactoryRedirect_toMissing() async {
// a depends on A.foo() which depends on nothing, since A.bar() is
// missing.
- _assertProperDependencies(
+ await _assertProperDependencies(
r'''
const A a = const A.foo();
class A {
@@ -558,10 +560,10 @@
[CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]);
}
- void test_dependencyOnNonFactoryRedirect_toNonConst() {
+ test_dependencyOnNonFactoryRedirect_toNonConst() async {
// a depends on A.foo() which depends on nothing, since A.bar() is
// non-const.
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const A a = const A.foo();
class A {
const A.foo() : this.bar();
@@ -569,9 +571,9 @@
}''');
}
- void test_dependencyOnNonFactoryRedirect_unnamed() {
+ test_dependencyOnNonFactoryRedirect_unnamed() async {
// a depends on A.foo() depends on A()
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const A a = const A.foo();
class A {
const A.foo() : this();
@@ -579,9 +581,9 @@
}''');
}
- void test_dependencyOnOptionalParameterDefault() {
+ test_dependencyOnOptionalParameterDefault() async {
// a depends on A() depends on B()
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
class A {
const A([x = const B()]) : b = x;
final B b;
@@ -592,15 +594,15 @@
const A a = const A();''');
}
- void test_dependencyOnVariable() {
+ test_dependencyOnVariable() async {
// x depends on y
- _assertProperDependencies(r'''
+ await _assertProperDependencies(r'''
const x = y + 1;
const y = 2;''');
}
- void test_final_initialized_at_declaration() {
- CompilationUnit compilationUnit = resolveSource('''
+ test_final_initialized_at_declaration() async {
+ CompilationUnit compilationUnit = await resolveSource('''
class A {
final int i = 123;
const A();
@@ -615,103 +617,115 @@
_assertIntField(fields, "i", 123);
}
- void test_fromEnvironment_bool_default_false() {
- expect(_assertValidBool(_check_fromEnvironment_bool(null, "false")), false);
- }
-
- void test_fromEnvironment_bool_default_overridden() {
- expect(
- _assertValidBool(_check_fromEnvironment_bool("false", "true")), false);
- }
-
- void test_fromEnvironment_bool_default_parseError() {
- expect(_assertValidBool(_check_fromEnvironment_bool("parseError", "true")),
- true);
- }
-
- void test_fromEnvironment_bool_default_true() {
- expect(_assertValidBool(_check_fromEnvironment_bool(null, "true")), true);
- }
-
- void test_fromEnvironment_bool_false() {
- expect(_assertValidBool(_check_fromEnvironment_bool("false", null)), false);
- }
-
- void test_fromEnvironment_bool_parseError() {
- expect(_assertValidBool(_check_fromEnvironment_bool("parseError", null)),
+ test_fromEnvironment_bool_default_false() async {
+ expect(_assertValidBool(await _check_fromEnvironment_bool(null, "false")),
false);
}
- void test_fromEnvironment_bool_true() {
- expect(_assertValidBool(_check_fromEnvironment_bool("true", null)), true);
+ test_fromEnvironment_bool_default_overridden() async {
+ expect(_assertValidBool(await _check_fromEnvironment_bool("false", "true")),
+ false);
}
- void test_fromEnvironment_bool_undeclared() {
- _assertValidUnknown(_check_fromEnvironment_bool(null, null));
- }
-
- void test_fromEnvironment_int_default_overridden() {
- expect(_assertValidInt(_check_fromEnvironment_int("234", "123")), 234);
- }
-
- void test_fromEnvironment_int_default_parseError() {
+ test_fromEnvironment_bool_default_parseError() async {
expect(
- _assertValidInt(_check_fromEnvironment_int("parseError", "123")), 123);
+ _assertValidBool(
+ await _check_fromEnvironment_bool("parseError", "true")),
+ true);
}
- void test_fromEnvironment_int_default_undeclared() {
- expect(_assertValidInt(_check_fromEnvironment_int(null, "123")), 123);
+ test_fromEnvironment_bool_default_true() async {
+ expect(_assertValidBool(await _check_fromEnvironment_bool(null, "true")),
+ true);
}
- void test_fromEnvironment_int_ok() {
- expect(_assertValidInt(_check_fromEnvironment_int("234", null)), 234);
+ test_fromEnvironment_bool_false() async {
+ expect(_assertValidBool(await _check_fromEnvironment_bool("false", null)),
+ false);
}
- void test_fromEnvironment_int_parseError() {
- _assertValidNull(_check_fromEnvironment_int("parseError", null));
+ test_fromEnvironment_bool_parseError() async {
+ expect(
+ _assertValidBool(await _check_fromEnvironment_bool("parseError", null)),
+ false);
}
- void test_fromEnvironment_int_parseError_nullDefault() {
- _assertValidNull(_check_fromEnvironment_int("parseError", "null"));
+ test_fromEnvironment_bool_true() async {
+ expect(_assertValidBool(await _check_fromEnvironment_bool("true", null)),
+ true);
}
- void test_fromEnvironment_int_undeclared() {
- _assertValidUnknown(_check_fromEnvironment_int(null, null));
+ test_fromEnvironment_bool_undeclared() async {
+ _assertValidUnknown(await _check_fromEnvironment_bool(null, null));
}
- void test_fromEnvironment_int_undeclared_nullDefault() {
- _assertValidNull(_check_fromEnvironment_int(null, "null"));
+ test_fromEnvironment_int_default_overridden() async {
+ expect(
+ _assertValidInt(await _check_fromEnvironment_int("234", "123")), 234);
}
- void test_fromEnvironment_string_default_overridden() {
- expect(_assertValidString(_check_fromEnvironment_string("abc", "'def'")),
+ test_fromEnvironment_int_default_parseError() async {
+ expect(
+ _assertValidInt(await _check_fromEnvironment_int("parseError", "123")),
+ 123);
+ }
+
+ test_fromEnvironment_int_default_undeclared() async {
+ expect(_assertValidInt(await _check_fromEnvironment_int(null, "123")), 123);
+ }
+
+ test_fromEnvironment_int_ok() async {
+ expect(_assertValidInt(await _check_fromEnvironment_int("234", null)), 234);
+ }
+
+ test_fromEnvironment_int_parseError() async {
+ _assertValidNull(await _check_fromEnvironment_int("parseError", null));
+ }
+
+ test_fromEnvironment_int_parseError_nullDefault() async {
+ _assertValidNull(await _check_fromEnvironment_int("parseError", "null"));
+ }
+
+ test_fromEnvironment_int_undeclared() async {
+ _assertValidUnknown(await _check_fromEnvironment_int(null, null));
+ }
+
+ test_fromEnvironment_int_undeclared_nullDefault() async {
+ _assertValidNull(await _check_fromEnvironment_int(null, "null"));
+ }
+
+ test_fromEnvironment_string_default_overridden() async {
+ expect(
+ _assertValidString(await _check_fromEnvironment_string("abc", "'def'")),
"abc");
}
- void test_fromEnvironment_string_default_undeclared() {
- expect(_assertValidString(_check_fromEnvironment_string(null, "'def'")),
+ test_fromEnvironment_string_default_undeclared() async {
+ expect(
+ _assertValidString(await _check_fromEnvironment_string(null, "'def'")),
"def");
}
- void test_fromEnvironment_string_empty() {
- expect(_assertValidString(_check_fromEnvironment_string("", null)), "");
- }
-
- void test_fromEnvironment_string_ok() {
+ test_fromEnvironment_string_empty() async {
expect(
- _assertValidString(_check_fromEnvironment_string("abc", null)), "abc");
+ _assertValidString(await _check_fromEnvironment_string("", null)), "");
}
- void test_fromEnvironment_string_undeclared() {
- _assertValidUnknown(_check_fromEnvironment_string(null, null));
+ test_fromEnvironment_string_ok() async {
+ expect(_assertValidString(await _check_fromEnvironment_string("abc", null)),
+ "abc");
}
- void test_fromEnvironment_string_undeclared_nullDefault() {
- _assertValidNull(_check_fromEnvironment_string(null, "null"));
+ test_fromEnvironment_string_undeclared() async {
+ _assertValidUnknown(await _check_fromEnvironment_string(null, null));
}
- void test_instanceCreationExpression_computedField() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_fromEnvironment_string_undeclared_nullDefault() async {
+ _assertValidNull(await _check_fromEnvironment_string(null, "null"));
+ }
+
+ test_instanceCreationExpression_computedField() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A(4, 5);
class A {
const A(int i, int j) : k = 2 * i + j;
@@ -724,28 +738,24 @@
_assertIntField(fields, "k", 13);
}
- void
- test_instanceCreationExpression_computedField_namedOptionalWithDefault() {
- _checkInstanceCreationOptionalParams(false, true, true);
+ test_instanceCreationExpression_computedField_namedOptionalWithDefault() async {
+ await _checkInstanceCreationOptionalParams(false, true, true);
}
- void
- test_instanceCreationExpression_computedField_namedOptionalWithoutDefault() {
- _checkInstanceCreationOptionalParams(false, true, false);
+ test_instanceCreationExpression_computedField_namedOptionalWithoutDefault() async {
+ await _checkInstanceCreationOptionalParams(false, true, false);
}
- void
- test_instanceCreationExpression_computedField_unnamedOptionalWithDefault() {
- _checkInstanceCreationOptionalParams(false, false, true);
+ test_instanceCreationExpression_computedField_unnamedOptionalWithDefault() async {
+ await _checkInstanceCreationOptionalParams(false, false, true);
}
- void
- test_instanceCreationExpression_computedField_unnamedOptionalWithoutDefault() {
- _checkInstanceCreationOptionalParams(false, false, false);
+ test_instanceCreationExpression_computedField_unnamedOptionalWithoutDefault() async {
+ await _checkInstanceCreationOptionalParams(false, false, false);
}
- void test_instanceCreationExpression_computedField_usesConstConstructor() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_computedField_usesConstConstructor() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A(3);
class A {
const A(int i) : b = const B(4);
@@ -765,8 +775,8 @@
_assertIntField(fieldsOfB, "k", 4);
}
- void test_instanceCreationExpression_computedField_usesStaticConst() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_computedField_usesStaticConst() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A(3);
class A {
const A(int i) : k = i + B.bar;
@@ -782,8 +792,8 @@
_assertIntField(fields, "k", 7);
}
- void test_instanceCreationExpression_computedField_usesTopLevelConst() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_computedField_usesTopLevelConst() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A(3);
const bar = 4;
class A {
@@ -797,8 +807,8 @@
_assertIntField(fields, "k", 7);
}
- void test_instanceCreationExpression_explicitSuper() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_explicitSuper() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const B(4, 5);
class A {
const A(this.x);
@@ -819,8 +829,8 @@
_assertIntField(superclassFields, "x", 8);
}
- void test_instanceCreationExpression_fieldFormalParameter() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_fieldFormalParameter() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A(42);
class A {
int x;
@@ -833,28 +843,24 @@
_assertIntField(fields, "x", 42);
}
- void
- test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithDefault() {
- _checkInstanceCreationOptionalParams(true, true, true);
+ test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithDefault() async {
+ await _checkInstanceCreationOptionalParams(true, true, true);
}
- void
- test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithoutDefault() {
- _checkInstanceCreationOptionalParams(true, true, false);
+ test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithoutDefault() async {
+ await _checkInstanceCreationOptionalParams(true, true, false);
}
- void
- test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithDefault() {
- _checkInstanceCreationOptionalParams(true, false, true);
+ test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithDefault() async {
+ await _checkInstanceCreationOptionalParams(true, false, true);
}
- void
- test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithoutDefault() {
- _checkInstanceCreationOptionalParams(true, false, false);
+ test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithoutDefault() async {
+ await _checkInstanceCreationOptionalParams(true, false, false);
}
- void test_instanceCreationExpression_implicitSuper() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_implicitSuper() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const B(4);
class A {
const A() : x = 3;
@@ -875,8 +881,8 @@
_assertIntField(superclassFields, "x", 3);
}
- void test_instanceCreationExpression_nonFactoryRedirect() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_nonFactoryRedirect() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A.a1();
class A {
const A.a1() : this.a2();
@@ -888,8 +894,8 @@
_assertIntField(aFields, 'x', 5);
}
- void test_instanceCreationExpression_nonFactoryRedirect_arg() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_nonFactoryRedirect_arg() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A.a1(1);
class A {
const A.a1(x) : this.a2(x + 100);
@@ -901,11 +907,11 @@
_assertIntField(aFields, 'y', 111);
}
- void test_instanceCreationExpression_nonFactoryRedirect_cycle() {
+ test_instanceCreationExpression_nonFactoryRedirect_cycle() async {
// It is an error to have a cycle in non-factory redirects; however, we
// need to make sure that even if the error occurs, attempting to evaluate
// the constant will terminate.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A();
class A {
const A() : this.b();
@@ -914,8 +920,8 @@
_assertValidUnknown(_evaluateTopLevelVariable(compilationUnit, "foo"));
}
- void test_instanceCreationExpression_nonFactoryRedirect_defaultArg() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_nonFactoryRedirect_defaultArg() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A.a1();
class A {
const A.a1() : this.a2();
@@ -927,8 +933,8 @@
_assertIntField(aFields, 'y', 110);
}
- void test_instanceCreationExpression_nonFactoryRedirect_toMissing() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_nonFactoryRedirect_toMissing() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A.a1();
class A {
const A.a1() : this.a2();
@@ -939,8 +945,8 @@
_assertType(_evaluateTopLevelVariable(compilationUnit, "foo"), "A");
}
- void test_instanceCreationExpression_nonFactoryRedirect_toNonConst() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_nonFactoryRedirect_toNonConst() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A.a1();
class A {
const A.a1() : this.a2();
@@ -952,8 +958,8 @@
_assertType(_evaluateTopLevelVariable(compilationUnit, "foo"), "A");
}
- void test_instanceCreationExpression_nonFactoryRedirect_unnamed() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_nonFactoryRedirect_unnamed() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A.a1();
class A {
const A.a1() : this();
@@ -965,8 +971,8 @@
_assertIntField(aFields, 'x', 5);
}
- void test_instanceCreationExpression_redirect() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_redirect() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A();
class A {
const factory A() = B;
@@ -977,11 +983,11 @@
_assertType(_evaluateTopLevelVariable(compilationUnit, "foo"), "B");
}
- void test_instanceCreationExpression_redirect_cycle() {
+ test_instanceCreationExpression_redirect_cycle() async {
// It is an error to have a cycle in factory redirects; however, we need
// to make sure that even if the error occurs, attempting to evaluate the
// constant will terminate.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A();
class A {
const factory A() = A.b;
@@ -990,8 +996,8 @@
_assertValidUnknown(_evaluateTopLevelVariable(compilationUnit, "foo"));
}
- void test_instanceCreationExpression_redirect_external() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_redirect_external() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A();
class A {
external const factory A();
@@ -999,11 +1005,11 @@
_assertValidUnknown(_evaluateTopLevelVariable(compilationUnit, "foo"));
}
- void test_instanceCreationExpression_redirect_nonConst() {
+ test_instanceCreationExpression_redirect_nonConst() async {
// It is an error for a const factory constructor redirect to a non-const
// constructor; however, we need to make sure that even if the error
// attempting to evaluate the constant won't cause a crash.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
const foo = const A();
class A {
const factory A() = A.b;
@@ -1012,8 +1018,8 @@
_assertValidUnknown(_evaluateTopLevelVariable(compilationUnit, "foo"));
}
- void test_instanceCreationExpression_redirectWithTypeParams() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_redirectWithTypeParams() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A {
const factory A(var a) = B<int>;
}
@@ -1031,11 +1037,11 @@
_assertIntField(fields, "x", 10);
}
- void test_instanceCreationExpression_redirectWithTypeSubstitution() {
+ test_instanceCreationExpression_redirectWithTypeSubstitution() async {
// To evaluate the redirection of A<int>,
// A's template argument (T=int) must be substituted
// into B's template argument (B<U> where U=T) to get B<int>.
- CompilationUnit compilationUnit = resolveSource(r'''
+ CompilationUnit compilationUnit = await resolveSource(r'''
class A<T> {
const factory A(var a) = B<T>;
}
@@ -1053,9 +1059,9 @@
_assertIntField(fields, "x", 10);
}
- void test_instanceCreationExpression_symbol() {
+ test_instanceCreationExpression_symbol() async {
CompilationUnit compilationUnit =
- resolveSource("const foo = const Symbol('a');");
+ await resolveSource("const foo = const Symbol('a');");
EvaluationResultImpl evaluationResult =
_evaluateTopLevelVariable(compilationUnit, "foo");
expect(evaluationResult.value, isNotNull);
@@ -1064,16 +1070,16 @@
expect(value.toSymbolValue(), "a");
}
- void test_instanceCreationExpression_withSupertypeParams_explicit() {
- _checkInstanceCreation_withSupertypeParams(true);
+ test_instanceCreationExpression_withSupertypeParams_explicit() async {
+ await _checkInstanceCreation_withSupertypeParams(true);
}
- void test_instanceCreationExpression_withSupertypeParams_implicit() {
- _checkInstanceCreation_withSupertypeParams(false);
+ test_instanceCreationExpression_withSupertypeParams_implicit() async {
+ await _checkInstanceCreation_withSupertypeParams(false);
}
- void test_instanceCreationExpression_withTypeParams() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_instanceCreationExpression_withTypeParams() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
class C<E> {
const C();
}
@@ -1090,7 +1096,7 @@
expect(c_int_value == c_num_value, isFalse);
}
- void test_isValidSymbol() {
+ test_isValidSymbol() async {
expect(ConstantEvaluationEngine.isValidPublicSymbol(""), isTrue);
expect(ConstantEvaluationEngine.isValidPublicSymbol("foo"), isTrue);
expect(ConstantEvaluationEngine.isValidPublicSymbol("foo.bar"), isTrue);
@@ -1117,11 +1123,11 @@
expect(ConstantEvaluationEngine.isValidPublicSymbol("foo.void"), isFalse);
}
- void test_length_of_improperly_typed_string_expression() {
+ test_length_of_improperly_typed_string_expression() async {
// Since type annotations are ignored in unchecked mode, the improper
// types on s1 and s2 shouldn't prevent us from evaluating i to
// 'alpha'.length.
- CompilationUnit compilationUnit = resolveSource('''
+ CompilationUnit compilationUnit = await resolveSource('''
const int s1 = 'alpha';
const int s2 = 'beta';
const int i = (true ? s1 : s2).length;
@@ -1132,10 +1138,10 @@
expect(_assertValidInt(result), 5);
}
- void test_length_of_improperly_typed_string_identifier() {
+ test_length_of_improperly_typed_string_identifier() async {
// Since type annotations are ignored in unchecked mode, the improper type
// on s shouldn't prevent us from evaluating i to 'alpha'.length.
- CompilationUnit compilationUnit = resolveSource('''
+ CompilationUnit compilationUnit = await resolveSource('''
const int s = 'alpha';
const int i = s.length;
''');
@@ -1145,10 +1151,10 @@
expect(_assertValidInt(result), 5);
}
- void test_non_static_const_initialized_at_declaration() {
+ test_non_static_const_initialized_at_declaration() async {
// Even though non-static consts are not allowed by the language, we need
// to handle them for error recovery purposes.
- CompilationUnit compilationUnit = resolveSource('''
+ CompilationUnit compilationUnit = await resolveSource('''
class A {
const int i = 123;
const A();
@@ -1163,9 +1169,9 @@
_assertIntField(fields, "i", 123);
}
- void test_symbolLiteral_void() {
+ test_symbolLiteral_void() async {
CompilationUnit compilationUnit =
- resolveSource("const voidSymbol = #void;");
+ await resolveSource("const voidSymbol = #void;");
VariableDeclaration voidSymbol =
findTopLevelDeclaration(compilationUnit, "voidSymbol");
EvaluationResultImpl voidSymbolResult =
@@ -1196,8 +1202,8 @@
expect(field.isNull, isTrue);
}
- void _assertProperDependencies(String sourceText,
- [List<ErrorCode> expectedErrorCodes = const <ErrorCode>[]]) {
+ Future<Null> _assertProperDependencies(String sourceText,
+ [List<ErrorCode> expectedErrorCodes = const <ErrorCode>[]]) async {
Source source = addSource(sourceText);
LibraryElement element = resolve2(source);
CompilationUnit unit =
@@ -1206,6 +1212,7 @@
ConstantValueComputer computer = _makeConstantValueComputer();
computer.add(unit);
computer.computeValues();
+ await computeAnalysisResult(source);
assertErrors(source, expectedErrorCodes);
}
@@ -1253,8 +1260,8 @@
expect(value.isUnknown, isTrue);
}
- EvaluationResultImpl _check_fromEnvironment_bool(
- String valueInEnvironment, String defaultExpr) {
+ Future<EvaluationResultImpl> _check_fromEnvironment_bool(
+ String valueInEnvironment, String defaultExpr) async {
String envVarName = "x";
String varName = "foo";
if (valueInEnvironment != null) {
@@ -1262,13 +1269,13 @@
}
String defaultArg =
defaultExpr == null ? "" : ", defaultValue: $defaultExpr";
- CompilationUnit compilationUnit = resolveSource(
+ CompilationUnit compilationUnit = await resolveSource(
"const $varName = const bool.fromEnvironment('$envVarName'$defaultArg);");
return _evaluateTopLevelVariable(compilationUnit, varName);
}
- EvaluationResultImpl _check_fromEnvironment_int(
- String valueInEnvironment, String defaultExpr) {
+ Future<EvaluationResultImpl> _check_fromEnvironment_int(
+ String valueInEnvironment, String defaultExpr) async {
String envVarName = "x";
String varName = "foo";
if (valueInEnvironment != null) {
@@ -1276,13 +1283,13 @@
}
String defaultArg =
defaultExpr == null ? "" : ", defaultValue: $defaultExpr";
- CompilationUnit compilationUnit = resolveSource(
+ CompilationUnit compilationUnit = await resolveSource(
"const $varName = const int.fromEnvironment('$envVarName'$defaultArg);");
return _evaluateTopLevelVariable(compilationUnit, varName);
}
- EvaluationResultImpl _check_fromEnvironment_string(
- String valueInEnvironment, String defaultExpr) {
+ Future<EvaluationResultImpl> _check_fromEnvironment_string(
+ String valueInEnvironment, String defaultExpr) async {
String envVarName = "x";
String varName = "foo";
if (valueInEnvironment != null) {
@@ -1290,14 +1297,15 @@
}
String defaultArg =
defaultExpr == null ? "" : ", defaultValue: $defaultExpr";
- CompilationUnit compilationUnit = resolveSource(
+ CompilationUnit compilationUnit = await resolveSource(
"const $varName = const String.fromEnvironment('$envVarName'$defaultArg);");
return _evaluateTopLevelVariable(compilationUnit, varName);
}
- void _checkInstanceCreation_withSupertypeParams(bool isExplicit) {
+ Future<Null> _checkInstanceCreation_withSupertypeParams(
+ bool isExplicit) async {
String superCall = isExplicit ? " : super()" : "";
- CompilationUnit compilationUnit = resolveSource("""
+ CompilationUnit compilationUnit = await resolveSource("""
class A<T> {
const A();
}
@@ -1321,13 +1329,13 @@
_assertFieldType(c_int_num_fields, GenericState.SUPERCLASS_FIELD, "A<num>");
}
- void _checkInstanceCreationOptionalParams(
- bool isFieldFormal, bool isNamed, bool hasDefault) {
+ Future<Null> _checkInstanceCreationOptionalParams(
+ bool isFieldFormal, bool isNamed, bool hasDefault) async {
String fieldName = "j";
String paramName = isFieldFormal ? fieldName : "i";
String formalParam =
"${isFieldFormal ? "this." : "int "}$paramName${hasDefault ? " = 3" : ""}";
- CompilationUnit compilationUnit = resolveSource("""
+ CompilationUnit compilationUnit = await resolveSource("""
const x = const A();
const y = const A(${isNamed ? '$paramName: ' : ''}10);
class A {
@@ -1407,7 +1415,7 @@
@reflectiveTest
class ConstantVisitorTest extends ResolverTestCase {
- void test_visitBinaryExpression_questionQuestion_notNull_notNull() {
+ test_visitBinaryExpression_questionQuestion_notNull_notNull() async {
Expression left = AstTestFactory.string2('a');
Expression right = AstTestFactory.string2('b');
Expression expression = AstTestFactory.binaryExpression(
@@ -1423,7 +1431,7 @@
errorListener.assertNoErrors();
}
- void test_visitBinaryExpression_questionQuestion_null_notNull() {
+ test_visitBinaryExpression_questionQuestion_null_notNull() async {
Expression left = AstTestFactory.nullLiteral();
Expression right = AstTestFactory.string2('b');
Expression expression = AstTestFactory.binaryExpression(
@@ -1439,7 +1447,7 @@
errorListener.assertNoErrors();
}
- void test_visitBinaryExpression_questionQuestion_null_null() {
+ test_visitBinaryExpression_questionQuestion_null_null() async {
Expression left = AstTestFactory.nullLiteral();
Expression right = AstTestFactory.nullLiteral();
Expression expression = AstTestFactory.binaryExpression(
@@ -1454,7 +1462,7 @@
errorListener.assertNoErrors();
}
- void test_visitConditionalExpression_false() {
+ test_visitConditionalExpression_false() async {
Expression thenExpression = AstTestFactory.integer(1);
Expression elseExpression = AstTestFactory.integer(0);
ConditionalExpression expression = AstTestFactory.conditionalExpression(
@@ -1466,7 +1474,7 @@
errorListener.assertNoErrors();
}
- void test_visitConditionalExpression_nonBooleanCondition() {
+ test_visitConditionalExpression_nonBooleanCondition() async {
Expression thenExpression = AstTestFactory.integer(1);
Expression elseExpression = AstTestFactory.integer(0);
NullLiteral conditionExpression = AstTestFactory.nullLiteral();
@@ -1481,7 +1489,7 @@
.assertErrorsWithCodes([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
}
- void test_visitConditionalExpression_nonConstantElse() {
+ test_visitConditionalExpression_nonConstantElse() async {
Expression thenExpression = AstTestFactory.integer(1);
Expression elseExpression = AstTestFactory.identifier3("x");
ConditionalExpression expression = AstTestFactory.conditionalExpression(
@@ -1495,7 +1503,7 @@
.assertErrorsWithCodes([CompileTimeErrorCode.INVALID_CONSTANT]);
}
- void test_visitConditionalExpression_nonConstantThen() {
+ test_visitConditionalExpression_nonConstantThen() async {
Expression thenExpression = AstTestFactory.identifier3("x");
Expression elseExpression = AstTestFactory.integer(0);
ConditionalExpression expression = AstTestFactory.conditionalExpression(
@@ -1509,7 +1517,7 @@
.assertErrorsWithCodes([CompileTimeErrorCode.INVALID_CONSTANT]);
}
- void test_visitConditionalExpression_true() {
+ test_visitConditionalExpression_true() async {
Expression thenExpression = AstTestFactory.integer(1);
Expression elseExpression = AstTestFactory.integer(0);
ConditionalExpression expression = AstTestFactory.conditionalExpression(
@@ -1521,8 +1529,8 @@
errorListener.assertNoErrors();
}
- void test_visitSimpleIdentifier_className() {
- CompilationUnit compilationUnit = resolveSource('''
+ test_visitSimpleIdentifier_className() async {
+ CompilationUnit compilationUnit = await resolveSource('''
const a = C;
class C {}
''');
@@ -1531,8 +1539,8 @@
expect(result.toTypeValue().name, 'C');
}
- void test_visitSimpleIdentifier_dynamic() {
- CompilationUnit compilationUnit = resolveSource('''
+ test_visitSimpleIdentifier_dynamic() async {
+ CompilationUnit compilationUnit = await resolveSource('''
const a = dynamic;
''');
DartObjectImpl result = _evaluateConstant(compilationUnit, 'a', null);
@@ -1540,8 +1548,8 @@
expect(result.toTypeValue(), typeProvider.dynamicType);
}
- void test_visitSimpleIdentifier_inEnvironment() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_visitSimpleIdentifier_inEnvironment() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const a = b;
const b = 3;''');
Map<String, DartObjectImpl> environment = new Map<String, DartObjectImpl>();
@@ -1551,8 +1559,8 @@
_assertValue(6, _evaluateConstant(compilationUnit, "a", environment));
}
- void test_visitSimpleIdentifier_notInEnvironment() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_visitSimpleIdentifier_notInEnvironment() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const a = b;
const b = 3;''');
Map<String, DartObjectImpl> environment = new Map<String, DartObjectImpl>();
@@ -1562,8 +1570,8 @@
_assertValue(3, _evaluateConstant(compilationUnit, "a", environment));
}
- void test_visitSimpleIdentifier_withoutEnvironment() {
- CompilationUnit compilationUnit = resolveSource(r'''
+ test_visitSimpleIdentifier_withoutEnvironment() async {
+ CompilationUnit compilationUnit = await resolveSource(r'''
const a = b;
const b = 3;''');
_assertValue(3, _evaluateConstant(compilationUnit, "a", null));
@@ -1610,6 +1618,6 @@
class StrongConstantValueComputerTest extends ConstantValueComputerTest {
void setUp() {
super.setUp();
- resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
}
}
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
index 3b81e26..64901f9 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -4541,7 +4541,10 @@
void _assertTypeParameterBound(TypeParameter typeParameter,
String expectedBoundTypeString, String expectedBoundElementName) {
- TypeName boundNode = typeParameter.bound;
+ TypeAnnotation bound = typeParameter.bound;
+ // TODO(brianwilkerson) Extend this to support function types as bounds.
+ expect(bound, new isInstanceOf<TypeName>());
+ TypeName boundNode = bound;
Identifier boundName = boundNode.name;
expect(boundNode.type.toString(), expectedBoundTypeString);
expect(boundName.staticType.toString(), expectedBoundTypeString);
diff --git a/pkg/analyzer/test/utils.dart b/pkg/analyzer/test/utils.dart
index 5bd96ff..6d70357 100644
--- a/pkg/analyzer/test/utils.dart
+++ b/pkg/analyzer/test/utils.dart
@@ -201,7 +201,9 @@
// TODO(leafp): Make these matchers.
// https://www.dartdocs.org/documentation/matcher/0.12.0%2B1/matcher/Matcher-class.html
- /* Provides primitive types for basic type assertions */
+ /**
+ * Provides primitive types for basic type assertions.
+ */
final TypeProvider _typeProvider;
TypeAssertions(this._typeProvider);
@@ -219,12 +221,12 @@
/**
* Primitive assertion for the list type
*/
- Asserter<DartType> get isList => sameElement(_typeProvider.listType);
+ Asserter<DartType> get isList => hasElementOf(_typeProvider.listType);
/**
* Primitive assertion for the map type
*/
- Asserter<DartType> get isMap => sameElement(_typeProvider.mapType);
+ Asserter<DartType> get isMap => hasElementOf(_typeProvider.mapType);
/**
* Primitive assertion for the num type
@@ -237,10 +239,16 @@
Asserter<DartType> get isString => isType(_typeProvider.stringType);
/**
- * Given a type, produce an assertion that a type has the same element.
+ * Assert that a type has the element that is equal to the [expected].
*/
- Asserter<DartType> hasElement(Element element) =>
- (DartType type) => expect(element, same(type.element));
+ Asserter<DartType> hasElement(Element expected) =>
+ (DartType type) => expect(expected, type.element);
+
+ /**
+ * Assert that a type has the element that is equal to the element of the
+ * given [type].
+ */
+ Asserter<DartType> hasElementOf(DartType type) => hasElement(type.element);
/**
* Given assertions for the argument and return types, produce an
@@ -256,7 +264,7 @@
/**
* Given an assertion for the base type and assertions over the type
- * parameters, produce an assertion over instantations.
+ * parameters, produce an assertion over instantiations.
*/
AsserterBuilder<List<Asserter<DartType>>, DartType> isInstantiationOf(
Asserter<DartType> baseAssert) =>
@@ -286,15 +294,9 @@
isInstantiationOf(isMap)([argAssert0, argAssert1]);
/**
- * Assert that one type is the same as another
+ * Assert that a type is equal to the [expected].
*/
- Asserter<DartType> isType(DartType argument) => (DartType t) {
- expect(t, same(argument));
+ Asserter<DartType> isType(DartType expected) => (DartType t) {
+ expect(t, expected);
};
-
- /**
- * Given a type, produce an assertion that a type has the same element.
- */
- Asserter<DartType> sameElement(DartType elementType) =>
- hasElement(elementType.element);
}
diff --git a/pkg/analyzer/tool/summary/generate.dart b/pkg/analyzer/tool/summary/generate.dart
index d3fd863..6db5cf0 100644
--- a/pkg/analyzer/tool/summary/generate.dart
+++ b/pkg/analyzer/tool/summary/generate.dart
@@ -268,10 +268,13 @@
for (ClassMember classMember in decl.members) {
if (classMember is MethodDeclaration && classMember.isGetter) {
String desc = '$clsName.${classMember.name.name}';
- TypeName type = classMember.returnType;
- if (type == null) {
- throw new Exception('Class member needs a type: $desc');
+ if (classMember.returnType is! TypeName) {
+ if (classMember.returnType == null) {
+ throw new Exception('Class member needs a type: $desc');
+ }
+ throw new Exception('Class member needs a class type: $desc');
}
+ TypeName type = classMember.returnType;
bool isList = false;
if (type.name.name == 'List' &&
type.typeArguments != null &&
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 95cd78e..87ce42f 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -1984,7 +1984,7 @@
/**
* Returns true if the element has to be resolved due to a mirrorsUsed
* annotation. If we have insufficient mirrors used annotations, we only
- * keep additonal elements if treeshaking has been disabled.
+ * keep additional elements if treeshaking has been disabled.
*/
bool requiredByMirrorSystem(Element element) {
return hasInsufficientMirrorsUsed && isTreeShakingDisabled ||
diff --git a/pkg/compiler/lib/src/js_backend/backend_helpers.dart b/pkg/compiler/lib/src/js_backend/backend_helpers.dart
index 3d7944e..a4f814f 100644
--- a/pkg/compiler/lib/src/js_backend/backend_helpers.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_helpers.dart
@@ -638,17 +638,26 @@
return _findHelper('throwNoSuchMethod');
}
- Element get genericNoSuchMethod =>
- _genericNoSuchMethod ??= findCoreHelper('_genericNoSuchMethod');
- MethodElement _genericNoSuchMethod;
+ Element get malformedTypeError => _cachedCoreHelper('_malformedTypeError');
+ Element get genericNoSuchMethod => _cachedCoreHelper('_genericNoSuchMethod');
+ Element get unresolvedConstructorError =>
+ _cachedCoreHelper('_unresolvedConstructorError');
+ Element get unresolvedStaticGetterError =>
+ _cachedCoreHelper('_unresolvedStaticGetterError');
+ Element get unresolvedStaticSetterError =>
+ _cachedCoreHelper('_unresolvedStaticSetterError');
+ Element get unresolvedStaticMethodError =>
+ _cachedCoreHelper('_unresolvedStaticMethodError');
+ Element get unresolvedTopLevelGetterError =>
+ _cachedCoreHelper('_unresolvedTopLevelGetterError');
+ Element get unresolvedTopLevelSetterError =>
+ _cachedCoreHelper('_unresolvedTopLevelSetterError');
+ Element get unresolvedTopLevelMethodError =>
+ _cachedCoreHelper('_unresolvedTopLevelMethodError');
- Element get unresolvedConstructorError => _unresolvedConstructorError ??=
- findCoreHelper('_unresolvedConstructorError');
- MethodElement _unresolvedConstructorError;
-
- Element get malformedTypeError =>
- _malformedTypeError ??= findCoreHelper('_malformedTypeError');
- MethodElement _malformedTypeError;
+ Map<String, Element> _cachedCoreHelpers = <String, Element>{};
+ Element _cachedCoreHelper(String name) =>
+ _cachedCoreHelpers[name] ??= findCoreHelper(name);
Element get createRuntimeType {
return _findHelper('createRuntimeType');
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index be5e9cf..f2df00d 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -170,6 +170,12 @@
? [
helpers.genericNoSuchMethod,
helpers.unresolvedConstructorError,
+ helpers.unresolvedStaticMethodError,
+ helpers.unresolvedStaticGetterError,
+ helpers.unresolvedStaticSetterError,
+ helpers.unresolvedTopLevelMethodError,
+ helpers.unresolvedTopLevelGetterError,
+ helpers.unresolvedTopLevelSetterError,
commonElements.symbolConstructor.declaration,
]
: [
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index 3d8ea6c..6b3a226 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -939,10 +939,14 @@
prototype[getterName] = function () {
var result = this[fieldName];
+ if (result == sentinelInProgress) {
+ // In minified mode, static name is not provided, so fall back
+ // to the minified fieldName.
+ #cyclicThrow(staticName || fieldName);
+ }
try {
if (result === sentinelUndefined) {
this[fieldName] = sentinelInProgress;
-
try {
result = this[fieldName] = lazyValue();
} finally {
@@ -951,13 +955,7 @@
if (result === sentinelUndefined)
this[fieldName] = null;
}
- } else {
- if (result === sentinelInProgress)
- // In minified mode, static name is not provided, so fall
- // back to the minified fieldName.
- #cyclicThrow(staticName || fieldName);
}
-
return result;
} finally {
this[getterName] = function() { return this[fieldName]; };
diff --git a/pkg/compiler/lib/src/kernel/unresolved.dart b/pkg/compiler/lib/src/kernel/unresolved.dart
index 7560ccb..8a984ed 100644
--- a/pkg/compiler/lib/src/kernel/unresolved.dart
+++ b/pkg/compiler/lib/src/kernel/unresolved.dart
@@ -30,6 +30,7 @@
bool get isVoidContext;
ir.Arguments buildArguments(NodeList arguments);
ir.TreeNode visitForValue(Expression node);
+ void associateCompoundComponents(Accessor accessor, Node node);
// TODO(ahe): Delete this method.
ir.InvalidExpression handleUnresolved(Node node);
@@ -124,6 +125,7 @@
}
ir.Expression buildThrowUnresolvedSuperGetter(String name) {
+ // TODO(sra): This is incorrect when the superclass defines noSuchMethod.
return buildThrowNoSuchMethodError(kernel.getUnresolvedSuperGetterBuilder(),
new ir.ThisExpression(), name, new ir.Arguments.empty());
}
@@ -269,16 +271,22 @@
MethodElement getter, Element element, IncDecOperator operator, _) {
var accessor = new ClassStaticAccessor(
this, getter.name, possiblyErroneousFunctionToIr(getter), null);
- return accessor.buildPostfixIncrement(new ir.Name(operator.selectorName),
+ var result = accessor.buildPostfixIncrement(
+ new ir.Name(operator.selectorName),
voidContext: isVoidContext);
+ associateCompoundComponents(accessor, node);
+ return result;
}
ir.Expression visitUnresolvedStaticSetterPrefix(Send node,
MethodElement getter, Element element, IncDecOperator operator, _) {
var accessor = new ClassStaticAccessor(
this, getter.name, possiblyErroneousFunctionToIr(getter), null);
- return accessor.buildPrefixIncrement(new ir.Name(operator.selectorName),
+ var result = accessor.buildPrefixIncrement(
+ new ir.Name(operator.selectorName),
voidContext: isVoidContext);
+ associateCompoundComponents(accessor, node);
+ return result;
}
ir.Expression visitUnresolvedStaticSetterSetIfNull(
@@ -291,6 +299,7 @@
ir.Expression visitUnresolvedSuperBinary(
Send node, Element element, BinaryOperator operator, Node argument, _) {
+ // TODO(sra): This is incorrect when the superclass defines noSuchMethod.
return buildThrowNoSuchMethodError(
kernel.getUnresolvedSuperMethodBuilder(),
new ir.ThisExpression(),
@@ -521,25 +530,33 @@
_) {
var accessor = new TopLevelStaticAccessor(
this, getter.name, possiblyErroneousFunctionToIr(getter), null);
- return accessor.buildCompoundAssignment(
+ var result = accessor.buildCompoundAssignment(
new ir.Name(operator.selectorName), visitForValue(rhs),
voidContext: isVoidContext);
+ associateCompoundComponents(accessor, node);
+ return result;
}
ir.Expression visitUnresolvedTopLevelSetterPostfix(Send node,
MethodElement getter, Element element, IncDecOperator operator, _) {
var accessor = new TopLevelStaticAccessor(
this, getter.name, possiblyErroneousFunctionToIr(getter), null);
- return accessor.buildPostfixIncrement(new ir.Name(operator.selectorName),
+ var result = accessor.buildPostfixIncrement(
+ new ir.Name(operator.selectorName),
voidContext: isVoidContext);
+ associateCompoundComponents(accessor, node);
+ return result;
}
ir.Expression visitUnresolvedTopLevelSetterPrefix(Send node,
MethodElement getter, Element element, IncDecOperator operator, _) {
var accessor = new TopLevelStaticAccessor(
this, getter.name, possiblyErroneousFunctionToIr(getter), null);
- return accessor.buildPrefixIncrement(new ir.Name(operator.selectorName),
+ var result = accessor.buildPrefixIncrement(
+ new ir.Name(operator.selectorName),
voidContext: isVoidContext);
+ associateCompoundComponents(accessor, node);
+ return result;
}
ir.Expression visitUnresolvedTopLevelSetterSetIfNull(
diff --git a/pkg/compiler/lib/src/mirrors_used.dart b/pkg/compiler/lib/src/mirrors_used.dart
index dde7af1..34a81a5 100644
--- a/pkg/compiler/lib/src/mirrors_used.dart
+++ b/pkg/compiler/lib/src/mirrors_used.dart
@@ -116,7 +116,7 @@
(librariesWithUsage != null && librariesWithUsage.contains(library));
}
- /// Call-back from the resolver to analyze MirorsUsed annotations. The result
+ /// Call-back from the resolver to analyze MirrorsUsed annotations. The result
/// is stored in [analyzer] and later used to compute
/// [:analyzer.mergedMirrorUsage:].
void validate(NewExpression node, TreeElements mapping) {
@@ -260,7 +260,7 @@
return result;
}
- /// Merge all [MirrorUsage] instances accross all libraries.
+ /// Merge all [MirrorUsage] instances across all libraries.
MirrorUsage mergeUsages(Map<LibraryElement, List<MirrorUsage>> usageMap) {
Set<MirrorUsage> usagesToMerge = new Set<MirrorUsage>();
usageMap.forEach((LibraryElement library, List<MirrorUsage> usages) {
diff --git a/pkg/compiler/lib/src/parser/parser.dart b/pkg/compiler/lib/src/parser/parser.dart
index 988cbf3..0ef9cb8 100644
--- a/pkg/compiler/lib/src/parser/parser.dart
+++ b/pkg/compiler/lib/src/parser/parser.dart
@@ -426,6 +426,15 @@
Token parseFormalParameter(Token token, FormalParameterType type) {
token = parseMetadataStar(token, forParameter: true);
listener.beginFormalParameter(token);
+
+ // Skip over `covariant` token, if the next token is an identifier or
+ // modifier.
+ // This enables the case where `covariant` is the name of the parameter:
+ // void foo(covariant);
+ if (identical(token.stringValue, 'covariant') &&
+ (token.next.isIdentifier() || isModifier(token.next))) {
+ token = token.next;
+ }
token = parseModifiers(token);
// TODO(ahe): Validate that there are formal parameters if void.
token = parseReturnTypeOpt(token);
@@ -988,9 +997,29 @@
return null;
}
+ /// Removes the optional `covariant` token from the modifiers, if there
+ /// is no `static` in the list, and `covariant` is the first modifier.
+ Link<Token> removeOptCovariantTokenIfNotStatic(Link<Token> modifiers) {
+ if (modifiers.isEmpty ||
+ !identical(modifiers.first.stringValue, 'covariant')) {
+ return modifiers;
+ }
+ for (Token modifier in modifiers.tail) {
+ if (identical(modifier.stringValue, 'static')) {
+ return modifiers;
+ }
+ }
+ return modifiers.tail;
+ }
+
Token parseFields(Token start, Link<Token> modifiers, Token type,
Token getOrSet, Token name, bool isTopLevel) {
bool hasType = type != null;
+
+ if (getOrSet == null && !isTopLevel) {
+ modifiers = removeOptCovariantTokenIfNotStatic(modifiers);
+ }
+
Token varFinalOrConst =
expectVarFinalOrConst(modifiers, hasType, !isTopLevel);
bool isVar = false;
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index d978338..aab6519 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -1235,7 +1235,7 @@
@override
void visitTypeLiteral(ir.TypeLiteral typeLiteral) {
ir.DartType type = typeLiteral.type;
- if (type is ir.InterfaceType) {
+ if (type is ir.InterfaceType || type is ir.DynamicType) {
ConstantValue constant = astAdapter.getConstantForType(type);
stack.add(graph.addConstant(constant, closedWorld));
return;
@@ -1253,7 +1253,7 @@
astAdapter.createRuntimeTypeReturnType);
return;
}
- // TODO(27394): 'dynamic' and function types observed. Where are they from?
+ // TODO(27394): Function types observed. Where are they from?
defaultExpression(typeLiteral);
return;
}
@@ -2214,6 +2214,21 @@
}
@override
+ void visitRethrow(ir.Rethrow rethrowNode) {
+ HInstruction exception = rethrowableException;
+ if (exception == null) {
+ exception = graph.addConstantNull(closedWorld);
+ compiler.reporter.internalError(astAdapter.getNode(rethrowNode),
+ 'rethrowableException should not be null.');
+ }
+ SourceInformation sourceInformation = null;
+ closeAndGotoExit(new HThrow(exception, sourceInformation, isRethrow: true));
+ // ir.Rethrow is an expression so we need to push a value - a constant with
+ // no type.
+ stack.add(graph.addConstantUnreachable(closedWorld));
+ }
+
+ @override
void visitThisExpression(ir.ThisExpression thisExpression) {
stack.add(localsHandler.readThis());
}
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index 2ce5fac..1852bce 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -271,6 +271,15 @@
return addConstant(closedWorld.constantSystem.createNull(), closedWorld);
}
+ HConstant addConstantUnreachable(ClosedWorld closedWorld) {
+ // A constant with an empty type used as the HInstruction of an expression
+ // in an unreachable context.
+ return addConstant(
+ new SyntheticConstantValue(
+ SyntheticConstantKind.EMPTY_VALUE, const TypeMask.nonNullEmpty()),
+ closedWorld);
+ }
+
void finalize() {
addBlock(exit);
exit.open();
diff --git a/pkg/compiler/lib/src/tokens/keyword.dart b/pkg/compiler/lib/src/tokens/keyword.dart
index 4d914bc..607c4e8 100644
--- a/pkg/compiler/lib/src/tokens/keyword.dart
+++ b/pkg/compiler/lib/src/tokens/keyword.dart
@@ -53,6 +53,7 @@
const Keyword("abstract", isBuiltIn: true),
const Keyword("as", info: Precedence.AS_INFO, isBuiltIn: true),
+ const Keyword("covariant", isBuiltIn: true),
const Keyword("dynamic", isBuiltIn: true),
const Keyword("export", isBuiltIn: true),
const Keyword("external", isBuiltIn: true),
@@ -77,7 +78,7 @@
const Keyword("async", isPseudo: true),
const Keyword("sync", isPseudo: true),
const Keyword("await", isPseudo: true),
- const Keyword("yield", isPseudo: true)
+ const Keyword("yield", isPseudo: true),
];
final String syntax;
diff --git a/pkg/dev_compiler/USAGE.md b/pkg/dev_compiler/USAGE.md
index 9a3de65..dcdce9a 100644
--- a/pkg/dev_compiler/USAGE.md
+++ b/pkg/dev_compiler/USAGE.md
@@ -1,81 +1,84 @@
# Usage
-The [Dart Dev Compiler](README.md) (DDC) is an **experimental**
-development compiler from Dart to EcmaScript 6. It is
-still incomplete, under heavy development, and not yet ready for
-production use.
+The [Dart Dev Compiler](README.md) (DDC) is an **experimental** development
+compiler from Dart to EcmaScript 6. It is still incomplete, under heavy
+development, and not yet ready for production use.
With those caveats, we welcome feedback for those experimenting.
-The easiest way to compile and run DDC generated code for now is via NodeJS. The following instructions are in a state of flux - please expect them to change. If you find issues, please let us know.
+The easiest way to compile and run DDC generated code for now is via NodeJS.
+The following instructions are in a state of flux -- please expect them to
+change. If you find issues, please let us know.
-(1) Clone the [DDC repository](https://github.com/dart-lang/dev_compiler) and set the environment variable DDC_PATH to your checkout.
+1. Clone the [DDC repository](https://github.com/dart-lang/sdk) and
+ set the environment variable `DDC_PATH` to the `pkg/dev_compiler`
+ subdirectory within wherever you check that out.
-(2) Install nodejs v6.0 or later and add it to your path. It can be installed from:
+2. Install nodejs v6.0 or later and add it to your path. It can be installed
+ from:
-https://nodejs.org/
+ https://nodejs.org/
-Note, v6 or later is required for harmony / ES6 support.
+ Note, v6 or later is required for harmony / ES6 support.
-(3) Create a node compatible version of the dart_sdk:
+3. Define a node path (you can add other directories if you want to separate
+ things out):
-```
-dart $DDC_PATH/tool/build_sdk.dart --dart-sdk $DDC_PATH/gen/patched_sdk/ --modules node -o dart_sdk.js
-```
+ ```sh
+ export NODE_PATH=$DDC_PATH/lib/js/common:.
+ ```
-You can ignore any errors or warnings for now.
+4. Compile a test file with a `main` entry point:
-(4) Define a node path (you can add other directories if you want to separate things out):
+ ```sh
+ dart $DDC_PATH/bin/dartdevc.dart --modules node -o hello.js hello.dart
+ ```
-```
-export NODE_PATH=.
-```
+ Note, the `hello.js` built here is not fully linked. It loads the SDK via a `require` call.
-(5) Compile a test file with a `main` entry point:
+5. Run it via your node built in step 1:
-```
-dart $DDC_PATH/bin/dartdevc.dart --modules node -o hello.js hello.dart
-```
+ ```sh
+ node -e 'require("hello").hello.main()'
+ ```
-Note, the `hello.js` built here is not fully linked. It loads the SDK via a `require` call.
+6. Compile multiple libraries using summaries. E.g., write a `world.dart` that
+ imports `hello.dart` with it's own `main`. Step 5 above generated a summary
+ (`hello.sum`) for `hello.dart`. Build world:
-(6) Run it via your node built in step 1:
+ ```sh
+ dart $DDC_PATH/bin/dartdevc.dart --modules node -s hello.sum -o world.js world.dart
+ ```
-```
-node -e 'require("hello").hello.main()'
-```
+ Run world just like hello above:
-(7) Compile multiple libraries using summaries. E.g., write a `world.dart` that imports `hello.dart` with it's own `main`. Step 5 above generated a summary (`hello.sum`) for `hello.dart`. Build world:
+ ```sh
+ node -e 'require("world").world.main()'
+ ```
-```
-dart $DDC_PATH/bin/dartdevc.dart --modules node -s hello.sum -o world.js world.dart
-```
+7. Node modules do not run directly on the browser or v8. You can use a tool
+ like `browserify` to build a linked javascript file that can:
-Run world just like hello above:
+ Install:
-```
-node -e 'require("world").world.main()'
-```
+ ```sh
+ sudo npm install -g browserify
+ ```
-(8) Node modules do not run directly on the browser or v8. You can use a tool like `browserify` to build a linked javascript file that can:
+ and run, e.g.,:
-Install:
-```
-sudo npm install -g browserify
-```
+ ```sh
+ echo 'require("world").world.main()' | browserify -d - > world.dart.js
+ ```
-and run, e.g.,:
-```
-echo 'require("world").world.main()' | browserify -d - > world.dart.js
-```
-
-The produced `world.dart.js` fully links all dependencies (`dart_sdk`, `hello`, and `world`) and executes `world.main`. It can be loaded via script tag and run in Chrome (stable or later).
+ The produced `world.dart.js` fully links all dependencies (`dart_sdk`,
+ `hello`, and `world`) and executes `world.main`. It can be loaded via
+ script tag and run in Chrome (stable or later).
## Feedback
-Please file issues in our [GitHub issue tracker](https://github.com/dart-lang/sdk/issues).
+Please file issues in our [GitHub issue
+tracker](https://github.com/dart-lang/sdk/issues).
-You can also view or join our [mailing list](https://groups.google.com/a/dartlang.org/forum/#!forum/dev-compiler).
-
-
-
+You can also view or join our [mailing
+list](https://groups.google.com/a/dartlang.org/forum/#!forum/dev-compiler).
diff --git a/pkg/dev_compiler/lib/js/amd/dart_sdk.js b/pkg/dev_compiler/lib/js/amd/dart_sdk.js
index 9d6ddd8..ebd0c84 100644
--- a/pkg/dev_compiler/lib/js/amd/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/amd/dart_sdk.js
@@ -1687,36 +1687,47 @@
}
return true;
};
+ dart.trapRuntimeErrors = function(flag) {
+ dart._trapRuntimeErrors = flag;
+ };
dart.throwCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.CastErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.CastErrorImplementation(object, found, expected));
};
dart.throwTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.TypeErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.TypeErrorImplementation(object, found, expected));
};
dart.throwStrongModeCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeCastError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeCastError(object, found, expected));
};
dart.throwStrongModeTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeTypeError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeTypeError(object, found, expected));
};
dart.throwUnimplementedError = function(message) {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.UnimplementedError(message));
};
dart.throwAssertionError = function(message) {
if (message === void 0) message = null;
return (() => {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
let error = message != null ? new _js_helper.AssertionErrorWithMessage(message()) : new core.AssertionError();
dart.throw(error);
})();
};
dart.throwNullValueError = function() {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.NoSuchMethodError(null, new core.Symbol('<Unexpected Null Value>'), null, null, null));
};
dart.syncStar = function(gen, E, ...args) {
@@ -2248,11 +2259,11 @@
return Object.getOwnPropertySymbols(obj);
};
dart.throwStrongModeError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw new _js_helper.StrongModeErrorImplementation(message);
};
dart.throwInternalError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw Error(message);
};
dart.getOwnNamesAndSymbols = function(obj) {
@@ -2663,6 +2674,7 @@
};
dart._typeFormalCount = Symbol("_typeFormalCount");
dart.isSubtype = dart._subtypeMemo((t1, t2) => t1 === t2 || dart._isSubtype(t1, t2, true));
+ dart._trapRuntimeErrors = true;
dart._jsIterator = Symbol("_jsIterator");
dart._current = Symbol("_current");
dart._AsyncStarStreamController = class _AsyncStarStreamController {
@@ -45196,7 +45208,7 @@
return r;
}
};
- dart.setBaseClass(io._HttpConnection, collection.LinkedListEntry$(io._HttpConnection));
+ dart.setBaseClass(io._HttpConnection, dart.mixin(collection.LinkedListEntry$(io._HttpConnection), io._ServiceObject));
dart.addSimpleTypeTests(io._HttpConnection);
dart.setSignature(io._HttpConnection, {
constructors: () => ({new: dart.definiteFunctionType(io._HttpConnection, [dart.dynamic, io._HttpServer])}),
diff --git a/pkg/dev_compiler/lib/js/common/dart_sdk.js b/pkg/dev_compiler/lib/js/common/dart_sdk.js
index 2b4c910..822f847 100644
--- a/pkg/dev_compiler/lib/js/common/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/common/dart_sdk.js
@@ -1687,36 +1687,47 @@
}
return true;
};
+ dart.trapRuntimeErrors = function(flag) {
+ dart._trapRuntimeErrors = flag;
+ };
dart.throwCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.CastErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.CastErrorImplementation(object, found, expected));
};
dart.throwTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.TypeErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.TypeErrorImplementation(object, found, expected));
};
dart.throwStrongModeCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeCastError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeCastError(object, found, expected));
};
dart.throwStrongModeTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeTypeError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeTypeError(object, found, expected));
};
dart.throwUnimplementedError = function(message) {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.UnimplementedError(message));
};
dart.throwAssertionError = function(message) {
if (message === void 0) message = null;
return (() => {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
let error = message != null ? new _js_helper.AssertionErrorWithMessage(message()) : new core.AssertionError();
dart.throw(error);
})();
};
dart.throwNullValueError = function() {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.NoSuchMethodError(null, new core.Symbol('<Unexpected Null Value>'), null, null, null));
};
dart.syncStar = function(gen, E, ...args) {
@@ -2248,11 +2259,11 @@
return Object.getOwnPropertySymbols(obj);
};
dart.throwStrongModeError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw new _js_helper.StrongModeErrorImplementation(message);
};
dart.throwInternalError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw Error(message);
};
dart.getOwnNamesAndSymbols = function(obj) {
@@ -2663,6 +2674,7 @@
};
dart._typeFormalCount = Symbol("_typeFormalCount");
dart.isSubtype = dart._subtypeMemo((t1, t2) => t1 === t2 || dart._isSubtype(t1, t2, true));
+ dart._trapRuntimeErrors = true;
dart._jsIterator = Symbol("_jsIterator");
dart._current = Symbol("_current");
dart._AsyncStarStreamController = class _AsyncStarStreamController {
@@ -45196,7 +45208,7 @@
return r;
}
};
- dart.setBaseClass(io._HttpConnection, collection.LinkedListEntry$(io._HttpConnection));
+ dart.setBaseClass(io._HttpConnection, dart.mixin(collection.LinkedListEntry$(io._HttpConnection), io._ServiceObject));
dart.addSimpleTypeTests(io._HttpConnection);
dart.setSignature(io._HttpConnection, {
constructors: () => ({new: dart.definiteFunctionType(io._HttpConnection, [dart.dynamic, io._HttpServer])}),
diff --git a/pkg/dev_compiler/lib/js/es6/dart_sdk.js b/pkg/dev_compiler/lib/js/es6/dart_sdk.js
index 10c4a9a..30fa1b5 100644
--- a/pkg/dev_compiler/lib/js/es6/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/es6/dart_sdk.js
@@ -1685,36 +1685,47 @@
}
return true;
};
+dart.trapRuntimeErrors = function(flag) {
+ dart._trapRuntimeErrors = flag;
+};
dart.throwCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.CastErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.CastErrorImplementation(object, found, expected));
};
dart.throwTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.TypeErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.TypeErrorImplementation(object, found, expected));
};
dart.throwStrongModeCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeCastError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeCastError(object, found, expected));
};
dart.throwStrongModeTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeTypeError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeTypeError(object, found, expected));
};
dart.throwUnimplementedError = function(message) {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.UnimplementedError(message));
};
dart.throwAssertionError = function(message) {
if (message === void 0) message = null;
return (() => {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
let error = message != null ? new _js_helper.AssertionErrorWithMessage(message()) : new core.AssertionError();
dart.throw(error);
})();
};
dart.throwNullValueError = function() {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.NoSuchMethodError(null, new core.Symbol('<Unexpected Null Value>'), null, null, null));
};
dart.syncStar = function(gen, E, ...args) {
@@ -2246,11 +2257,11 @@
return Object.getOwnPropertySymbols(obj);
};
dart.throwStrongModeError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw new _js_helper.StrongModeErrorImplementation(message);
};
dart.throwInternalError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw Error(message);
};
dart.getOwnNamesAndSymbols = function(obj) {
@@ -2661,6 +2672,7 @@
};
dart._typeFormalCount = Symbol("_typeFormalCount");
dart.isSubtype = dart._subtypeMemo((t1, t2) => t1 === t2 || dart._isSubtype(t1, t2, true));
+dart._trapRuntimeErrors = true;
dart._jsIterator = Symbol("_jsIterator");
dart._current = Symbol("_current");
dart._AsyncStarStreamController = class _AsyncStarStreamController {
@@ -45194,7 +45206,7 @@
return r;
}
};
-dart.setBaseClass(io._HttpConnection, collection.LinkedListEntry$(io._HttpConnection));
+dart.setBaseClass(io._HttpConnection, dart.mixin(collection.LinkedListEntry$(io._HttpConnection), io._ServiceObject));
dart.addSimpleTypeTests(io._HttpConnection);
dart.setSignature(io._HttpConnection, {
constructors: () => ({new: dart.definiteFunctionType(io._HttpConnection, [dart.dynamic, io._HttpServer])}),
diff --git a/pkg/dev_compiler/lib/js/legacy/dart_library.js b/pkg/dev_compiler/lib/js/legacy/dart_library.js
index d8dfd96..f72cf9e 100644
--- a/pkg/dev_compiler/lib/js/legacy/dart_library.js
+++ b/pkg/dev_compiler/lib/js/legacy/dart_library.js
@@ -125,13 +125,15 @@
// Force import of core.
var dart_sdk = import_('dart_sdk');
- // TODO(vsm): DOM facades?
- // See: https://github.com/dart-lang/dev_compiler/issues/173
+ // TODO(vsm): Move this to a shared location:
+ // https://github.com/dart-lang/sdk/issues/27605
if (typeof NodeList !== "undefined") {
+ // TODO(vsm): Do we still need these?
NodeList.prototype.get = function(i) { return this[i]; };
NamedNodeMap.prototype.get = function(i) { return this[i]; };
DOMTokenList.prototype.get = function(i) { return this[i]; };
HTMLCollection.prototype.get = function(i) { return this[i]; };
+
// Expose constructors for DOM types dart:html needs to assume are
// available on window.
if (typeof PannerNode == "undefined") {
diff --git a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
index 7820c1b..751f1e8 100644
--- a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
@@ -1688,36 +1688,47 @@
}
return true;
};
+ dart.trapRuntimeErrors = function(flag) {
+ dart._trapRuntimeErrors = flag;
+ };
dart.throwCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.CastErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.CastErrorImplementation(object, found, expected));
};
dart.throwTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.TypeErrorImplementation(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.TypeErrorImplementation(object, found, expected));
};
dart.throwStrongModeCastError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeCastError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeCastError(object, found, expected));
};
dart.throwStrongModeTypeError = function(object, actual, type) {
- debugger;
- dart.throw(new _js_helper.StrongModeTypeError(object, dart.typeName(actual), dart.typeName(type)));
+ var found = dart.typeName(actual);
+ var expected = dart.typeName(type);
+ if (dart._trapRuntimeErrors) debugger;
+ dart.throw(new _js_helper.StrongModeTypeError(object, found, expected));
};
dart.throwUnimplementedError = function(message) {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.UnimplementedError(message));
};
dart.throwAssertionError = function(message) {
if (message === void 0) message = null;
return (() => {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
let error = message != null ? new _js_helper.AssertionErrorWithMessage(message()) : new core.AssertionError();
dart.throw(error);
})();
};
dart.throwNullValueError = function() {
- debugger;
+ if (dart._trapRuntimeErrors) debugger;
dart.throw(new core.NoSuchMethodError(null, new core.Symbol('<Unexpected Null Value>'), null, null, null));
};
dart.syncStar = function(gen, E, ...args) {
@@ -2249,11 +2260,11 @@
return Object.getOwnPropertySymbols(obj);
};
dart.throwStrongModeError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw new _js_helper.StrongModeErrorImplementation(message);
};
dart.throwInternalError = function(message) {
- debugger;
+ if (dart.test(dart._trapRuntimeErrors)) debugger;
throw Error(message);
};
dart.getOwnNamesAndSymbols = function(obj) {
@@ -2664,6 +2675,7 @@
};
dart._typeFormalCount = Symbol("_typeFormalCount");
dart.isSubtype = dart._subtypeMemo((t1, t2) => t1 === t2 || dart._isSubtype(t1, t2, true));
+ dart._trapRuntimeErrors = true;
dart._jsIterator = Symbol("_jsIterator");
dart._current = Symbol("_current");
dart._AsyncStarStreamController = class _AsyncStarStreamController {
@@ -45197,7 +45209,7 @@
return r;
}
};
- dart.setBaseClass(io._HttpConnection, collection.LinkedListEntry$(io._HttpConnection));
+ dart.setBaseClass(io._HttpConnection, dart.mixin(collection.LinkedListEntry$(io._HttpConnection), io._ServiceObject));
dart.addSimpleTypeTests(io._HttpConnection);
dart.setSignature(io._HttpConnection, {
constructors: () => ({new: dart.definiteFunctionType(io._HttpConnection, [dart.dynamic, io._HttpServer])}),
diff --git a/pkg/dev_compiler/lib/sdk/ddc_sdk.sum b/pkg/dev_compiler/lib/sdk/ddc_sdk.sum
index 073b986..670fd6f 100644
--- a/pkg/dev_compiler/lib/sdk/ddc_sdk.sum
+++ b/pkg/dev_compiler/lib/sdk/ddc_sdk.sum
Binary files differ
diff --git a/pkg/dev_compiler/lib/src/compiler/ast_builder.dart b/pkg/dev_compiler/lib/src/compiler/ast_builder.dart
index 46c57b1..2cbfdbf 100644
--- a/pkg/dev_compiler/lib/src/compiler/ast_builder.dart
+++ b/pkg/dev_compiler/lib/src/compiler/ast_builder.dart
@@ -35,7 +35,7 @@
return RawAstBuilder.typeParameterList(params);
}
- static TypeArgumentList typeArgumentList(List<TypeName> args) {
+ static TypeArgumentList typeArgumentList(List<TypeAnnotation> args) {
return RawAstBuilder.typeArgumentList(args);
}
@@ -43,7 +43,7 @@
return RawAstBuilder.argumentList(args);
}
- static TypeName typeName(Identifier id, List<TypeName> args) {
+ static TypeName typeName(Identifier id, List<TypeAnnotation> args) {
TypeArgumentList argList = null;
if (args != null && args.length > 0) argList = typeArgumentList(args);
return RawAstBuilder.typeName(id, argList);
@@ -411,7 +411,7 @@
return astFactory.typeParameterList(lb, params, rb);
}
- static TypeArgumentList typeArgumentList(List<TypeName> args) {
+ static TypeArgumentList typeArgumentList(List<TypeAnnotation> args) {
Token lb = new Token(TokenType.LT, 0);
Token rb = new Token(TokenType.GT, 0);
return astFactory.typeArgumentList(lb, args, rb);
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index d406907..afabcf3 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -1248,24 +1248,25 @@
_loader.startTopLevel(element);
- // Find the super type
- JS.Expression heritage;
- var supertype = type.superclass;
- if (_deferIfNeeded(supertype, element)) {
- // Fall back to raw type.
- supertype = fillDynamicTypeArgs(supertype.element.type);
+ // List of "direct" supertypes (supertype + mixins)
+ var basetypes = [type.superclass]..addAll(type.mixins);
+
+ // If any of these are recursive (via type parameter), defer setting
+ // the real superclass.
+ if (basetypes.any((t) => _deferIfNeeded(t, element))) {
+ // Fall back to raw type
+ basetypes =
+ basetypes.map((t) => fillDynamicTypeArgs(t.element.type)).toList();
_hasDeferredSupertype.add(element);
}
- // We could choose to name the superclasses, but it's
- // not clear that there's much benefit
- heritage = _emitType(supertype, nameType: false);
- if (type.mixins.isNotEmpty) {
- var mixins =
- type.mixins.map((t) => _emitType(t, nameType: false)).toList();
- mixins.insert(0, heritage);
- heritage = _callHelper('mixin(#)', [mixins]);
- }
+ // List of "direct" JS superclasses
+ var baseclasses =
+ basetypes.map((t) => _emitType(t, nameType: false)).toList();
+ assert(baseclasses.isNotEmpty);
+ var heritage = (baseclasses.length == 1)
+ ? baseclasses.first
+ : _callHelper('mixin(#)', [baseclasses]);
_loader.finishTopLevel(element);
@@ -1331,7 +1332,7 @@
// bypass the ES6 restrictions.
//
// TODO(jmesserly): we'll need to rethink this.
- // See <https://github.com/dart-lang/dev_compiler/issues/51>.
+ // See https://github.com/dart-lang/sdk/issues/28322.
// This level of indirection will hurt performance.
jsMethods.add(new JS.Method(
_propertyName('constructor'),
@@ -1682,8 +1683,17 @@
'setExtensionBaseClass(#, #);', [className, newBaseClass]));
}
} else if (_hasDeferredSupertype.contains(classElem)) {
+ // TODO(vsm): consider just threading the deferred supertype through
+ // instead of recording classElem in a set on the class and recomputing
var newBaseClass = _emitType(classElem.type.superclass,
nameType: false, subClass: classElem, className: className);
+ if (classElem.type.mixins.isNotEmpty) {
+ var mixins = classElem.type.mixins
+ .map((t) => _emitType(t, nameType: false))
+ .toList();
+ mixins.insert(0, newBaseClass);
+ newBaseClass = _callHelper('mixin(#)', [mixins]);
+ }
var deferredBaseClass = _callHelperStatement(
'setBaseClass(#, #);', [className, newBaseClass]);
if (typeFormals.isNotEmpty) return deferredBaseClass;
@@ -2293,7 +2303,7 @@
}
// TODO(jmesserly): various problems here, see:
- // https://github.com/dart-lang/dev_compiler/issues/116
+ // https://github.com/dart-lang/sdk/issues/27259
var paramType =
resolutionMap.elementDeclaredByFormalParameter(param).type;
if (node is MethodDeclaration &&
@@ -2648,8 +2658,7 @@
// are not mutated inside the generator.
//
// In the future, we might be able to simplify this, see:
- // https://github.com/dart-lang/dev_compiler/issues/247.
- //
+ // https://github.com/dart-lang/sdk/issues/28320
// `async` works the same, but uses the `dart.async` helper.
//
// In the body of a `sync*` and `async`, `yield`/`await` are both generated
@@ -2956,8 +2965,8 @@
var typeFormals = type.typeFormals;
if (typeFormals.isNotEmpty && !lowerTypedef) {
// TODO(jmesserly): this is a suboptimal representation for universal
- // function types (as callable functions). See discussion at:
- // https://github.com/dart-lang/dev_compiler/issues/526
+ // function types (as callable functions). See discussion at
+ // https://github.com/dart-lang/sdk/issues/27333
var tf = _emitTypeFormals(typeFormals);
var names = _typeTable.discharge(typeFormals);
var parts = new JS.ArrayInitializer(typeParts);
@@ -3615,7 +3624,15 @@
} else if (typeArgs != null) {
// Dynamic calls may have type arguments, even though the function types
// are not known.
- return typeArgs.arguments.map(visitTypeName).toList(growable: false);
+ return typeArgs.arguments.map((argument) {
+ if (argument is TypeName) {
+ return visitTypeName(argument);
+ } else {
+ // TODO(brianwilkerson) Implement support for GenericFunctionType.
+ throw new StateError(
+ 'Cannot compile type argument of kind ${argument.runtimeType}');
+ }
+ }).toList(growable: false);
}
return null;
}
@@ -5643,7 +5660,6 @@
expectedType = types.streamType;
} else {
// Future<T> -> T
- // TODO(vsm): Revisit with issue #228.
expectedType = types.futureType;
}
} else {
diff --git a/pkg/dev_compiler/lib/src/compiler/js_metalet.dart b/pkg/dev_compiler/lib/src/compiler/js_metalet.dart
index 3645dc1..3947884 100644
--- a/pkg/dev_compiler/lib/src/compiler/js_metalet.dart
+++ b/pkg/dev_compiler/lib/src/compiler/js_metalet.dart
@@ -350,6 +350,7 @@
@override
visitYield(Yield node) {
if (!_nestedFunction) hasYield = true;
+ super.visitYield(node);
}
@override
diff --git a/pkg/dev_compiler/lib/src/compiler/module_builder.dart b/pkg/dev_compiler/lib/src/compiler/module_builder.dart
index d321bd0..415554a 100644
--- a/pkg/dev_compiler/lib/src/compiler/module_builder.dart
+++ b/pkg/dev_compiler/lib/src/compiler/module_builder.dart
@@ -238,7 +238,7 @@
}
}
- // TODO(vsm): See https://github.com/dart-lang/dev_compiler/issues/512
+ // TODO(vsm): See https://github.com/dart-lang/sdk/issues/27309
// This extra level of indirection should be unnecessary.
var block =
js.statement("(function() { 'use strict'; #; })()", [statements]);
diff --git a/pkg/dev_compiler/test/browser/language_tests.js b/pkg/dev_compiler/test/browser/language_tests.js
index 593b3a0..4e1a6ad 100644
--- a/pkg/dev_compiler/test/browser/language_tests.js
+++ b/pkg/dev_compiler/test/browser/language_tests.js
@@ -9,6 +9,7 @@
async_helper = async_helper.async_helper;
let minitest = expect.minitest;
+ dart_sdk.dart.trapRuntimeErrors(false);
dart_sdk._isolate_helper.startRootIsolate(function() {}, []);
let html_config = unittest.html_config;
// Test attributes are a list of strings, or a string for a single
@@ -51,7 +52,10 @@
'assertion_test': skip_fail,
'async_await_test_none_multi': 'unittest',
'async_await_test_02_multi': 'unittest',
- 'async_await_test_03_multi': skip_fail, // Flaky on travis (#634)
+
+ // Flaky on travis (https://github.com/dart-lang/sdk/issues/27224)
+ 'async_await_test_03_multi': skip_fail,
+
'async_star_await_pauses_test': skip_fail,
// TODO(jmesserly): figure out why this test is hanging.
@@ -60,8 +64,7 @@
'async_star_cancel_while_paused_test': skip_fail,
'async_star_regression_fisk_test': skip_fail,
- // TODO(vsm): Re-enable.
- // See https://github.com/dart-lang/dev_compiler/issues/456
+ // TODO(vsm): Re-enable (https://github.com/dart-lang/sdk/issues/28319)
'async_star_test_none_multi': ['unittest', 'skip', 'fail'],
'async_star_test_01_multi': ['unittest', 'skip', 'fail'],
'async_star_test_02_multi': ['unittest', 'skip', 'fail'],
@@ -94,9 +97,6 @@
'cha_deopt1_test': skip_fail,
'cha_deopt2_test': skip_fail,
'cha_deopt3_test': skip_fail,
-
- // interpolation does not call Dart's toString:
- // https://github.com/dart-lang/dev_compiler/issues/470
'class_syntax2_test': skip_fail,
'classes_static_method_clash_test': skip_fail,
'closure_call_wrong_argument_count_negative_test': skip_fail,
@@ -117,6 +117,7 @@
'const_switch_test_04_multi': skip_fail,
'constructor11_test': skip_fail,
'constructor12_test': skip_fail,
+ 'custom_await_stack_trace_test': skip_fail,
'cyclic_type2_test': skip_fail,
'cyclic_type_test_00_multi': skip_fail,
'cyclic_type_test_01_multi': skip_fail,
@@ -151,6 +152,8 @@
'field_optimization3_test': skip_fail,
'final_syntax_test_08_multi': skip_fail,
'first_class_types_test': skip_fail,
+ 'flatten_test_01_multi': skip_fail,
+ 'flatten_test_04_multi': skip_fail,
'for_in2_test': skip_fail,
'for_variable_capture_test': skip_fail,
'function_subtype0_test': skip_fail,
@@ -223,6 +226,7 @@
'issue13179_test': skip_fail,
'issue21079_test': skip_fail,
'issue21957_test': skip_fail,
+ 'issue23244_test': skip_fail,
'issue_1751477_test': skip_fail,
'issue_22780_test_01_multi': skip_fail,
'issue_23914_test': skip_fail,
@@ -241,6 +245,7 @@
'mixin_forwarding_constructor3_test': skip_fail,
'mixin_generic_test': skip_fail,
'mixin_implements_test': skip_fail,
+ 'mixin_invalid_inheritance1_test_none_multi': skip_fail,
'mixin_issue10216_2_test': skip_fail,
'mixin_mixin2_test': skip_fail,
'mixin_mixin3_test': skip_fail,
@@ -406,10 +411,6 @@
'lib/convert': {
'encoding_test': skip_timeout,
- // TODO(jmesserly): this is in an inconsistent state between our old and
- // newer SDKs.
- 'html_escape_test': ['skip'],
-
'json_utf8_chunk_test': skip_timeout,
'latin1_test': skip_timeout,
@@ -424,7 +425,10 @@
'lib/html': {
'async_spawnuri_test': async_unittest,
'async_test': async_unittest,
- 'audiocontext_test': is.chrome('<=54') ? fail : pass, // was sdk#27578, needs triage
+
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'audiocontext_test': is.chrome('<=54') ? fail : pass,
+
'canvas_test': ['unittest'],
'canvasrenderingcontext2d_test': ['unittest'],
'cross_domain_iframe_test': async_unittest,
@@ -434,17 +438,24 @@
// This is failing with a range error, I'm guessing because it's looking
// for a stylesheet and the page has none.
'css_rule_list_test': 'fail',
+
'custom_element_method_clash_test': async_unittest,
'custom_element_name_clash_test': async_unittest,
'custom_elements_23127_test': async_unittest,
'custom_elements_test': async_unittest,
- 'dom_constructors_test': 'fail', // was sdk#27578, needs triage
+
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'dom_constructors_test': 'fail',
+
'element_animate_test': async_unittest,
- 'element_classes_test': 'fail', // sdk#27579.
- 'element_classes_svg_test': 'fail', // sdk#27579.
+
+ // https://github.com/dart-lang/sdk/issues/27579.
+ 'element_classes_test': 'fail',
+ 'element_classes_svg_test': 'fail',
// Failure: 'Expected 56 to be in the inclusive range [111, 160].'.
'element_offset_test': 'fail',
+
'element_test': async_unittest,
'element_types_test': firefox_fail,
'event_customevent_test': async_unittest,
@@ -453,12 +464,14 @@
// Failure: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter
// 1 is not of type 'Event'."
'event_test': 'fail',
+
'fileapi_test': async_unittest,
'filereader_test': async_unittest,
'fontface_loaded_test': async_unittest,
// Failed because it's expecting "Ahem" but getting null. Maybe sdk#27579?
'fontface_test': 'fail',
+
'form_data_test': async_unittest,
'history_test': async_unittest,
'indexeddb_1_test': async_unittest,
@@ -466,7 +479,10 @@
'indexeddb_3_test': async_unittest,
'indexeddb_4_test': async_unittest,
'indexeddb_5_test': async_unittest,
- 'input_element_test': 'fail', // was sdk#27578, needs triage
+
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'input_element_test': 'fail',
+
'interactive_test': async_unittest,
'isolates_test': async_unittest,
@@ -479,29 +495,41 @@
'js_util_test': 'fail',
'keyboard_event_test': async_unittest,
- 'mediasource_test': 'fail', // was sdk#27578, needs triage
- 'media_stream_test': 'fail', // was sdk#27578, needs triage
- 'messageevent_test': 'fail', // was sdk#27578, needs triage
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'mediasource_test': 'fail',
+ 'media_stream_test': 'fail',
+ 'messageevent_test': 'fail',
// Should throw but does not.
'mirrors_js_typed_interop_test': 'fail',
'mutationobserver_test': async_unittest,
'native_gc_test': async_unittest,
- 'notification_test': 'fail', // was sdk#27578, needs triage
+
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'notification_test': 'fail',
+
'postmessage_structured_test': async_unittest,
'queryall_test': ['slow'], // see sdk #27794
'request_animation_frame_test': async_unittest,
'resource_http_test': async_unittest,
- 'rtc_test': is.chrome('<=55') ? fail : pass, // was sdk#27578, needs triage
+
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'rtc_test': is.chrome('<=55') ? fail : pass,
// Expected 1, got null.
'serialized_script_value_test': 'fail',
+
'shadow_dom_test': firefox_fail,
- 'speechrecognition_test': 'fail', // was sdk#27578, needs triage
- 'svgelement_test': chrome_fail, // was sdk#27578, needs triage
+
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'speechrecognition_test': 'fail',
+ 'svgelement_test': chrome_fail,
'text_event_test': firefox_fail,
- 'touchevent_test': 'fail', // was sdk#27578, needs triage
+
+ // was https://github.com/dart-lang/sdk/issues/27578, needs triage
+ 'touchevent_test': 'fail',
+
'transferables_test': async_unittest,
'transition_event_test': async_unittest,
'url_test': async_unittest,
@@ -666,6 +694,7 @@
'relation_assignable_test': fail,
'relation_subtype_test': fail,
'set_field_with_final_test': fail,
+ 'spawn_function_root_library_test': skip_fail,
'symbol_validation_test_01_multi': fail,
'symbol_validation_test_none_multi': fail,
'to_string_test': fail,
@@ -748,6 +777,7 @@
async_helper.asyncTestInitialize(done);
console.debug('Running test: ' + name);
+ var result = null;
let mainLibrary = require(module)[libraryName(name)];
let negative = /negative_test/.test(name);
if (has('slow')) this.timeout(10000);
@@ -769,7 +799,7 @@
if (negative) {
assert.throws(mainLibrary.main);
} else {
- mainLibrary.main();
+ result = mainLibrary.main();
}
} finally {
minitest.finishTests();
@@ -781,7 +811,13 @@
document.body.innerHTML = '';
console.log("cleared");
- if (!async_helper.asyncTestStarted) done();
+ if (!async_helper.asyncTestStarted) {
+ if (!result) {
+ done();
+ } else {
+ result.then(dart_sdk.dart.dynamic)(() => done());
+ }
+ }
});
}
}
diff --git a/pkg/dev_compiler/test/codegen/js_test.dart b/pkg/dev_compiler/test/codegen/js_test.dart
index 4476801..2c862d0 100644
--- a/pkg/dev_compiler/test/codegen/js_test.dart
+++ b/pkg/dev_compiler/test/codegen/js_test.dart
@@ -447,7 +447,7 @@
var result = context.callMethod('callable');
expect(result, 'called');
context.deleteProperty('callable');
- }, skip: "https://github.com/dart-lang/dev_compiler/issues/244");
+ });
});
diff --git a/pkg/dev_compiler/test/codegen_test.dart b/pkg/dev_compiler/test/codegen_test.dart
index f33df56..4c4446c 100644
--- a/pkg/dev_compiler/test/codegen_test.dart
+++ b/pkg/dev_compiler/test/codegen_test.dart
@@ -79,9 +79,8 @@
.where((p) => p.endsWith('.sum'))
.toList();
- var sharedCompiler = new ModuleCompiler(
- new AnalyzerOptions.basic(
- dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths));
+ var sharedCompiler = new ModuleCompiler(new AnalyzerOptions.basic(
+ dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths));
var testDirs = [
'language',
diff --git a/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart b/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart
index ffeb76a..6d7a5e8 100644
--- a/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart
+++ b/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart
@@ -56,8 +56,8 @@
static apply(Function f,
List positionalArguments,
[Map<Symbol, dynamic> namedArguments]) {
- // TODO(vsm): Handle named args.
- // See: https://github.com/dart-lang/dev_compiler/issues/176
+ // TODO(vsm): Handle named args:
+ // https://github.com/dart-lang/sdk/issues/27257
return JS('', 'dart.dcall.apply(null, [#].concat(#))', f, positionalArguments);
}
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
index 0f8d0b4..49bc1cc 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
@@ -3,41 +3,48 @@
// BSD-style license that can be found in the LICENSE file.
part of dart._runtime;
+bool _trapRuntimeErrors = true;
+
+// Override, e.g., for testing
+void trapRuntimeErrors(bool flag) {
+ _trapRuntimeErrors = flag;
+}
+
throwCastError(object, actual, type) => JS('', '''(() => {
- debugger;
- $throw_(new $CastErrorImplementation($object,
- $typeName($actual),
- $typeName($type)));
+ var found = $typeName($actual);
+ var expected = $typeName($type);
+ if ($_trapRuntimeErrors) debugger;
+ $throw_(new $CastErrorImplementation($object, found, expected));
})()''');
throwTypeError(object, actual, type) => JS('', '''(() => {
- debugger;
- $throw_(new $TypeErrorImplementation($object,
- $typeName($actual),
- $typeName($type)));
+ var found = $typeName($actual);
+ var expected = $typeName($type);
+ if ($_trapRuntimeErrors) debugger;
+ $throw_(new $TypeErrorImplementation($object, found, expected));
})()''');
throwStrongModeCastError(object, actual, type) => JS('', '''(() => {
- debugger;
- $throw_(new $StrongModeCastError($object,
- $typeName($actual),
- $typeName($type)));
+ var found = $typeName($actual);
+ var expected = $typeName($type);
+ if ($_trapRuntimeErrors) debugger;
+ $throw_(new $StrongModeCastError($object, found, expected));
})()''');
throwStrongModeTypeError(object, actual, type) => JS('', '''(() => {
- debugger;
- $throw_(new $StrongModeTypeError($object,
- $typeName($actual),
- $typeName($type)));
+ var found = $typeName($actual);
+ var expected = $typeName($type);
+ if ($_trapRuntimeErrors) debugger;
+ $throw_(new $StrongModeTypeError($object, found, expected));
})()''');
throwUnimplementedError(message) => JS('', '''(() => {
- debugger;
+ if ($_trapRuntimeErrors) debugger;
$throw_(new $UnimplementedError($message));
})()''');
throwAssertionError([message]) => JS('', '''(() => {
- debugger;
+ if ($_trapRuntimeErrors) debugger;
let error = $message != null
? new $AssertionErrorWithMessage($message())
: new $AssertionError();
@@ -48,7 +55,7 @@
// TODO(vsm): Per spec, we should throw an NSM here. Technically, we ought
// to thread through method info, but that uglifies the code and can't
// actually be queried ... it only affects how the error is printed.
- debugger;
+ if ($_trapRuntimeErrors) debugger;
$throw_(new $NoSuchMethodError(null,
new $Symbol('<Unexpected Null Value>'), null, null, null));
})()''');
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart
index b8138d7..a88138b 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/generators.dart
@@ -5,7 +5,7 @@
/// This library adapts ES6 generators to implement Dart's async/await.
/// It's designed to interact with Dart's Future/Stream and follow Dart
/// async/await semantics.
-/// See https://github.com/dart-lang/dev_compiler/issues/245 for ideas on
+/// See https://github.com/dart-lang/sdk/issues/27315 for ideas on
/// reconciling Dart's Future and ES6 Promise.
/// Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a
/// stepping stone for proposed ES7 async/await, and uses ES6 Promises.
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
index cefbefb..629ae6b 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
@@ -761,7 +761,7 @@
}
// TODO(jmesserly): restore this faster path once ES Symbol is treated as
// an extension type (and thus hits the above code path).
- // See https://github.com/dart-lang/dev_compiler/issues/578.
+ // See https://github.com/dart-lang/sdk/issues/28323
// return JS('', '"" + #', obj);
return JS('String', '#.toString()', obj);
}
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart
index a604423..154410e 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/utils.dart
@@ -24,13 +24,13 @@
/// This error indicates a strong mode specific failure, other than a type
/// assertion failure (TypeError) or CastError.
void throwStrongModeError(String message) {
- JS('', 'debugger');
+ if (_trapRuntimeErrors) JS('', 'debugger');
JS('', 'throw new #(#);', StrongModeErrorImplementation, message);
}
/// This error indicates a bug in the runtime or the compiler.
void throwInternalError(String message) {
- JS('', 'debugger');
+ if (_trapRuntimeErrors) JS('', 'debugger');
JS('', 'throw Error(#)', message);
}
@@ -98,7 +98,7 @@
// On native types, Symbol.iterator may already be present.
// TODO(jmesserly): investigate if we still need this.
// If so, we need to find a better solution.
- // See: https://github.com/dart-lang/dev_compiler/issues/487
+ // See https://github.com/dart-lang/sdk/issues/28324
var existing = getOwnPropertyDescriptor(to, name);
if (existing != null) {
if (JS('bool', '#.writable', existing)) {
diff --git a/pkg/dev_compiler/tool/input_sdk/private/interceptors.dart b/pkg/dev_compiler/tool/input_sdk/private/interceptors.dart
index daa0e77..4c84cc9 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/interceptors.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/interceptors.dart
@@ -98,7 +98,7 @@
// dart:html can be used in dart2js an dev compiler.
// Warning: calls to these methods need to be removed before custom elements
// and cross-frame dom objects behave correctly in ddc.
-// See https://github.com/dart-lang/dev_compiler/issues/517
+// See https://github.com/dart-lang/sdk/issues/28326
findInterceptorConstructorForType(Type type) { }
findConstructorForNativeSubclassType(Type type, String name) { }
getNativeInterceptor(object) {}
diff --git a/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart b/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart
index 336eaa2..a20547b 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/js_helper.dart
@@ -878,8 +878,8 @@
}
-// TODO(jmesserly): this adapter is to work around:
-// https://github.com/dart-lang/dev_compiler/issues/247
+// TODO(jmesserly): this adapter is to work around
+// https://github.com/dart-lang/sdk/issues/28320
class SyncIterator<E> implements Iterator<E> {
final dynamic _jsIterator;
E _current;
diff --git a/pkg/dev_compiler/tool/input_sdk/private/native_helper.dart b/pkg/dev_compiler/tool/input_sdk/private/native_helper.dart
index de77f66..335805b 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/native_helper.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/native_helper.dart
@@ -24,8 +24,8 @@
}
// Warning: calls to these methods need to be removed before custom elements
-// and cross-frame dom objects behave correctly in ddc.
-// See https://github.com/dart-lang/dev_compiler/issues/517
+// and cross-frame dom objects behave correctly in ddc
+// https://github.com/dart-lang/sdk/issues/28326
setNativeSubclassDispatchRecord(proto, interceptor) { }
findDispatchTagForInterceptorClass(interceptorClassConstructor) {}
makeLeafDispatchRecord(interceptor) {}
diff --git a/pkg/dev_compiler/tool/sdk_expected_errors.txt b/pkg/dev_compiler/tool/sdk_expected_errors.txt
index 0a3d26e..c3223fa 100644
--- a/pkg/dev_compiler/tool/sdk_expected_errors.txt
+++ b/pkg/dev_compiler/tool/sdk_expected_errors.txt
@@ -1,12 +1,5 @@
[error] Couldn't infer type parameter 'T'; '_ControllerEventSinkWrapper<dynamic>' must be of type 'EventSink<T>'. (dart:async/stream.dart, line 1346, col 16)
[error] The argument type '_ControllerEventSinkWrapper' can't be assigned to the parameter type 'EventSink<T>'. (dart:async/stream.dart, line 1346, col 53)
-[error] A value of type '<R>(Zone, ZoneDelegate, Zone, () → R) → R' can't be assigned to a parameter of type '(Zone, ZoneDelegate, Zone, () → dynamic) → dynamic'. (dart:async/zone.dart, line 1071, col 51)
-[error] A value of type '<R,T>(Zone, ZoneDelegate, Zone, (T) → R, T) → R' can't be assigned to a parameter of type '(Zone, ZoneDelegate, Zone, (dynamic) → dynamic, dynamic) → dynamic'. (dart:async/zone.dart, line 1073, col 56)
-[error] A value of type '<R,T1,T2>(Zone, ZoneDelegate, Zone, (T1, T2) → R, T1, T2) → R' can't be assigned to a parameter of type '(Zone, ZoneDelegate, Zone, (dynamic, dynamic) → dynamic, dynamic, dynamic) → dynamic'. (dart:async/zone.dart, line 1075, col 57)
-[error] A value of type '<R>(Zone, ZoneDelegate, Zone, () → R) → () → R' can't be assigned to a parameter of type '(Zone, ZoneDelegate, Zone, () → dynamic) → () → dynamic'. (dart:async/zone.dart, line 1078, col 23)
-[error] A value of type '<R,T>(Zone, ZoneDelegate, Zone, (T) → R) → (T) → R' can't be assigned to a parameter of type '(Zone, ZoneDelegate, Zone, (dynamic) → dynamic) → (dynamic) → dynamic'. (dart:async/zone.dart, line 1081, col 23)
-[error] A value of type '<R,T1,T2>(Zone, ZoneDelegate, Zone, (T1, T2) → R) → (T1, T2) → R' can't be assigned to a parameter of type '(Zone, ZoneDelegate, Zone, (dynamic, dynamic) → dynamic) → (dynamic, dynamic) → dynamic'. (dart:async/zone.dart, line 1084, col 23)
-[error] A value of type '<R>(Zone, ZoneDelegate, Zone, dynamic, StackTrace) → R' can't be assigned to a parameter of type '(Zone, ZoneDelegate, Zone, dynamic, StackTrace) → dynamic'. (dart:async/zone.dart, line 1100, col 23)
[error] Invalid override. The type of 'ChunkedConverter.bind' ('(dynamic) → dynamic') isn't a subtype of 'Converter<S, T>.bind' ('(Stream<S>) → Stream<T>'). (dart:convert/chunked_conversion.dart, line 14, col 3)
[error] Invalid override. The type of 'ChunkedConverter.bind' ('(dynamic) → dynamic') isn't a subtype of 'StreamTransformer<S, T>.bind' ('(Stream<S>) → Stream<T>'). (dart:convert/chunked_conversion.dart, line 14, col 3)
[error] Invalid override. The type of 'ChunkedConverter.startChunkedConversion' ('(dynamic) → dynamic') isn't a subtype of 'Converter<S, T>.startChunkedConversion' ('(Sink<T>) → Sink<S>'). (dart:convert/chunked_conversion.dart, line 15, col 3)
diff --git a/pkg/front_end/lib/compiler_options.dart b/pkg/front_end/lib/compiler_options.dart
index 5230f4e..731344c 100644
--- a/pkg/front_end/lib/compiler_options.dart
+++ b/pkg/front_end/lib/compiler_options.dart
@@ -18,13 +18,13 @@
///
/// Not intended to be implemented or extended by clients.
class CompilerOptions {
- /// The path to the Dart SDK.
+ /// The URI of the root of the Dart SDK (typically a "file:" URI).
///
/// If `null`, the SDK will be searched for using
/// [Platform.resolvedExecutable] as a starting point.
///
/// This option is mutually exclusive with [sdkSummary].
- String sdkPath;
+ Uri sdkRoot;
/// Callback to which compilation errors should be delivered.
///
@@ -32,56 +32,58 @@
/// type [CompilationError].
ErrorHandler onError = defaultErrorHandler;
- /// Path to the ".packages" file.
+ /// URI of the ".packages" file (typically a "file:" URI).
///
/// If `null`, the ".packages" file will be found via the standard
/// package_config search algorithm.
///
- /// If the empty string, no packages file will be used.
- String packagesFilePath;
+ /// If the URI's path component is empty (e.g. `new Uri()`), no packages file
+ /// will be used.
+ Uri packagesFileUri;
- /// Paths to the input summary files (excluding the SDK summary). These files
- /// should all be linked summaries. They should also be closed, in the sense
- /// that any libraries they reference should also appear in [inputSummaries]
- /// or [sdkSummary].
- List<String> inputSummaries = [];
+ /// URIs of input summary files (excluding the SDK summary; typically these
+ /// will be "file:" URIs). These files should all be linked summaries. They
+ /// should also be closed, in the sense that any libraries they reference
+ /// should also appear in [inputSummaries] or [sdkSummary].
+ List<Uri> inputSummaries = [];
- /// Path to the SDK summary file.
+ /// URI of the SDK summary file (typically a "file:" URI).
///
/// This should be a linked summary. If `null`, the SDK summary will be
- /// searched for at a default location within [sdkPath].
+ /// searched for at a default location within [sdkRoot].
///
- /// This option is mutually exclusive with [sdkPath]. TODO(paulberry): if the
+ /// This option is mutually exclusive with [sdkRoot]. TODO(paulberry): if the
/// VM does not contain a pickled copy of the SDK, we might need to change
/// this.
- String sdkSummary;
+ Uri sdkSummary;
/// URI override map.
///
- /// This is a map from Uri to file path. Any URI override listed in this map
- /// takes precedence over the URI resolution that would be implied by the
- /// packages file (see [packagesFilePath]) and/or [bazelRoots].
+ /// This is a map from URIs that might appear in import/export/part statements
+ /// to URIs that should be used to locate the corresponding files in the
+ /// [fileSystem]. Any URI override listed in this map takes precedence over
+ /// the URI resolution that would be implied by the packages file (see
+ /// [packagesFileUri]) and/or [multiRoots].
///
/// If a URI is not listed in this map, then the normal URI resolution
/// algorithm will be used.
///
/// TODO(paulberry): transition analyzer and dev_compiler to use the
- /// "file:///bazel-root" mechanism, and then remove this.
+ /// "multi-root:" mechanism, and then remove this.
@deprecated
- Map<Uri, String> uriOverride = {};
+ Map<Uri, Uri> uriOverride = {};
- /// Bazel roots.
+ /// Multi-roots.
///
- /// Any Uri that resolves to "file:///bazel-root/$rest" will be searched for
- /// at "$root/$rest" ("$root\\$rest" in Windows), where "$root" is drawn from
- /// this list. If the file is not found at any of those locations, the URI
- /// "file:///bazel-root/$rest" will be used directly.
+ /// Any Uri that resolves to "multi-root:///$rest" will be searched for
+ /// at "$root/$rest", where "$root" is drawn from this list.
///
- /// Intended use: if the Bazel workspace is located at path "$workspace", this
- /// could be set to `['$workspace', '$workspace/bazel-bin',
- /// '$workspace/bazel-genfiles']`, effectively overlaying source and generated
- /// files.
- List<String> bazelRoots = [];
+ /// Intended use: if the user has a Bazel workspace located at path
+ /// "$workspace", this could be set to the file URIs corresponding to the
+ /// paths for "$workspace", "$workspace/bazel-bin",
+ /// and "$workspace/bazel-genfiles", effectively overlaying source and
+ /// generated files.
+ List<Uri> multiRoots = [];
/// Sets the platform bit, which determines which patch files should be
/// applied to the SDK.
@@ -99,7 +101,7 @@
///
/// All file system access performed by the front end goes through this
/// mechanism, with one exception: if no value is specified for
- /// [packagesFilePath], the packages file is located using the actual physical
+ /// [packagesFileUri], the packages file is located using the actual physical
/// file system. TODO(paulberry): fix this.
FileSystem fileSystem = PhysicalFileSystem.instance;
diff --git a/pkg/front_end/lib/file_system.dart b/pkg/front_end/lib/file_system.dart
index cadf82f..6e57c26 100644
--- a/pkg/front_end/lib/file_system.dart
+++ b/pkg/front_end/lib/file_system.dart
@@ -18,22 +18,17 @@
/// Not intended to be implemented or extended by clients.
abstract class FileSystem {
/// Returns a path context suitable for use with this [FileSystem].
+ ///
+ /// TODO(paulberry): try to eliminate all usages of this. Since the
+ /// FileSystem API now uses URIs rather than paths, it should not be needed.
path.Context get context;
- /// Returns a [FileSystemEntity] corresponding to the given [path].
- ///
- /// Uses of `..` and `.` in path are normalized before returning (so, for
- /// example, `entityForPath('./foo')` and `entityForPath('foo')` are
- /// equivalent). Relative paths are also converted to absolute paths.
- ///
- /// Does not check whether a file or folder exists at the given location.
- FileSystemEntity entityForPath(String path);
-
/// Returns a [FileSystemEntity] corresponding to the given [uri].
///
/// Uses of `..` and `.` in the URI are normalized before returning.
///
- /// If [uri] is not an absolute `file:` URI, an [Error] will be thrown.
+ /// If the URI scheme is not supported by this file system, an [Error] will be
+ /// thrown.
///
/// Does not check whether a file or folder exists at the given location.
FileSystemEntity entityForUri(Uri uri);
@@ -46,14 +41,12 @@
///
/// Not intended to be implemented or extended by clients.
abstract class FileSystemEntity {
- /// Returns the absolute normalized path represented by this file system
+ /// Returns the absolute normalized URI represented by this file system
/// entity.
///
- /// Note: if the [FileSystemEntity] was created using
- /// [FileSystem.entityForPath], this is not necessarily the same as the path
- /// that was used to create the object, since the path might have been
- /// normalized.
- String get path;
+ /// Note: this is not necessarily the same as the URI that was passed to
+ /// [FileSystem.entityForUri], since the URI might have been normalized.
+ Uri get uri;
/// Attempts to access this file system entity as a file and read its contents
/// as raw bytes.
diff --git a/pkg/front_end/lib/kernel_generator.dart b/pkg/front_end/lib/kernel_generator.dart
index a87bb68..348d1f9 100644
--- a/pkg/front_end/lib/kernel_generator.dart
+++ b/pkg/front_end/lib/kernel_generator.dart
@@ -59,7 +59,7 @@
/// which will be read are those listed in [sources],
/// [CompilerOptions.inputSummaries], and [CompilerOptions.sdkSummary]. If a
/// source file attempts to refer to a file which is not obtainable from these
-/// paths, that will result in an error, even if the file exists on the
+/// URIs, that will result in an error, even if the file exists on the
/// filesystem.
///
/// When [CompilerOptions.chaseDependencies] is true, this default behavior
@@ -128,7 +128,8 @@
Future<DartLoader> _createLoader(CompilerOptions options,
{Repository repository, Uri entry}) async {
var kernelOptions = _convertOptions(options);
- var packages = await createPackages(options.packagesFilePath,
+ var packages = await createPackages(
+ _uriToPath(options.packagesFileUri, options),
discoveryPath: entry?.path);
return new DartLoader(
repository ?? new Repository(), kernelOptions, packages);
@@ -137,11 +138,12 @@
DartOptions _convertOptions(CompilerOptions options) {
return new DartOptions(
strongMode: options.strongMode,
- sdk: options.sdkPath,
+ sdk: _uriToPath(options.sdkRoot, options),
// TODO(sigmund): make it possible to use summaries and still compile the
// sdk sources.
- sdkSummary: options.compileSdk ? null : options.sdkSummary,
- packagePath: options.packagesFilePath,
+ sdkSummary:
+ options.compileSdk ? null : _uriToPath(options.sdkSummary, options),
+ packagePath: _uriToPath(options.packagesFileUri, options),
declaredVariables: options.declaredVariables);
}
@@ -152,6 +154,14 @@
}
}
+String _uriToPath(Uri uri, CompilerOptions options) {
+ if (uri == null) return null;
+ if (uri.scheme != 'file') {
+ throw new StateError('Only file URIs are supported');
+ }
+ return options.fileSystem.context.fromUri(uri);
+}
+
// TODO(sigmund): delete this class. Dartk should not format errors itself, we
// should just pass them along.
class _DartkError implements CompilationError {
diff --git a/pkg/front_end/lib/memory_file_system.dart b/pkg/front_end/lib/memory_file_system.dart
index 267cbe3..e7382ad 100644
--- a/pkg/front_end/lib/memory_file_system.dart
+++ b/pkg/front_end/lib/memory_file_system.dart
@@ -20,26 +20,29 @@
@override
final p.Context context;
- final Map<String, Uint8List> _files = {};
+ final Map<Uri, Uint8List> _files = {};
/// The "current directory" in the in-memory virtual file system.
///
- /// This is used to convert relative paths to absolute paths.
- String currentDirectory;
+ /// This is used to convert relative URIs to absolute URIs.
+ ///
+ /// Always ends in a trailing '/'.
+ Uri currentDirectory;
- MemoryFileSystem(this.context, this.currentDirectory);
-
- @override
- MemoryFileSystemEntity entityForPath(String path) =>
- new MemoryFileSystemEntity._(
- this, context.normalize(context.join(currentDirectory, path)));
+ MemoryFileSystem(this.context, Uri currentDirectory)
+ : currentDirectory = _addTrailingSlash(currentDirectory);
@override
MemoryFileSystemEntity entityForUri(Uri uri) {
- if (uri.scheme != 'file') throw new ArgumentError('File URI expected');
- // Note: we don't have to verify that the URI's path is absolute, because
- // URIs with non-empty schemes always have absolute paths.
- return entityForPath(context.fromUri(uri));
+ return new MemoryFileSystemEntity._(
+ this, currentDirectory.resolveUri(uri).normalizePath());
+ }
+
+ static Uri _addTrailingSlash(Uri uri) {
+ if (!uri.path.endsWith('/')) {
+ uri = uri.replace(path: uri.path + '/');
+ }
+ return uri;
}
}
@@ -49,22 +52,22 @@
final MemoryFileSystem _fileSystem;
@override
- final String path;
+ final Uri uri;
- MemoryFileSystemEntity._(this._fileSystem, this.path);
+ MemoryFileSystemEntity._(this._fileSystem, this.uri);
@override
- int get hashCode => path.hashCode;
+ int get hashCode => uri.hashCode;
@override
bool operator ==(Object other) =>
other is MemoryFileSystemEntity &&
- other.path == path &&
+ other.uri == uri &&
identical(other._fileSystem, _fileSystem);
@override
Future<List<int>> readAsBytes() async {
- List<int> contents = _fileSystem._files[path];
+ List<int> contents = _fileSystem._files[uri];
if (contents != null) {
return contents.toList();
}
@@ -82,7 +85,7 @@
/// If no file exists, one is created. If a file exists already, it is
/// overwritten.
void writeAsBytesSync(List<int> bytes) {
- _fileSystem._files[path] = new Uint8List.fromList(bytes);
+ _fileSystem._files[uri] = new Uint8List.fromList(bytes);
}
/// Writes the given string to this file system entity.
@@ -95,6 +98,6 @@
// Note: the return type of UTF8.encode is List<int>, but in practice it
// always returns Uint8List. We rely on that for efficiency, so that we
// don't have to make an extra copy.
- _fileSystem._files[path] = UTF8.encode(s) as Uint8List;
+ _fileSystem._files[uri] = UTF8.encode(s) as Uint8List;
}
}
diff --git a/pkg/front_end/lib/physical_file_system.dart b/pkg/front_end/lib/physical_file_system.dart
index 0ed5d8b..757eb60 100644
--- a/pkg/front_end/lib/physical_file_system.dart
+++ b/pkg/front_end/lib/physical_file_system.dart
@@ -24,36 +24,38 @@
p.Context get context => p.context;
@override
- FileSystemEntity entityForPath(String path) =>
- new _PhysicalFileSystemEntity(context.normalize(context.absolute(path)));
-
- @override
FileSystemEntity entityForUri(Uri uri) {
- if (uri.scheme != 'file') throw new ArgumentError('File URI expected');
+ if (uri.scheme != 'file' && uri.scheme != '') {
+ throw new ArgumentError('File URI expected');
+ }
// Note: we don't have to verify that the URI's path is absolute, because
// URIs with non-empty schemes always have absolute paths.
- return entityForPath(context.fromUri(uri));
+ var path = context.fromUri(uri);
+ return new _PhysicalFileSystemEntity(
+ context.normalize(context.absolute(path)));
}
}
/// Concrete implementation of [FileSystemEntity] for use by
/// [PhysicalFileSystem].
class _PhysicalFileSystemEntity implements FileSystemEntity {
- @override
- final String path;
+ final String _path;
- _PhysicalFileSystemEntity(this.path);
+ _PhysicalFileSystemEntity(this._path);
@override
- int get hashCode => path.hashCode;
+ int get hashCode => _path.hashCode;
+
+ @override
+ Uri get uri => p.toUri(_path);
@override
bool operator ==(Object other) =>
- other is _PhysicalFileSystemEntity && other.path == path;
+ other is _PhysicalFileSystemEntity && other._path == _path;
@override
- Future<List<int>> readAsBytes() => new io.File(path).readAsBytes();
+ Future<List<int>> readAsBytes() => new io.File(_path).readAsBytes();
@override
- Future<String> readAsString() => new io.File(path).readAsString();
+ Future<String> readAsString() => new io.File(_path).readAsString();
}
diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart
index e1a4ef4..60ef2ec 100644
--- a/pkg/front_end/lib/src/base/processed_options.dart
+++ b/pkg/front_end/lib/src/base/processed_options.dart
@@ -4,6 +4,7 @@
import 'dart:async';
+import 'package:analyzer/src/summary/idl.dart';
import 'package:front_end/compiler_options.dart';
import 'package:front_end/file_system.dart';
import 'package:front_end/src/base/uri_resolver.dart';
@@ -29,6 +30,13 @@
/// been computed yet.
UriResolver _uriResolver;
+ /// The summary bundle for the SDK, or `null` if it has not been read yet.
+ PackageBundle _sdkSummary;
+
+ /// The location of the SDK, or `null` if the location hasn't been determined
+ /// yet.
+ Uri _sdkRoot;
+
/// Initializes a [ProcessedOptions] object wrapping the given [rawOptions].
ProcessedOptions(CompilerOptions rawOptions) : this._raw = rawOptions;
@@ -39,14 +47,38 @@
/// Get the [FileSystem] which should be used by the front end to access
/// files.
///
- /// If the client supplied bazel roots using [CompilerOptions.bazelRoots], the
+ /// If the client supplied roots using [CompilerOptions.multiRoots], the
/// returned [FileSystem] will automatically perform the appropriate mapping.
FileSystem get fileSystem {
- // TODO(paulberry): support bazelRoots.
- assert(_raw.bazelRoots.isEmpty);
+ // TODO(paulberry): support multiRoots.
+ assert(_raw.multiRoots.isEmpty);
return _raw.fileSystem;
}
+ /// Get the summary bundle for the SDK.
+ ///
+ /// This is an asynchronous getter since file system operations are required.
+ Future<PackageBundle> getSdkSummary() async {
+ if (_sdkSummary == null) {
+ Uri summaryLocation;
+ if (_raw.sdkSummary != null) {
+ // Options sdkSummary and sdkRoot are mutually exclusive.
+ assert(_raw.sdkRoot == null);
+ // No need to look for the SDK; we were told where the SDK summary is.
+ summaryLocation = _raw.sdkSummary;
+ } else {
+ // Need to look for the SDK summary inside the SDK.
+ var sdkRoot = await _getSdkRoot();
+ summaryLocation = sdkRoot.resolve(
+ 'lib/_internal/' + (_raw.strongMode ? 'strong.sum' : 'spec.sum'));
+ }
+ var summaryBytes =
+ await fileSystem.entityForUri(summaryLocation).readAsBytes();
+ _sdkSummary = new PackageBundle.fromBuffer(summaryBytes);
+ }
+ return _sdkSummary;
+ }
+
/// Get the [UriResolver] which resolves "package:" and "dart:" URIs.
///
/// This is an asynchronous getter since file system operations may be
@@ -56,8 +88,7 @@
await _getPackages();
var sdkLibraries =
<String, Uri>{}; // TODO(paulberry): support SDK libraries
- _uriResolver =
- new UriResolver(_packages, sdkLibraries, fileSystem.context);
+ _uriResolver = new UriResolver(_packages, sdkLibraries);
}
return _uriResolver;
}
@@ -68,17 +99,38 @@
/// required to locate/read the packages file.
Future<Map<String, Uri>> _getPackages() async {
if (_packages == null) {
- if (_raw.packagesFilePath == null) {
+ if (_raw.packagesFileUri == null) {
throw new UnimplementedError(); // TODO(paulberry): search for .packages
- } else if (_raw.packagesFilePath.isEmpty) {
+ } else if (_raw.packagesFileUri.path.isEmpty) {
_packages = {};
} else {
var contents =
- await fileSystem.entityForPath(_raw.packagesFilePath).readAsBytes();
- var baseLocation = fileSystem.context.toUri(_raw.packagesFilePath);
- _packages = package_config.parse(contents, baseLocation);
+ await fileSystem.entityForUri(_raw.packagesFileUri).readAsBytes();
+ _packages = package_config.parse(contents, _raw.packagesFileUri);
}
}
return _packages;
}
+
+ /// Get the location of the SDK.
+ ///
+ /// This is an asynchronous getter since file system operations may be
+ /// required to locate the SDK.
+ Future<Uri> _getSdkRoot() async {
+ if (_sdkRoot == null) {
+ // If an SDK summary location was provided, the SDK itself should not be
+ // needed.
+ assert(_raw.sdkSummary == null);
+ if (_raw.sdkRoot == null) {
+ // TODO(paulberry): implement the algorithm for finding the SDK
+ // automagically.
+ throw new UnimplementedError();
+ }
+ _sdkRoot = _raw.sdkRoot;
+ if (!_sdkRoot.path.endsWith('/')) {
+ _sdkRoot = _sdkRoot.replace(path: _sdkRoot.path + '/');
+ }
+ }
+ return _sdkRoot;
+ }
}
diff --git a/pkg/front_end/lib/src/base/uri_resolver.dart b/pkg/front_end/lib/src/base/uri_resolver.dart
index db469f0..0c6a420 100644
--- a/pkg/front_end/lib/src/base/uri_resolver.dart
+++ b/pkg/front_end/lib/src/base/uri_resolver.dart
@@ -2,13 +2,15 @@
// 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:path/path.dart' as p;
-
-/// The class `UriResolver` implements the rules for resolving URIs to file
-/// paths.
-///
-/// TODO(paulberry): Is it necessary to support the "http" scheme?
+/// The class `UriResolver` implements the rules for resolving "dart:" and
+/// "package:" URIs.
class UriResolver {
+ /// The URI scheme used for "package" URIs.
+ static const PACKAGE_SCHEME = 'package';
+
+ /// The URI scheme used for "dart" URIs.
+ static const DART_SCHEME = 'dart';
+
/// A map from package name to the file URI of the "lib" directory of the
/// corresponding package. This is equivalent to the format returned by
/// the "package_config" package's parse() function.
@@ -18,36 +20,27 @@
/// of the defining compilation unit of the SDK library.
final Map<String, Uri> sdkLibraries;
- /// The path context which should be used to convert from file URIs to file
- /// paths.
- final p.Context pathContext;
+ UriResolver(this.packages, this.sdkLibraries);
- /// The URI scheme used for "package" URIs.
- static const PACKAGE_SCHEME = 'package';
-
- /// The URI scheme used for "dart" URIs.
- static const DART_SCHEME = 'dart';
-
- /// The URI scheme used for "file" URIs.
- static const FILE_SCHEME = 'file';
-
- UriResolver(this.packages, this.sdkLibraries, this.pathContext);
-
- /// Converts a URI to a file path.
+ /// Converts "package:" and "dart:" URIs to the locations of the corresponding
+ /// files.
///
- /// If the given URI is valid, and of a recognized form, returns the file path
- /// it corresponds to. Otherwise returns `null`. It is not necessary for the
- /// URI to be absolute (relative URIs will be converted to relative file
- /// paths).
+ /// If the given URI is a "package:" or "dart:" URI, is well formed, and names
+ /// a package or dart library that is recognized, returns the URI it resolves
+ /// to. If the given URI is a "package:" or "dart:" URI, and is ill-formed
+ /// or names a package or dart library that is not recognized, returns `null`.
///
- /// Note that no I/O is performed; the file path that is returned will be
+ /// If the given URI has any scheme other than "package:" or "dart:", it is
+ /// returned unchanged.
+ ///
+ /// It is not necessary for the URI to be absolute (relative URIs will be
+ /// passed through unchanged).
+ ///
+ /// Note that no I/O is performed; the URI that is returned will be
/// independent of whether or not any particular file exists on the file
/// system.
- String resolve(Uri uri) {
- Uri fileUri;
- if (uri.scheme == FILE_SCHEME) {
- fileUri = uri;
- } else {
+ Uri resolve(Uri uri) {
+ if (uri.scheme == DART_SCHEME || uri.scheme == PACKAGE_SCHEME) {
var path = uri.path;
var slashIndex = path.indexOf('/');
String prefix;
@@ -67,9 +60,9 @@
libUri = sdkLibraries[prefix];
}
if (libUri == null) return null;
- fileUri = libUri.resolve(rest);
- if (fileUri.scheme != FILE_SCHEME) return null;
+ return libUri.resolve(rest);
+ } else {
+ return uri;
}
- return pathContext.fromUri(fileUri);
}
}
diff --git a/pkg/front_end/lib/src/dependency_grapher_impl.dart b/pkg/front_end/lib/src/dependency_grapher_impl.dart
index 5dbe12d..0951931 100644
--- a/pkg/front_end/lib/src/dependency_grapher_impl.dart
+++ b/pkg/front_end/lib/src/dependency_grapher_impl.dart
@@ -99,13 +99,14 @@
Future<List<_WalkerNode>> computeDependencies() async {
var dependencies = <_WalkerNode>[];
// TODO(paulberry): add error recovery if the file can't be read.
- var path = walker.uriResolver.resolve(uri);
- if (path == null) {
+ var resolvedUri = walker.uriResolver.resolve(uri);
+ if (resolvedUri == null) {
// TODO(paulberry): If an error reporter was provided, report the error
// in the proper way and continue.
throw new StateError('Invalid URI: $uri');
}
- var contents = await walker.fileSystem.entityForPath(path).readAsString();
+ var contents =
+ await walker.fileSystem.entityForUri(resolvedUri).readAsString();
var scanner = new _Scanner(contents);
var token = scanner.tokenize();
// TODO(paulberry): report errors.
diff --git a/pkg/front_end/test/dependency_grapher_test.dart b/pkg/front_end/test/dependency_grapher_test.dart
index bcfca56..826283d 100644
--- a/pkg/front_end/test/dependency_grapher_test.dart
+++ b/pkg/front_end/test/dependency_grapher_test.dart
@@ -35,15 +35,17 @@
// If no starting points given, assume the first entry in [contents] is the
// single starting point.
startingPoints ??= [contents.keys.first];
- var fileSystem = new MemoryFileSystem(pathos.posix, '/');
+ var fileSystem = new MemoryFileSystem(pathos.posix, Uri.parse('file:///'));
contents.forEach((path, text) {
- fileSystem.entityForPath(path).writeAsStringSync(text);
+ fileSystem.entityForUri(pathos.posix.toUri(path)).writeAsStringSync(text);
});
// TODO(paulberry): implement and test other option possibilities.
var options = new CompilerOptions()
..fileSystem = fileSystem
..chaseDependencies = true
- ..packagesFilePath = packagesFilePath;
+ ..packagesFileUri = packagesFilePath == ''
+ ? new Uri()
+ : pathos.posix.toUri(packagesFilePath);
var graph = await graphForProgram(
startingPoints.map(pathos.posix.toUri).toList(), options);
return graph.topologicallySortedCycles;
diff --git a/pkg/front_end/test/memory_file_system_test.dart b/pkg/front_end/test/memory_file_system_test.dart
index b9757f3..365cd43 100644
--- a/pkg/front_end/test/memory_file_system_test.dart
+++ b/pkg/front_end/test/memory_file_system_test.dart
@@ -30,26 +30,23 @@
setUp() {
super.setUp();
path = join(tempPath, 'file.txt');
- file = fileSystem.entityForPath(path);
+ file = entityForPath(path);
}
test_equals_differentPaths() {
- expect(
- file == fileSystem.entityForPath(join(tempPath, 'file2.txt')), isFalse);
+ expect(file == entityForPath(join(tempPath, 'file2.txt')), isFalse);
}
test_equals_samePath() {
- expect(
- file == fileSystem.entityForPath(join(tempPath, 'file.txt')), isTrue);
+ expect(file == entityForPath(join(tempPath, 'file.txt')), isTrue);
}
test_hashCode_samePath() {
- expect(file.hashCode,
- fileSystem.entityForPath(join(tempPath, 'file.txt')).hashCode);
+ expect(file.hashCode, entityForPath(join(tempPath, 'file.txt')).hashCode);
}
test_path() {
- expect(file.path, path);
+ expect(file.uri, fileSystem.context.toUri(path));
}
test_readAsBytes_badUtf8() async {
@@ -128,40 +125,44 @@
tempUri = fileSystem.context.toUri(tempPath);
}
- test_entityForPath() {
- var path = join(tempPath, 'file.txt');
- expect(fileSystem.entityForPath(path).path, path);
+ test_currentDirectory_trailingSlash() {
+ // The currentDirectory should already end in a trailing slash.
+ expect(fileSystem.currentDirectory.path, endsWith('/'));
+ // A trailing slash should automatically be appended when creating a
+ // MemoryFileSystem.
+ var path = fileSystem.currentDirectory.path;
+ var currentDirectoryWithoutSlash = fileSystem.currentDirectory
+ .replace(path: path.substring(0, path.length - 1));
+ expect(
+ new MemoryFileSystem(fileSystem.context, currentDirectoryWithoutSlash)
+ .currentDirectory,
+ fileSystem.currentDirectory);
+ // If the currentDirectory supplied to the MemoryFileSystem constructor
+ // already has a trailing slash, no further trailing slash should be added.
+ expect(
+ new MemoryFileSystem(fileSystem.context, fileSystem.currentDirectory)
+ .currentDirectory,
+ fileSystem.currentDirectory);
}
test_entityForPath_absolutize() {
- expect(fileSystem.entityForPath('file.txt').path,
- join(fileSystem.currentDirectory, 'file.txt'));
+ expect(entityForPath('file.txt').uri,
+ fileSystem.currentDirectory.resolve('file.txt'));
}
test_entityForPath_normalize_dot() {
- expect(fileSystem.entityForPath(join(tempPath, '.', 'file.txt')).path,
- join(tempPath, 'file.txt'));
+ expect(entityForPath(join(tempPath, '.', 'file.txt')).uri,
+ Uri.parse('$tempUri/file.txt'));
}
test_entityForPath_normalize_dotDot() {
- expect(
- fileSystem.entityForPath(join(tempPath, 'foo', '..', 'file.txt')).path,
- join(tempPath, 'file.txt'));
+ expect(entityForPath(join(tempPath, 'foo', '..', 'file.txt')).uri,
+ Uri.parse('$tempUri/file.txt'));
}
test_entityForUri() {
- expect(fileSystem.entityForUri(Uri.parse('$tempUri/file.txt')).path,
- join(tempPath, 'file.txt'));
- }
-
- test_entityForUri_bareUri_absolute() {
- expect(() => fileSystem.entityForUri(Uri.parse('/file.txt')),
- throwsA(new isInstanceOf<Error>()));
- }
-
- test_entityForUri_bareUri_relative() {
- expect(() => fileSystem.entityForUri(Uri.parse('file.txt')),
- throwsA(new isInstanceOf<Error>()));
+ expect(fileSystem.entityForUri(Uri.parse('$tempUri/file.txt')).uri,
+ Uri.parse('$tempUri/file.txt'));
}
test_entityForUri_fileUri_relative() {
@@ -184,18 +185,18 @@
}
test_entityForUri_nonFileUri() {
- expect(() => fileSystem.entityForUri(Uri.parse('package:foo/bar.dart')),
- throwsA(new isInstanceOf<Error>()));
+ var uri = Uri.parse('package:foo/bar.dart');
+ expect(fileSystem.entityForUri(uri).uri, uri);
}
test_entityForUri_normalize_dot() {
- expect(fileSystem.entityForUri(Uri.parse('$tempUri/./file.txt')).path,
- join(tempPath, 'file.txt'));
+ expect(fileSystem.entityForUri(Uri.parse('$tempUri/./file.txt')).uri,
+ Uri.parse('$tempUri/file.txt'));
}
test_entityForUri_normalize_dotDot() {
- expect(fileSystem.entityForUri(Uri.parse('$tempUri/foo/../file.txt')).path,
- join(tempPath, 'file.txt'));
+ expect(fileSystem.entityForUri(Uri.parse('$tempUri/foo/../file.txt')).uri,
+ Uri.parse('$tempUri/file.txt'));
}
}
@@ -213,8 +214,14 @@
abstract class _BaseTest {
MemoryFileSystem get fileSystem;
+
String get tempPath;
+
+ MemoryFileSystemEntity entityForPath(String path) =>
+ fileSystem.entityForUri(fileSystem.context.toUri(path));
+
String join(String path1, String path2, [String path3, String path4]);
+
void setUp();
}
@@ -227,8 +234,8 @@
setUp() {
tempPath = pathos.join(io.Directory.systemTemp.path, 'test_file_system');
- fileSystem =
- new MemoryFileSystem(pathos.context, io.Directory.current.path);
+ fileSystem = new MemoryFileSystem(
+ pathos.context, pathos.toUri(io.Directory.current.path));
}
}
@@ -241,7 +248,7 @@
void setUp() {
tempPath = '/test_file_system';
- fileSystem = new MemoryFileSystem(pathos.posix, '/cwd');
+ fileSystem = new MemoryFileSystem(pathos.posix, Uri.parse('file:///cwd'));
}
}
@@ -254,6 +261,7 @@
void setUp() {
tempPath = r'c:\test_file_system';
- fileSystem = new MemoryFileSystem(pathos.windows, r'c:\cwd');
+ fileSystem =
+ new MemoryFileSystem(pathos.windows, Uri.parse('file:///c:/cwd'));
}
}
diff --git a/pkg/front_end/test/physical_file_system_test.dart b/pkg/front_end/test/physical_file_system_test.dart
index 859e998..2a8cbb6 100644
--- a/pkg/front_end/test/physical_file_system_test.dart
+++ b/pkg/front_end/test/physical_file_system_test.dart
@@ -30,35 +30,19 @@
setUp() {
super.setUp();
path = p.join(tempPath, 'file.txt');
- file = PhysicalFileSystem.instance.entityForPath(path);
+ file = PhysicalFileSystem.instance.entityForUri(p.toUri(path));
}
test_equals_differentPaths() {
- expect(
- file ==
- PhysicalFileSystem.instance
- .entityForPath(p.join(tempPath, 'file2.txt')),
- isFalse);
+ expect(file == entityForPath(p.join(tempPath, 'file2.txt')), isFalse);
}
test_equals_samePath() {
- expect(
- file ==
- PhysicalFileSystem.instance
- .entityForPath(p.join(tempPath, 'file.txt')),
- isTrue);
+ expect(file == entityForPath(p.join(tempPath, 'file.txt')), isTrue);
}
test_hashCode_samePath() {
- expect(
- file.hashCode,
- PhysicalFileSystem.instance
- .entityForPath(p.join(tempPath, 'file.txt'))
- .hashCode);
- }
-
- test_path() {
- expect(file.path, path);
+ expect(file.hashCode, entityForPath(p.join(tempPath, 'file.txt')).hashCode);
}
test_readAsBytes_badUtf8() async {
@@ -98,6 +82,10 @@
new io.File(path).writeAsBytesSync(bytes);
expect(await file.readAsString(), '\u20ac');
}
+
+ test_uri() {
+ expect(file.uri, p.toUri(path));
+ }
}
@reflectiveTest
@@ -111,48 +99,35 @@
test_entityForPath() {
var path = p.join(tempPath, 'file.txt');
- expect(PhysicalFileSystem.instance.entityForPath(path).path, path);
+ expect(entityForPath(path).uri, p.toUri(path));
}
test_entityForPath_absolutize() {
- expect(PhysicalFileSystem.instance.entityForPath('file.txt').path,
- new io.File('file.txt').absolute.path);
+ expect(entityForPath('file.txt').uri,
+ p.toUri(new io.File('file.txt').absolute.path));
}
test_entityForPath_normalize_dot() {
- expect(
- PhysicalFileSystem.instance
- .entityForPath(p.join(tempPath, '.', 'file.txt'))
- .path,
- p.join(tempPath, 'file.txt'));
+ expect(entityForPath(p.join(tempPath, '.', 'file.txt')).uri,
+ p.toUri(p.join(tempPath, 'file.txt')));
}
test_entityForPath_normalize_dotDot() {
- expect(
- PhysicalFileSystem.instance
- .entityForPath(p.join(tempPath, 'foo', '..', 'file.txt'))
- .path,
- p.join(tempPath, 'file.txt'));
+ expect(entityForPath(p.join(tempPath, 'foo', '..', 'file.txt')).uri,
+ p.toUri(p.join(tempPath, 'file.txt')));
}
test_entityForUri() {
expect(
PhysicalFileSystem.instance
.entityForUri(Uri.parse('$tempUri/file.txt'))
- .path,
- p.join(tempPath, 'file.txt'));
+ .uri,
+ p.toUri(p.join(tempPath, 'file.txt')));
}
test_entityForUri_bareUri_absolute() {
- expect(
- () => PhysicalFileSystem.instance.entityForUri(Uri.parse('/file.txt')),
- throwsA(new isInstanceOf<Error>()));
- }
-
- test_entityForUri_bareUri_relative() {
- expect(
- () => PhysicalFileSystem.instance.entityForUri(Uri.parse('file.txt')),
- throwsA(new isInstanceOf<Error>()));
+ expect(PhysicalFileSystem.instance.entityForUri(Uri.parse('/file.txt')).uri,
+ p.toUri(p.fromUri('/file.txt')));
}
test_entityForUri_fileUri_relative() {
@@ -185,16 +160,16 @@
expect(
PhysicalFileSystem.instance
.entityForUri(Uri.parse('$tempUri/./file.txt'))
- .path,
- p.join(tempPath, 'file.txt'));
+ .uri,
+ p.toUri(p.join(tempPath, 'file.txt')));
}
test_entityForUri_normalize_dotDot() {
expect(
PhysicalFileSystem.instance
.entityForUri(Uri.parse('$tempUri/foo/../file.txt'))
- .path,
- p.join(tempPath, 'file.txt'));
+ .uri,
+ p.toUri(p.join(tempPath, 'file.txt')));
}
}
@@ -202,6 +177,9 @@
io.Directory tempDirectory;
String tempPath;
+ FileSystemEntity entityForPath(String path) =>
+ PhysicalFileSystem.instance.entityForUri(p.toUri(path));
+
setUp() {
tempDirectory = io.Directory.systemTemp.createTempSync('test_file_system');
tempPath = tempDirectory.absolute.path;
diff --git a/pkg/front_end/test/src/base/processed_options_test.dart b/pkg/front_end/test/src/base/processed_options_test.dart
index ff34028..94941f1 100644
--- a/pkg/front_end/test/src/base/processed_options_test.dart
+++ b/pkg/front_end/test/src/base/processed_options_test.dart
@@ -2,6 +2,9 @@
// 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/src/summary/format.dart';
import 'package:front_end/compiler_options.dart';
import 'package:front_end/memory_file_system.dart';
import 'package:front_end/src/base/processed_options.dart';
@@ -17,7 +20,18 @@
@reflectiveTest
class ProcessedOptionsTest {
- final fileSystem = new MemoryFileSystem(pathos.posix, '/');
+ final fileSystem = new MemoryFileSystem(pathos.posix, Uri.parse('file:///'));
+
+ PackageBundleBuilder _mockSdkSummary;
+
+ PackageBundleBuilder get mockSdkSummary => _mockSdkSummary ??=
+ new PackageBundleBuilder(apiSignature: 'mock summary signature');
+
+ Future<Null> checkMockSummary(CompilerOptions raw) async {
+ var processed = new ProcessedOptions(raw);
+ var sdkSummary = await processed.getSdkSummary();
+ expect(sdkSummary.apiSignature, mockSdkSummary.apiSignature);
+ }
test_compileSdk_false() {
for (var value in [false, true]) {
@@ -35,48 +49,88 @@
expect(processed.fileSystem, same(fileSystem));
}
+ test_getSdkSummary_sdkLocationProvided_noTrailingSlash() async {
+ var uri = Uri.parse('file:///sdk');
+ writeMockSummaryTo(Uri.parse('$uri/lib/_internal/strong.sum'));
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..sdkRoot = uri);
+ }
+
+ test_getSdkSummary_sdkLocationProvided_spec() async {
+ var uri = Uri.parse('file:///sdk');
+ writeMockSummaryTo(Uri.parse('$uri/lib/_internal/spec.sum'));
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..strongMode = false
+ ..sdkRoot = uri);
+ }
+
+ test_getSdkSummary_sdkLocationProvided_trailingSlash() async {
+ var uri = Uri.parse('file:///sdk');
+ writeMockSummaryTo(Uri.parse('$uri/lib/_internal/strong.sum'));
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..sdkRoot = Uri.parse('$uri/'));
+ }
+
+ test_getSdkSummary_summaryLocationProvided() async {
+ var uri = Uri.parse('file:///sdkSummary');
+ writeMockSummaryTo(uri);
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..sdkSummary = uri);
+ }
+
test_getUriResolver_explicitPackagesFile() async {
// This .packages file should be ignored.
- fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
+ fileSystem
+ .entityForUri(Uri.parse('file:///.packages'))
+ .writeAsStringSync('foo:bar\n');
// This one should be used.
fileSystem
- .entityForPath('/explicit.packages')
+ .entityForUri(Uri.parse('file:///explicit.packages'))
.writeAsStringSync('foo:baz\n');
var raw = new CompilerOptions()
..fileSystem = fileSystem
- ..packagesFilePath = '/explicit.packages';
+ ..packagesFileUri = Uri.parse('file:///explicit.packages');
var processed = new ProcessedOptions(raw);
var uriResolver = await processed.getUriResolver();
expect(uriResolver.packages, {'foo': Uri.parse('file:///baz/')});
- expect(uriResolver.pathContext, same(fileSystem.context));
}
test_getUriResolver_explicitPackagesFile_withBaseLocation() async {
// This .packages file should be ignored.
- fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
+ fileSystem
+ .entityForUri(Uri.parse('file:///.packages'))
+ .writeAsStringSync('foo:bar\n');
// This one should be used.
fileSystem
- .entityForPath('/base/location/explicit.packages')
+ .entityForUri(Uri.parse('file:///base/location/explicit.packages'))
.writeAsStringSync('foo:baz\n');
var raw = new CompilerOptions()
..fileSystem = fileSystem
- ..packagesFilePath = '/base/location/explicit.packages';
+ ..packagesFileUri = Uri.parse('file:///base/location/explicit.packages');
var processed = new ProcessedOptions(raw);
var uriResolver = await processed.getUriResolver();
expect(
uriResolver.packages, {'foo': Uri.parse('file:///base/location/baz/')});
- expect(uriResolver.pathContext, same(fileSystem.context));
}
test_getUriResolver_noPackages() async {
// .packages file should be ignored.
- fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
+ fileSystem
+ .entityForUri(Uri.parse('file:///.packages'))
+ .writeAsStringSync('foo:bar\n');
var raw = new CompilerOptions()
..fileSystem = fileSystem
- ..packagesFilePath = '';
+ ..packagesFileUri = new Uri();
var processed = new ProcessedOptions(raw);
var uriResolver = await processed.getUriResolver();
expect(uriResolver.packages, isEmpty);
- expect(uriResolver.pathContext, same(fileSystem.context));
+ }
+
+ void writeMockSummaryTo(Uri uri) {
+ fileSystem.entityForUri(uri).writeAsBytesSync(mockSdkSummary.toBuffer());
}
}
diff --git a/pkg/front_end/test/src/base/uri_resolver_test.dart b/pkg/front_end/test/src/base/uri_resolver_test.dart
index 1273a19..627b466 100644
--- a/pkg/front_end/test/src/base/uri_resolver_test.dart
+++ b/pkg/front_end/test/src/base/uri_resolver_test.dart
@@ -21,7 +21,7 @@
p.Context get pathContext;
void test_badScheme() {
- _expectResolution('foo:bar/baz.dart', null);
+ _expectResolutionUri('foo:bar/baz.dart', Uri.parse('foo:bar/baz.dart'));
}
void test_dart() {
@@ -46,19 +46,19 @@
}
void test_file() {
- _expectResolution('file:///foo.dart', _p('foo.dart'));
+ _expectResolution(_fileUri('foo.dart'), _p('foo.dart'));
}
void test_fileLongPath() {
- _expectResolution('file:///foo/bar.dart', _p('foo/bar.dart'));
+ _expectResolution(_fileUri('foo/bar.dart'), _p('foo/bar.dart'));
}
void test_noSchemeAbsolute() {
- _expectResolution('/foo.dart', null);
+ _expectResolutionUri('/foo.dart', Uri.parse('/foo.dart'));
}
void test_noSchemeRelative() {
- _expectResolution('foo.dart', null);
+ _expectResolution('foo.dart', 'foo.dart');
}
void test_package() {
@@ -102,6 +102,13 @@
/// Verifies that the resolution of [uriString] produces the path
/// [expectedResult].
void _expectResolution(String uriString, String expectedResult) {
+ _expectResolutionUri(uriString,
+ expectedResult == null ? null : pathContext.toUri(expectedResult));
+ }
+
+ /// Verifies that the resolution of [uriString] produces the URI
+ /// [expectedResult].
+ void _expectResolutionUri(String uriString, Uri expectedResult) {
var packages = {
'foo': _u('packages/foo/lib/'),
'bar': _u('packages/bar/lib/')
@@ -110,18 +117,31 @@
'core': _u('sdk/lib/core/core.dart'),
'async': _u('sdk/lib/async/async.dart')
};
- var uriResolver = new UriResolver(packages, sdkLibraries, pathContext);
+ var uriResolver = new UriResolver(packages, sdkLibraries);
expect(uriResolver.resolve(Uri.parse(uriString)), expectedResult);
}
+ /// Prepends "file:///", plus a Windows drive letter if applicable, to the
+ /// given path.
+ String _fileUri(String pathPart) {
+ if (pathContext.separator == '/') {
+ return 'file:///$pathPart';
+ } else {
+ return 'file:///C:/$pathPart';
+ }
+ }
+
/// Converts a posix style path into a path appropriate for the current path
/// context.
String _p(String posixPath) {
- return pathContext.fromUri(_u(posixPath));
+ if (!posixPath.startsWith('/')) posixPath = '/$posixPath';
+ if (pathContext.separator == '/') return posixPath;
+ // Windows
+ return 'C:${posixPath.replaceAll('/', pathContext.separator)}';
}
/// Converts a posix style path into a file URI.
- Uri _u(String posixPath) => Uri.parse('file:///$posixPath');
+ Uri _u(String posixPath) => pathContext.toUri(_p(posixPath));
}
/// Override of [UriResolverTest] which uses the native path context for the
diff --git a/pkg/front_end/tool/example.dart b/pkg/front_end/tool/example.dart
index 1d49b22..d81f437 100644
--- a/pkg/front_end/tool/example.dart
+++ b/pkg/front_end/tool/example.dart
@@ -11,17 +11,19 @@
}
Future kernelToSink(Uri entry, StreamSink<List<int>> sink) async {
- var program = await kernelForProgram(entry,
+ var program = await kernelForProgram(
+ entry,
new CompilerOptions()
- ..sdkPath = 'sdk'
- ..packagesFilePath = '.packages'
+ ..sdkRoot = new Uri.file('sdk')
+ ..packagesFileUri = new Uri.file('.packages')
..onError = (e) => print(e.message));
await dumpToSink(program, sink);
}
main(args) async {
- kernelToSink(Uri.base.resolve(args[0]),
+ kernelToSink(
+ Uri.base.resolve(args[0]),
// TODO(sigmund,hausner): define memory type where to dump binary data.
new StreamController<List<int>>.broadcast().sink);
}
diff --git a/pkg/front_end/tool/perf.dart b/pkg/front_end/tool/perf.dart
index a69251b..7c4e4cd 100644
--- a/pkg/front_end/tool/perf.dart
+++ b/pkg/front_end/tool/perf.dart
@@ -115,15 +115,16 @@
var options = new CompilerOptions()
..strongMode = false
..compileSdk = compileSdk
- ..packagesFilePath = '.packages'
+ ..packagesFileUri = new Uri.file('.packages')
..onError = ((e) => print('${e.message}'));
if (useSdkSummary) {
// TODO(sigmund): adjust path based on the benchmark runner architecture.
// Possibly let the runner make the file available at an architecture
// independent location.
- options.sdkSummary = 'out/ReleaseX64/dart-sdk/lib/_internal/spec.sum';
+ options.sdkSummary =
+ new Uri.file('out/ReleaseX64/dart-sdk/lib/_internal/spec.sum');
} else {
- options.sdkPath = 'sdk';
+ options.sdkRoot = new Uri.file('sdk');
}
Program program = await kernelForProgram(entryUri, options);
dartkTimer.stop();
diff --git a/pkg/kernel/bin/dartk.dart b/pkg/kernel/bin/dartk.dart
index f6a6447..b8666a4 100755
--- a/pkg/kernel/bin/dartk.dart
+++ b/pkg/kernel/bin/dartk.dart
@@ -75,7 +75,9 @@
hide: true)
..addFlag('show-external',
help: 'When printing a library as text, also print its dependencies\n'
- 'on external libraries.');
+ 'on external libraries.')
+ ..addFlag('show-offsets',
+ help: 'When printing a library as text, also print node offsets');
String getUsage() => """
Usage: dartk [options] FILE
@@ -376,7 +378,9 @@
switch (format) {
case 'text':
writeProgramToText(program,
- path: outputFile, showExternal: options['show-external']);
+ path: outputFile,
+ showExternal: options['show-external'],
+ showOffsets: options['show-offsets']);
break;
case 'bin':
ioFuture = writeProgramToBinary(program, outputFile);
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index a016fed..a287dd6 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -196,6 +196,7 @@
type NormalClass extends Class {
Byte tag = 2;
+ FileOffset fileOffset;
Byte flags (isAbstract, isTypeLevel);
StringReference name;
// An absolute path URI to the .dart file from which the class was created.
@@ -211,6 +212,7 @@
type MixinClass extends Class {
Byte tag = 3;
+ FileOffset fileOffset;
Byte flags (isAbstract, isTypeLevel);
StringReference name;
// An absolute path URI to the .dart file from which the class was created.
@@ -228,6 +230,7 @@
type Field extends Member {
Byte tag = 4;
FileOffset fileOffset;
+ FileOffset fileEndOffset;
Byte flags (isFinal, isConst, isStatic);
Name name;
// An absolute path URI to the .dart file from which the field was created.
@@ -240,6 +243,8 @@
type Constructor extends Member {
Byte tag = 5;
+ FileOffset fileOffset;
+ FileOffset fileEndOffset;
Byte flags (isConst, isExternal);
Name name;
List<Expression> annotations;
@@ -259,6 +264,8 @@
type Procedure extends Member {
Byte tag = 6;
+ FileOffset fileOffset;
+ FileOffset fileEndOffset;
Byte kind; // Index into the ProcedureKind enum above.
Byte flags (isStatic, isAbstract, isExternal, isConst);
Name name;
@@ -309,7 +316,10 @@
type FunctionNode {
// Note: there is no tag on FunctionNode.
+ FileOffset fileOffset;
+ FileOffset fileEndOffset;
Byte asyncMarker; // Index into AsyncMarker above.
+ Byte debuggable; // 1 for yes, 0 for no
List<TypeParameter> typeParameters;
UInt requiredParameterCount;
List<VariableDeclaration> positionalParameters;
@@ -350,22 +360,26 @@
type VariableGet extends Expression {
Byte tag = 20;
+ FileOffset fileOffset;
VariableReference variable;
}
type SpecializedVariableGet extends Expression {
Byte tag = 128 + N; // Where 0 <= N < 8.
// Equivalent to a VariableGet with index N.
+ FileOffset fileOffset;
}
type VariableSet extends Expression {
Byte tag = 21;
+ FileOffset fileOffset;
VariableReference variable;
Expression value;
}
type SpecializedVariableSet extends Expression {
Byte tag = 136 + N; // Where 0 <= N < 8.
+ FileOffset fileOffset;
Expression value;
// Equivalent to VariableSet with index N.
}
@@ -518,11 +532,13 @@
type StringConcatenation extends Expression {
Byte tag = 36;
+ FileOffset fileOffset;
List<Expression> expressions;
}
type IsExpression extends Expression {
Byte tag = 37;
+ FileOffset fileOffset;
Expression operand;
DartType type;
}
@@ -613,6 +629,7 @@
type MapLiteral extends Expression {
Byte tag = 50;
+ FileOffset fileOffset;
DartType keyType;
DartType valueType;
List<MapEntry> entries;
@@ -759,6 +776,7 @@
type ReturnStatement extends Statement {
Byte tag = 74;
+ FileOffset fileOffset;
Option<Expression> expression;
}
@@ -783,6 +801,7 @@
type YieldStatement extends Statement {
Byte tag = 77;
+ FileOffset fileOffset;
Byte flags (isYieldStar);
Expression expression;
}
@@ -793,6 +812,7 @@
}
type VariableDeclaration {
+ FileOffset fileOffset;
Byte flags (isFinal, isConst);
// For named parameters, this is the parameter name.
// For other variables, the name is cosmetic, may be empty,
@@ -809,6 +829,7 @@
type FunctionDeclaration extends Statement {
Byte tag = 79;
+ FileOffset fileOffset;
// The variable binding the function. The variable is in scope
// within the function for use as a self-reference.
// Some of the fields in the variable are redundant, but its presence here
diff --git a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
index e232b29..7bf54a7 100644
--- a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
+++ b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
@@ -307,6 +307,11 @@
ast.DartType get defaultTypeParameterBound => getRootClassReference().rawType;
+ ast.TypeParameter tryGetTypeParameterReference(TypeParameterElement element) {
+ return localTypeParameters[element] ??
+ loader.tryGetClassTypeParameter(element);
+ }
+
ast.TypeParameter getTypeParameterReference(TypeParameterElement element) {
return localTypeParameters[element] ??
loader.tryGetClassTypeParameter(element) ??
@@ -385,7 +390,8 @@
.toList();
}
return new List<ast.DartType>.filled(
- genericFunctionType.typeParameters.length, const ast.DynamicType());
+ genericFunctionType.typeParameters.length, const ast.DynamicType(),
+ growable: true);
} else {
return <ast.DartType>[];
}
@@ -472,7 +478,7 @@
positionalParameters: positional,
namedParameters: named,
requiredParameterCount: requiredParameterCount,
- returnType: returnType);
+ returnType: returnType)..fileOffset = element.nameOffset;
}
}
@@ -566,6 +572,8 @@
break;
}
}
+ int offset = formalParameters?.offset ?? body.offset;
+ int endOffset = body.endToken.offset;
return new ast.FunctionNode(buildOptionalFunctionBody(body),
typeParameters: typeParameters,
positionalParameters: positional,
@@ -575,7 +583,9 @@
inferredReturnType ??
const ast.DynamicType(),
asyncMarker: getAsyncMarker(
- isAsync: body.isAsynchronous, isStar: body.isGenerator));
+ isAsync: body.isAsynchronous, isStar: body.isGenerator))
+ ..fileOffset = offset
+ ..fileEndOffset = endOffset;
}
ast.Expression buildOptionalTopLevelExpression(Expression node) {
@@ -636,7 +646,8 @@
ast.VariableDeclaration getVariableReference(LocalElement element) {
return localVariables.putIfAbsent(element, () {
return new ast.VariableDeclaration(element.name,
- isFinal: isFinal(element), isConst: isConst(element));
+ isFinal: isFinal(element),
+ isConst: isConst(element))..fileOffset = element.nameOffset;
});
}
@@ -900,11 +911,19 @@
StatementBuilder(this.scope, [this.breakStack, this.continueStack]);
ast.Statement build(Statement node) {
- return node.accept(this);
+ ast.Statement result = node.accept(this);
+ result.fileOffset = _getOffset(node);
+ return result;
}
ast.Statement buildOptional(Statement node) {
- return node?.accept(this);
+ ast.Statement result = node?.accept(this);
+ result?.fileOffset = _getOffset(node);
+ return result;
+ }
+
+ int _getOffset(AstNode node) {
+ return node.offset;
}
ast.Statement buildInScope(
@@ -1171,6 +1190,28 @@
return loop;
}
+ DartType iterableElementType(DartType iterable) {
+ if (iterable is InterfaceType) {
+ var iterator = iterable.lookUpInheritedGetter('iterator')?.returnType;
+ if (iterator is InterfaceType) {
+ return iterator.lookUpInheritedGetter('current')?.returnType;
+ }
+ }
+ return null;
+ }
+
+ DartType streamElementType(DartType stream) {
+ if (stream is InterfaceType) {
+ var class_ = stream.element;
+ if (class_.library.isDartAsync &&
+ class_.name == 'Stream' &&
+ stream.typeArguments.length == 1) {
+ return stream.typeArguments[0];
+ }
+ }
+ return null;
+ }
+
ast.Statement visitForEachStatement(ForEachStatement node) {
ast.VariableDeclaration variable;
Accessor leftHand;
@@ -1180,8 +1221,16 @@
type: scope.buildOptionalTypeAnnotation(loopVariable.type));
} else if (node.identifier != null) {
leftHand = scope.buildLeftHandValue(node.identifier);
- // TODO: In strong mode, set variable type based on iterable type.
variable = new ast.VariableDeclaration(null, isFinal: true);
+ if (scope.strongMode) {
+ var containerType = node.iterable.staticType;
+ DartType elementType = node.awaitKeyword != null
+ ? streamElementType(containerType)
+ : iterableElementType(containerType);
+ if (elementType != null) {
+ variable.type = scope.buildType(elementType);
+ }
+ }
}
var breakNode = new LabelStack.unlabeled(breakStack);
var continueNode = new LabelStack.unlabeled(continueStack);
@@ -1208,7 +1257,7 @@
variable,
scope.buildExpression(node.iterable),
makeBreakTarget(body, continueNode),
- isAsync: node.awaitKeyword != null);
+ isAsync: node.awaitKeyword != null)..fileOffset = node.offset;
return makeBreakTarget(loop, breakNode);
}
@@ -1279,14 +1328,14 @@
var declaration = node.functionDeclaration;
var expression = declaration.functionExpression;
LocalElement element = declaration.element as dynamic; // Cross cast.
- // TODO: Set a function type on the variable.
return new ast.FunctionDeclaration(
- scope.makeVariableDeclaration(element),
+ scope.makeVariableDeclaration(element,
+ type: scope.buildType(declaration.element.type)),
scope.buildFunctionNode(expression.parameters, expression.body,
typeParameters: scope.buildOptionalTypeParameterList(
expression.typeParameters,
strongModeOnly: true),
- returnType: declaration.returnType));
+ returnType: declaration.returnType))..fileOffset = node.offset;
}
@override
@@ -1320,6 +1369,14 @@
return node.identifier.offset;
} else if (node is AssignmentExpression) {
return _getOffset(node.leftHandSide);
+ } else if (node is PropertyAccess) {
+ return node.propertyName.offset;
+ } else if (node is IsExpression) {
+ return node.isOperator.offset;
+ } else if (node is StringLiteral) {
+ // Use a catch-all for StringInterpolation and AdjacentStrings:
+ // the debugger stops at the end.
+ return node.end;
}
return node.offset;
}
@@ -1353,6 +1410,7 @@
// Cut off the trailing '='.
var name = new ast.Name(operator.substring(0, operator.length - 1));
return leftHand.buildCompoundAssignment(name, rightHand,
+ offset: node.offset,
voidContext: voidContext,
interfaceTarget: scope.resolveInterfaceMethod(node.staticElement));
}
@@ -1376,7 +1434,7 @@
ast.Expression leftOperand = build(node.leftOperand);
if (leftOperand is ast.VariableGet) {
return new ast.ConditionalExpression(
- buildIsNull(leftOperand),
+ buildIsNull(leftOperand, offset: node.leftOperand.offset),
build(node.rightOperand),
new ast.VariableGet(leftOperand.variable),
scope.getInferredType(node));
@@ -1385,7 +1443,8 @@
return new ast.Let(
variable,
new ast.ConditionalExpression(
- buildIsNull(new ast.VariableGet(variable)),
+ buildIsNull(new ast.VariableGet(variable),
+ offset: leftOperand.fileOffset),
build(node.rightOperand),
new ast.VariableGet(variable),
scope.getInferredType(node)));
@@ -1894,7 +1953,7 @@
new ast.VariableGet(receiver),
scope.buildName(node.methodName),
buildArgumentsForInvocation(node),
- element),
+ element)..fileOffset = node.methodName.offset,
scope.buildType(node.staticType)));
} else {
return buildDecomposableMethodInvocation(
@@ -1929,6 +1988,7 @@
var leftHand = buildLeftHandValue(node.operand);
var binaryOperator = new ast.Name(operator[0]);
return leftHand.buildPostfixIncrement(binaryOperator,
+ offset: node.offset,
voidContext: isInVoidContext(node),
interfaceTarget: scope.resolveInterfaceMethod(node.staticElement));
@@ -1962,6 +2022,7 @@
var leftHand = buildLeftHandValue(node.operand);
var binaryOperator = new ast.Name(operator[0]);
return leftHand.buildPrefixIncrement(binaryOperator,
+ offset: node.offset,
interfaceTarget: scope.resolveInterfaceMethod(node.staticElement));
default:
@@ -2125,7 +2186,15 @@
return const ast.DynamicType();
}
if (boundVariables == null || boundVariables.contains(type)) {
- var typeParameter = scope.getTypeParameterReference(type.element);
+ var typeParameter = scope.tryGetTypeParameterReference(type.element);
+ if (typeParameter == null) {
+ // The analyzer sometimes gives us a type parameter that was not
+ // bound anywhere. Make sure we do not emit a dangling reference.
+ if (type.element.bound != null) {
+ return convertType(type.element.bound, []);
+ }
+ return const ast.DynamicType();
+ }
if (!scope.allowClassTypeParameters &&
typeParameter.parent is ast.Class) {
return const ast.InvalidType();
@@ -2353,7 +2422,8 @@
currentClass.name = element.name;
currentClass.supertype = scope.getRootClassReference().asRawSupertype;
currentClass.constructors.add(
- new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement())));
+ new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement()))
+ ..fileOffset = element.nameOffset);
}
void addAnnotations(List<Annotation> annotations) {
@@ -2487,35 +2557,55 @@
visitEnumDeclaration(EnumDeclaration node) {
addAnnotations(node.metadata);
ast.Class classNode = currentClass;
+
var intType = scope.loader.getCoreClassReference('int').rawType;
var indexFieldElement = element.fields.firstWhere(_isIndexField);
ast.Field indexField = scope.getMemberReference(indexFieldElement);
indexField.type = intType;
classNode.addMember(indexField);
- var parameter = new ast.VariableDeclaration('index', type: intType);
+
+ var stringType = scope.loader.getCoreClassReference('String').rawType;
+ ast.Field nameField = new ast.Field(
+ new ast.Name('_name', scope.currentLibrary),
+ type: stringType,
+ isFinal: true,
+ fileUri: classNode.fileUri);
+ classNode.addMember(nameField);
+
+ var indexParameter = new ast.VariableDeclaration('index', type: intType);
+ var nameParameter = new ast.VariableDeclaration('name', type: stringType);
var function = new ast.FunctionNode(new ast.EmptyStatement(),
- positionalParameters: [parameter]);
+ positionalParameters: [indexParameter, nameParameter]);
var superConstructor = scope.loader.getRootClassConstructorReference();
var constructor = new ast.Constructor(function,
name: new ast.Name(''),
isConst: true,
initializers: [
- new ast.FieldInitializer(indexField, new ast.VariableGet(parameter)),
+ new ast.FieldInitializer(
+ indexField, new ast.VariableGet(indexParameter)),
+ new ast.FieldInitializer(
+ nameField, new ast.VariableGet(nameParameter)),
new ast.SuperInitializer(superConstructor, new ast.Arguments.empty())
- ]);
+ ])..fileOffset = element.nameOffset;
classNode.addMember(constructor);
+
int index = 0;
var enumConstantFields = <ast.Field>[];
for (var constant in node.constants) {
ast.Field field = scope.getMemberReference(constant.element);
field.initializer = new ast.ConstructorInvocation(
- constructor, new ast.Arguments([new ast.IntLiteral(index)]),
+ constructor,
+ new ast.Arguments([
+ new ast.IntLiteral(index),
+ new ast.StringLiteral('${classNode.name}.${field.name.name}')
+ ]),
isConst: true)..parent = field;
field.type = classNode.rawType;
classNode.addMember(field);
++index;
enumConstantFields.add(field);
}
+
// Add the 'values' field.
var valuesFieldElement = element.fields.firstWhere(_isValuesField);
ast.Field valuesField = scope.getMemberReference(valuesFieldElement);
@@ -2527,7 +2617,15 @@
isConst: true,
typeArgument: enumType)..parent = valuesField;
classNode.addMember(valuesField);
- // TODO: Add the toString method.
+
+ // Add the 'toString()' method.
+ var body = new ast.ReturnStatement(
+ new ast.DirectPropertyGet(new ast.ThisExpression(), nameField));
+ var toStringFunction = new ast.FunctionNode(body, returnType: stringType);
+ var toStringMethod = new ast.Procedure(
+ new ast.Name('toString'), ast.ProcedureKind.Method, toStringFunction,
+ fileUri: classNode.fileUri);
+ classNode.addMember(toStringMethod);
}
visitClassTypeAlias(ClassTypeAlias node) {
@@ -2578,6 +2676,7 @@
void build(AstNode node) {
if (node != null) {
+ currentMember.fileEndOffset = node.endToken.offset;
node.accept(this);
} else {
buildBrokenMember();
diff --git a/pkg/kernel/lib/analyzer/loader.dart b/pkg/kernel/lib/analyzer/loader.dart
index 43a1b3d..cba5824 100644
--- a/pkg/kernel/lib/analyzer/loader.dart
+++ b/pkg/kernel/lib/analyzer/loader.dart
@@ -268,7 +268,7 @@
_classes[element] = classNode = new ast.Class(
name: element.name,
isAbstract: element.isAbstract,
- fileUri: '${element.source.uri}');
+ fileUri: '${element.source.uri}')..fileOffset = element.nameOffset;
classNode.level = ast.ClassLevel.Temporary;
var library = getLibraryReference(element.library);
library.addClass(classNode);
@@ -318,6 +318,9 @@
// Use a shared mixin application class for this library.
var mixinClass = getSharedMixinApplicationClass(
scope.currentLibrary, supertype.classNode, mixinType.classNode);
+ if (mixinClass.fileOffset < 0) {
+ mixinClass.fileOffset = element.nameOffset;
+ }
supertype = new ast.Supertype(
mixinClass,
supertype.typeArguments.length > mixinType.typeArguments.length
@@ -333,7 +336,7 @@
typeParameters: freshParameters.freshTypeParameters,
supertype: freshParameters.substituteSuper(supertype),
mixedInType: freshParameters.substituteSuper(mixinType),
- fileUri: classNode.fileUri);
+ fileUri: classNode.fileUri)..fileOffset = element.nameOffset;
mixinClass.level = ast.ClassLevel.Type;
supertype = new ast.Supertype(mixinClass,
classNode.typeParameters.map(makeTypeParameterType).toList());
@@ -446,12 +449,14 @@
isStatic: true,
isExternal: constructor.isExternal,
isConst: constructor.isConst,
- fileUri: '${element.source.uri}');
+ fileUri: '${element.source.uri}')
+ ..fileOffset = element.nameOffset;
}
return new ast.Constructor(scope.buildFunctionInterface(constructor),
name: _nameOfMember(element),
isConst: constructor.isConst,
- isExternal: constructor.isExternal);
+ isExternal: constructor.isExternal)
+ ..fileOffset = element.nameOffset;
case ElementKind.FIELD:
case ElementKind.TOP_LEVEL_VARIABLE:
@@ -480,7 +485,7 @@
isAbstract: executable.isAbstract,
isStatic: executable.isStatic,
isExternal: executable.isExternal,
- fileUri: '${element.source.uri}');
+ fileUri: '${element.source.uri}')..fileOffset = element.nameOffset;
default:
throw 'Unexpected member kind: $element';
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index aaf08707..f35e754 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -498,6 +498,11 @@
}
abstract class Member extends TreeNode {
+ /// End offset in the source file it comes from. Valid values are from 0 and
+ /// up, or -1 ([TreeNode.noOffset]) if the file end offset is not available
+ /// (this is the default if none is specifically set).
+ int fileEndOffset = TreeNode.noOffset;
+
/// List of metadata annotations on the member.
///
/// This defaults to an immutable empty list. Use [addAnnotation] to add
@@ -944,6 +949,10 @@
_MemberAccessor get _getterInterface => _reference;
_MemberAccessor get _setterInterface => _reference;
+
+ Location _getLocationInEnclosingFile(int offset) {
+ return enclosingProgram.getLocation(fileUri, offset);
+ }
}
enum ProcedureKind {
@@ -1104,7 +1113,13 @@
/// This may occur in a procedure, constructor, function expression, or local
/// function declaration.
class FunctionNode extends TreeNode {
+ /// End offset in the source file it comes from. Valid values are from 0 and
+ /// up, or -1 ([TreeNode.noOffset]) if the file end offset is not available
+ /// (this is the default if none is specifically set).
+ int fileEndOffset = TreeNode.noOffset;
+
AsyncMarker asyncMarker;
+ bool debuggable = true;
List<TypeParameter> typeParameters;
int requiredParameterCount;
List<VariableDeclaration> positionalParameters;
@@ -3547,7 +3562,7 @@
int lineIndex = low;
int lineStart = lines[lineIndex];
int lineNumber = 1 + lineIndex;
- int columnNumber = offset - lineStart;
+ int columnNumber = 1 + offset - lineStart;
return new Location(file, lineNumber, columnNumber);
}
}
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index 0dee08d..8c940f6 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -321,6 +321,7 @@
}
void readNormalClass(Class node) {
+ node.fileOffset = readOffset();
int flags = readByte();
node.isAbstract = flags & 0x1 != 0;
node.level = _currentLibrary.isExternal
@@ -347,6 +348,7 @@
}
void readMixinClass(Class node) {
+ node.fileOffset = readOffset();
int flags = readByte();
node.isAbstract = flags & 0x1 != 0;
node.level = _currentLibrary.isExternal
@@ -384,6 +386,7 @@
// consumed from the input.
assert(tag == Tag.Field);
node.fileOffset = readOffset();
+ node.fileEndOffset = readOffset();
node.flags = readByte();
node.name = readName();
node.fileUri = readUriReference();
@@ -399,6 +402,8 @@
void readConstructor(Constructor node, int tag) {
assert(tag == Tag.Constructor);
+ node.fileOffset = readOffset();
+ node.fileEndOffset = readOffset();
node.flags = readByte();
node.name = readName();
node.annotations = readAnnotationList(node);
@@ -414,6 +419,8 @@
void readProcedure(Procedure node, int tag) {
assert(tag == Tag.Procedure);
+ node.fileOffset = readOffset();
+ node.fileEndOffset = readOffset();
int kindIndex = readByte();
node.kind = ProcedureKind.values[kindIndex];
node.flags = readByte();
@@ -451,7 +458,10 @@
}
FunctionNode readFunctionNode() {
+ int offset = readOffset();
+ int endOffset = readOffset();
AsyncMarker asyncMarker = AsyncMarker.values[readByte()];
+ bool debuggable = readByte() == 1 ? true : false;
int typeParameterStackHeight = typeParameterStack.length;
var typeParameters = readAndPushTypeParameterList();
var requiredParameterCount = readUInt();
@@ -473,7 +483,10 @@
namedParameters: named,
returnType: returnType,
inferredReturnValue: inferredReturnValue,
- asyncMarker: asyncMarker);
+ asyncMarker: asyncMarker)
+ ..fileOffset = offset
+ ..fileEndOffset = endOffset
+ ..debuggable = debuggable;
}
void pushVariableDeclaration(VariableDeclaration variable) {
@@ -520,15 +533,22 @@
case Tag.InvalidExpression:
return new InvalidExpression();
case Tag.VariableGet:
- return new VariableGet(readVariableReference(), readDartTypeOption());
+ int offset = readOffset();
+ return new VariableGet(readVariableReference(), readDartTypeOption())
+ ..fileOffset = offset;
case Tag.SpecializedVariableGet:
int index = tagByte & Tag.SpecializedPayloadMask;
- return new VariableGet(variableStack[index]);
+ int offset = readOffset();
+ return new VariableGet(variableStack[index])..fileOffset = offset;
case Tag.VariableSet:
- return new VariableSet(readVariableReference(), readExpression());
+ int offset = readOffset();
+ return new VariableSet(readVariableReference(), readExpression())
+ ..fileOffset = offset;
case Tag.SpecializedVariableSet:
int index = tagByte & Tag.SpecializedPayloadMask;
- return new VariableSet(variableStack[index], readExpression());
+ int offset = readOffset();
+ return new VariableSet(variableStack[index], readExpression())
+ ..fileOffset = offset;
case Tag.PropertyGet:
int offset = readOffset();
return new PropertyGet(
@@ -597,9 +617,13 @@
return new ConditionalExpression(readExpression(), readExpression(),
readExpression(), readDartTypeOption());
case Tag.StringConcatenation:
- return new StringConcatenation(readExpressionList());
+ int offset = readOffset();
+ return new StringConcatenation(readExpressionList())
+ ..fileOffset = offset;
case Tag.IsExpression:
- return new IsExpression(readExpression(), readDartType());
+ int offset = readOffset();
+ return new IsExpression(readExpression(), readDartType())
+ ..fileOffset = offset;
case Tag.AsExpression:
return new AsExpression(readExpression(), readDartType());
case Tag.StringLiteral:
@@ -641,15 +665,21 @@
return new ListLiteral(readExpressionList(),
typeArgument: typeArgument, isConst: true);
case Tag.MapLiteral:
+ int offset = readOffset();
var keyType = readDartType();
var valueType = readDartType();
return new MapLiteral(readMapEntryList(),
- keyType: keyType, valueType: valueType, isConst: false);
+ keyType: keyType,
+ valueType: valueType,
+ isConst: false)..fileOffset = offset;
case Tag.ConstMapLiteral:
+ int offset = readOffset();
var keyType = readDartType();
var valueType = readDartType();
return new MapLiteral(readMapEntryList(),
- keyType: keyType, valueType: valueType, isConst: true);
+ keyType: keyType,
+ valueType: valueType,
+ isConst: true)..fileOffset = offset;
case Tag.AwaitExpression:
return new AwaitExpression(readExpression());
case Tag.FunctionExpression:
@@ -755,25 +785,29 @@
return new IfStatement(
readExpression(), readStatement(), readStatementOrNullIfEmpty());
case Tag.ReturnStatement:
- return new ReturnStatement(readExpressionOption());
+ int offset = readOffset();
+ return new ReturnStatement(readExpressionOption())..fileOffset = offset;
case Tag.TryCatch:
return new TryCatch(readStatement(), readCatchList());
case Tag.TryFinally:
return new TryFinally(readStatement(), readStatement());
case Tag.YieldStatement:
+ int offset = readOffset();
int flags = readByte();
return new YieldStatement(readExpression(),
isYieldStar: flags & YieldStatement.FlagYieldStar != 0,
- isNative: flags & YieldStatement.FlagNative != 0);
+ isNative: flags & YieldStatement.FlagNative != 0)
+ ..fileOffset = offset;
case Tag.VariableDeclaration:
var variable = readVariableDeclaration();
variableStack.add(variable); // Will be popped by the enclosing scope.
return variable;
case Tag.FunctionDeclaration:
+ int offset = readOffset();
var variable = readVariableDeclaration();
variableStack.add(variable); // Will be popped by the enclosing scope.
var function = readFunctionNode();
- return new FunctionDeclaration(variable, function);
+ return new FunctionDeclaration(variable, function)..fileOffset = offset;
default:
throw fail('Invalid statement tag: $tag');
}
@@ -925,13 +959,14 @@
}
VariableDeclaration readVariableDeclaration() {
+ int offset = readOffset();
int flags = readByte();
return new VariableDeclaration(readStringOrNullIfEmpty(),
type: readDartType(),
inferredValue: readOptionalInferredValue(),
initializer: readExpressionOption(),
isFinal: flags & 0x1 != 0,
- isConst: flags & 0x2 != 0);
+ isConst: flags & 0x2 != 0)..fileOffset = offset;
}
int readOffset() {
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 37dd80e..6d3dabd 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -203,11 +203,11 @@
}
}
- writeOffset(TreeNode node) {
+ writeOffset(TreeNode node, int offset) {
// TODO(jensj): Delta-encoding.
// File offset ranges from -1 and up,
// but is here saved as unsigned (thus the +1)
- writeUInt30(node.fileOffset + 1);
+ writeUInt30(offset + 1);
}
void visitClassReference(Class node) {
@@ -290,6 +290,7 @@
}
if (node.isMixinApplication) {
writeByte(Tag.MixinClass);
+ writeOffset(node, node.fileOffset);
writeByte(flags);
writeStringReference(node.name ?? '');
writeUriReference(node.fileUri ?? '');
@@ -303,6 +304,7 @@
_typeParameterIndexer.exit(node.typeParameters);
} else {
writeByte(Tag.NormalClass);
+ writeOffset(node, node.fileOffset);
writeByte(flags);
writeStringReference(node.name ?? '');
writeUriReference(node.fileUri ?? '');
@@ -323,6 +325,8 @@
visitConstructor(Constructor node) {
_variableIndexer = new VariableIndexer();
writeByte(Tag.Constructor);
+ writeOffset(node, node.fileOffset);
+ writeOffset(node, node.fileEndOffset);
writeByte(node.flags);
writeName(node.name ?? _emptyName);
writeAnnotationList(node.annotations);
@@ -338,6 +342,8 @@
visitProcedure(Procedure node) {
_variableIndexer = new VariableIndexer();
writeByte(Tag.Procedure);
+ writeOffset(node, node.fileOffset);
+ writeOffset(node, node.fileEndOffset);
writeByte(node.kind.index);
writeByte(node.flags);
writeName(node.name ?? '');
@@ -350,7 +356,8 @@
visitField(Field node) {
_variableIndexer = new VariableIndexer();
writeByte(Tag.Field);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
+ writeOffset(node, node.fileEndOffset);
writeByte(node.flags);
writeName(node.name ?? '');
writeUriReference(node.fileUri ?? '');
@@ -397,7 +404,10 @@
_switchCaseIndexer = new SwitchCaseIndexer();
// Note: FunctionNode has no tag.
_typeParameterIndexer.enter(node.typeParameters);
+ writeOffset(node, node.fileOffset);
+ writeOffset(node, node.fileEndOffset);
writeByte(node.asyncMarker.index);
+ writeByte(node.debuggable ? 1 : 0);
writeNodeList(node.typeParameters);
writeUInt30(node.requiredParameterCount);
writeVariableDeclarationList(node.positionalParameters);
@@ -422,8 +432,10 @@
if (index & Tag.SpecializedPayloadMask == index &&
node.promotedType == null) {
writeByte(Tag.SpecializedVariableGet + index);
+ writeOffset(node, node.fileOffset);
} else {
writeByte(Tag.VariableGet);
+ writeOffset(node, node.fileOffset);
writeUInt30(_variableIndexer[node.variable]);
writeOptionalNode(node.promotedType);
}
@@ -434,9 +446,11 @@
int index = _variableIndexer[node.variable];
if (index & Tag.SpecializedPayloadMask == index) {
writeByte(Tag.SpecializedVariableSet + index);
+ writeOffset(node, node.fileOffset);
writeNode(node.value);
} else {
writeByte(Tag.VariableSet);
+ writeOffset(node, node.fileOffset);
writeUInt30(_variableIndexer[node.variable]);
writeNode(node.value);
}
@@ -444,7 +458,7 @@
visitPropertyGet(PropertyGet node) {
writeByte(Tag.PropertyGet);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeNode(node.receiver);
writeName(node.name);
writeMemberReference(node.interfaceTarget, allowNull: true);
@@ -452,7 +466,7 @@
visitPropertySet(PropertySet node) {
writeByte(Tag.PropertySet);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeNode(node.receiver);
writeName(node.name);
writeNode(node.value);
@@ -487,7 +501,7 @@
visitStaticGet(StaticGet node) {
writeByte(Tag.StaticGet);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeMemberReference(node.target);
}
@@ -499,7 +513,7 @@
visitMethodInvocation(MethodInvocation node) {
writeByte(Tag.MethodInvocation);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeNode(node.receiver);
writeName(node.name);
writeNode(node.arguments);
@@ -508,7 +522,7 @@
visitSuperMethodInvocation(SuperMethodInvocation node) {
writeByte(Tag.SuperMethodInvocation);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeName(node.name);
writeNode(node.arguments);
writeMemberReference(node.interfaceTarget, allowNull: true);
@@ -523,7 +537,7 @@
visitStaticInvocation(StaticInvocation node) {
writeByte(node.isConst ? Tag.ConstStaticInvocation : Tag.StaticInvocation);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeMemberReference(node.target);
writeNode(node.arguments);
}
@@ -532,7 +546,7 @@
writeByte(node.isConst
? Tag.ConstConstructorInvocation
: Tag.ConstructorInvocation);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeMemberReference(node.target);
writeNode(node.arguments);
}
@@ -580,11 +594,13 @@
visitStringConcatenation(StringConcatenation node) {
writeByte(Tag.StringConcatenation);
+ writeOffset(node, node.fileOffset);
writeNodeList(node.expressions);
}
visitIsExpression(IsExpression node) {
writeByte(Tag.IsExpression);
+ writeOffset(node, node.fileOffset);
writeNode(node.operand);
writeNode(node.type);
}
@@ -655,7 +671,7 @@
visitThrow(Throw node) {
writeByte(Tag.Throw);
- writeOffset(node);
+ writeOffset(node, node.fileOffset);
writeNode(node.expression);
}
@@ -667,6 +683,7 @@
visitMapLiteral(MapLiteral node) {
writeByte(node.isConst ? Tag.ConstMapLiteral : Tag.MapLiteral);
+ writeOffset(node, node.fileOffset);
writeNode(node.keyType);
writeNode(node.valueType);
writeNodeList(node.entries);
@@ -801,6 +818,7 @@
visitReturnStatement(ReturnStatement node) {
writeByte(Tag.ReturnStatement);
+ writeOffset(node, node.fileOffset);
writeOptionalNode(node.expression);
}
@@ -828,6 +846,7 @@
visitYieldStatement(YieldStatement node) {
writeByte(Tag.YieldStatement);
+ writeOffset(node, node.fileOffset);
writeByte(node.flags);
writeNode(node.expression);
}
@@ -838,6 +857,7 @@
}
void writeVariableDeclaration(VariableDeclaration node) {
+ writeOffset(node, node.fileOffset);
writeByte(node.flags);
writeStringReference(node.name ?? '');
writeNode(node.type);
@@ -863,6 +883,7 @@
visitFunctionDeclaration(FunctionDeclaration node) {
writeByte(Tag.FunctionDeclaration);
+ writeOffset(node, node.fileOffset);
writeVariableDeclaration(node.variable);
writeNode(node.function);
}
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart
index c538127..6771cc4 100644
--- a/pkg/kernel/lib/class_hierarchy.dart
+++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -232,6 +232,15 @@
}
}
+ /// True if the program contains another class that is a subtype of given one.
+ bool hasProperSubtypes(Class class_) {
+ var info = _infoFor[class_];
+ var subtypes = info.subtypeIntervalList;
+ return !(subtypes.length == 2 &&
+ subtypes[0] == info.topDownIndex &&
+ subtypes[1] == info.topDownIndex + 1);
+ }
+
ClassHierarchy._internal(Program program, int numberOfClasses)
: classes = new List<Class>(numberOfClasses) {
// Build the class ordering based on a topological sort.
diff --git a/pkg/kernel/lib/clone.dart b/pkg/kernel/lib/clone.dart
index 4cfb9e8..3b9a6a2 100644
--- a/pkg/kernel/lib/clone.dart
+++ b/pkg/kernel/lib/clone.dart
@@ -341,7 +341,8 @@
isConst: node.isConst,
isExternal: node.isExternal,
initializers: node.initializers.map(clone).toList(),
- transformerFlags: node.transformerFlags);
+ transformerFlags: node.transformerFlags)
+ ..fileEndOffset = node.fileEndOffset;
}
visitProcedure(Procedure node) {
@@ -351,7 +352,7 @@
isExternal: node.isExternal,
isConst: node.isConst,
transformerFlags: node.transformerFlags,
- fileUri: node.fileUri);
+ fileUri: node.fileUri)..fileEndOffset = node.fileEndOffset;
}
visitField(Field node) {
@@ -364,7 +365,7 @@
hasImplicitGetter: node.hasImplicitGetter,
hasImplicitSetter: node.hasImplicitSetter,
transformerFlags: node.transformerFlags,
- fileUri: node.fileUri);
+ fileUri: node.fileUri)..fileEndOffset = node.fileEndOffset;
}
visitTypeParameter(TypeParameter node) {
@@ -386,7 +387,7 @@
namedParameters: named,
requiredParameterCount: node.requiredParameterCount,
returnType: visitType(node.returnType),
- asyncMarker: node.asyncMarker);
+ asyncMarker: node.asyncMarker)..fileEndOffset = node.fileEndOffset;
}
visitArguments(Arguments node) {
diff --git a/pkg/kernel/lib/frontend/accessors.dart b/pkg/kernel/lib/frontend/accessors.dart
index 17355b0..48bb2c5 100644
--- a/pkg/kernel/lib/frontend/accessors.dart
+++ b/pkg/kernel/lib/frontend/accessors.dart
@@ -42,30 +42,39 @@
}
Expression buildCompoundAssignment(Name binaryOperator, Expression value,
- {bool voidContext: false, Procedure interfaceTarget}) {
+ {int offset: TreeNode.noOffset,
+ bool voidContext: false,
+ Procedure interfaceTarget}) {
return _finish(_makeWrite(
- builtBinary =
- makeBinary(_makeRead(), binaryOperator, interfaceTarget, value),
+ builtBinary = makeBinary(
+ _makeRead(), binaryOperator, interfaceTarget, value,
+ offset: offset),
voidContext));
}
Expression buildPrefixIncrement(Name binaryOperator,
- {bool voidContext: false, Procedure interfaceTarget}) {
+ {int offset: TreeNode.noOffset,
+ bool voidContext: false,
+ Procedure interfaceTarget}) {
return buildCompoundAssignment(binaryOperator, new IntLiteral(1),
- voidContext: voidContext, interfaceTarget: interfaceTarget);
+ offset: offset,
+ voidContext: voidContext,
+ interfaceTarget: interfaceTarget);
}
Expression buildPostfixIncrement(Name binaryOperator,
- {bool voidContext: false, Procedure interfaceTarget}) {
+ {int offset: TreeNode.noOffset,
+ bool voidContext: false,
+ Procedure interfaceTarget}) {
if (voidContext) {
- return buildPrefixIncrement(binaryOperator,
+ return buildPrefixIncrement(binaryOperator, offset: offset,
voidContext: true, interfaceTarget: interfaceTarget);
}
var value = new VariableDeclaration.forValue(_makeRead());
valueAccess() => new VariableGet(value);
var dummy = new VariableDeclaration.forValue(_makeWrite(
- builtBinary = makeBinary(
- valueAccess(), binaryOperator, interfaceTarget, new IntLiteral(1)),
+ builtBinary = makeBinary(valueAccess(), binaryOperator, interfaceTarget,
+ new IntLiteral(1), offset: offset),
true));
return _finish(makeLet(value, makeLet(dummy, valueAccess())));
}
@@ -400,16 +409,19 @@
return new Let(variable, body);
}
-Expression makeBinary(Expression left, Name operator, Procedure interfaceTarget,
- Expression right) {
+Expression makeBinary(
+ Expression left, Name operator, Procedure interfaceTarget, Expression right,
+ {int offset: TreeNode.noOffset}) {
return new MethodInvocation(
- left, operator, new Arguments(<Expression>[right]), interfaceTarget);
+ left, operator, new Arguments(<Expression>[right]), interfaceTarget)
+ ..fileOffset = offset;
}
final Name _equalOperator = new Name('==');
-Expression buildIsNull(Expression value) {
- return makeBinary(value, _equalOperator, null, new NullLiteral());
+Expression buildIsNull(Expression value, {int offset: TreeNode.noOffset}) {
+ return makeBinary(value, _equalOperator, null, new NullLiteral(),
+ offset: offset);
}
VariableDeclaration makeOrReuseVariable(Expression value) {
diff --git a/pkg/kernel/lib/kernel.dart b/pkg/kernel/lib/kernel.dart
index 7675c9c..1d67fb3 100644
--- a/pkg/kernel/lib/kernel.dart
+++ b/pkg/kernel/lib/kernel.dart
@@ -51,9 +51,10 @@
}
void writeProgramToText(Program program,
- {String path, bool showExternal: false}) {
+ {String path, bool showExternal: false, bool showOffsets: false}) {
StringBuffer buffer = new StringBuffer();
- new Printer(buffer, showExternal: showExternal).writeProgramFile(program);
+ new Printer(buffer, showExternal: showExternal, showOffsets: showOffsets)
+ .writeProgramFile(program);
if (path == null) {
print(buffer);
} else {
diff --git a/pkg/kernel/lib/repository.dart b/pkg/kernel/lib/repository.dart
index 265a75c..73cc1a9 100644
--- a/pkg/kernel/lib/repository.dart
+++ b/pkg/kernel/lib/repository.dart
@@ -20,7 +20,7 @@
Library _buildLibraryReference(Uri uri) {
assert(uri.hasScheme);
- var library = new Library(uri, isExternal: true);
+ var library = new Library(uri, isExternal: true)..fileUri = '$uri';
libraries.add(library);
return library;
}
diff --git a/pkg/kernel/lib/target/vm.dart b/pkg/kernel/lib/target/vm.dart
index e6c5d94..58c229d 100644
--- a/pkg/kernel/lib/target/vm.dart
+++ b/pkg/kernel/lib/target/vm.dart
@@ -4,8 +4,11 @@
library kernel.target.vm;
import '../ast.dart';
+import '../core_types.dart';
import '../transformations/continuation.dart' as cont;
import '../transformations/erasure.dart';
+import '../transformations/insert_covariance_checks.dart';
+import '../transformations/insert_type_checks.dart';
import '../transformations/mixin_full_resolution.dart' as mix;
import '../transformations/sanitize_for_vm.dart';
import '../transformations/setup_builtin_library.dart' as setup_builtin_library;
@@ -51,7 +54,18 @@
];
void transformProgram(Program program) {
- new mix.MixinFullResolution().transform(program);
+ var mixins = new mix.MixinFullResolution();
+ mixins.transform(program);
+
+ if (strongMode) {
+ var hierarchy = mixins.hierarchy;
+ var coreTypes = new CoreTypes(program);
+ new InsertTypeChecks(hierarchy: hierarchy, coreTypes: coreTypes)
+ .transformProgram(program);
+ new InsertCovarianceChecks(hierarchy: hierarchy, coreTypes: coreTypes)
+ .transformProgram(program);
+ }
+
cont.transformProgram(program);
// Repair `_getMainClosure()` function in dart:_builtin.
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index 18be9de..a0e7227 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -181,6 +181,7 @@
int indentation = 0;
int column = 0;
bool showExternal;
+ bool showOffsets;
static int SPACE = 0;
static int WORD = 1;
@@ -190,6 +191,7 @@
Printer(this.sink,
{NameSystem syntheticNames,
this.showExternal,
+ this.showOffsets: false,
this.importTable,
this.annotator: const InferredValueAnnotator()})
: this.syntheticNames = syntheticNames ?? new NameSystem();
@@ -198,7 +200,8 @@
: sink = parent.sink,
syntheticNames = parent.syntheticNames,
annotator = parent.annotator,
- showExternal = parent.showExternal;
+ showExternal = parent.showExternal,
+ showOffsets = parent.showOffsets;
String getLibraryName(Library node) {
return node.name ?? syntheticNames.nameLibrary(node);
@@ -393,6 +396,9 @@
}
void writeNode(Node node) {
+ if (showOffsets && node is TreeNode) {
+ writeWord("[${node.fileOffset}]");
+ }
node.accept(this);
}
@@ -486,6 +492,7 @@
if (function.asyncMarker != AsyncMarker.Sync) {
writeSpaced(getAsyncMarkerKeyword(function.asyncMarker));
}
+ if (!function.debuggable) writeSpaced("/* not debuggable */");
if (function.body != null) {
writeFunctionBody(function.body, terminateLine: terminateLine);
} else if (terminateLine) {
@@ -626,6 +633,7 @@
}
void writeExpression(Expression node, [int minimumPrecedence]) {
+ if (showOffsets) writeWord("[${node.fileOffset}]");
bool needsParenteses = false;
if (minimumPrecedence != null && getPrecedence(node) < minimumPrecedence) {
needsParenteses = true;
@@ -983,6 +991,12 @@
visitVariableGet(VariableGet node) {
writeVariableReference(node.variable);
+ if (node.promotedType != null) {
+ writeSymbol('{');
+ writeNode(node.promotedType);
+ writeSymbol('}');
+ state = WORD;
+ }
}
visitVariableSet(VariableSet node) {
@@ -1287,6 +1301,7 @@
void writeVariableDeclaration(VariableDeclaration node,
{bool useVarKeyword: false}) {
+ if (showOffsets) writeWord("[${node.fileOffset}]");
writeModifier(node.isFinal, 'final');
writeModifier(node.isConst, 'const');
if (node.type != null) {
@@ -1380,6 +1395,9 @@
}
visitFunctionType(FunctionType node) {
+ if (state == WORD) {
+ ensureSpace();
+ }
writeTypeParameterList(node.typeParameters);
writeSymbol('(');
var positional = node.positionalParameters;
diff --git a/pkg/kernel/lib/transformations/async.dart b/pkg/kernel/lib/transformations/async.dart
index 972d8dc..b01f71a 100644
--- a/pkg/kernel/lib/transformations/async.dart
+++ b/pkg/kernel/lib/transformations/async.dart
@@ -409,17 +409,19 @@
final R = continuationRewriter;
var shouldName = seenAwait;
var result = new VariableGet(asyncResult);
+
// The statements are in reverse order, so name the result first if
// necessary and then add the two other statements in reverse.
if (shouldName) result = name(result);
- statements.add(R.createContinuationPoint());
+ statements.add(R.createContinuationPoint()..fileOffset = expr.fileOffset);
Arguments arguments = new Arguments(<Expression>[
expr.operand,
new VariableGet(R.thenContinuationVariable),
new VariableGet(R.catchErrorContinuationVariable)
]);
statements.add(new ExpressionStatement(
- new StaticInvocation(R.helper.awaitHelper, arguments)));
+ new StaticInvocation(R.helper.awaitHelper, arguments)
+ ..fileOffset = expr.fileOffset));
seenAwait = false;
var index = nameIndex;
diff --git a/pkg/kernel/lib/transformations/continuation.dart b/pkg/kernel/lib/transformations/continuation.dart
index 97ef172..f92d680 100644
--- a/pkg/kernel/lib/transformations/continuation.dart
+++ b/pkg/kernel/lib/transformations/continuation.dart
@@ -50,13 +50,12 @@
abstract class ContinuationRewriterBase extends RecursiveContinuationRewriter {
final FunctionNode enclosingFunction;
- int currentTryDepth; // Nesting depth for try-blocks.
+ int currentTryDepth = 0; // Nesting depth for try-blocks.
int currentCatchDepth = 0; // Nesting depth for catch-blocks.
int capturedTryDepth = 0; // Deepest yield point within a try-block.
int capturedCatchDepth = 0; // Deepest yield point within a catch-block.
- ContinuationRewriterBase(HelperNodes helper, this.enclosingFunction,
- {this.currentTryDepth: 0})
+ ContinuationRewriterBase(HelperNodes helper, this.enclosingFunction)
: super(helper);
Statement createContinuationPoint([Expression value]) {
@@ -68,28 +67,30 @@
TreeNode visitTryCatch(TryCatch node) {
if (node.body != null) {
- currentTryDepth++;
+ ++currentTryDepth;
node.body = node.body.accept(this);
node.body?.parent = node;
- currentTryDepth--;
+ --currentTryDepth;
}
- currentCatchDepth++;
+ ++currentCatchDepth;
transformList(node.catches, this, node);
- currentCatchDepth--;
+ --currentCatchDepth;
return node;
}
TreeNode visitTryFinally(TryFinally node) {
if (node.body != null) {
- currentTryDepth++;
+ ++currentTryDepth;
node.body = node.body.accept(this);
node.body?.parent = node;
- currentTryDepth--;
+ --currentTryDepth;
}
if (node.finalizer != null) {
+ ++currentCatchDepth;
node.finalizer = node.finalizer.accept(this);
node.finalizer?.parent = node;
+ --currentCatchDepth;
}
return node;
}
@@ -125,9 +126,12 @@
final function = new FunctionNode(buildClosureBody(),
positionalParameters: [iteratorVariable],
requiredParameterCount: 1,
- asyncMarker: AsyncMarker.SyncYielding);
+ asyncMarker: AsyncMarker.SyncYielding)
+ ..fileOffset = enclosingFunction.fileOffset
+ ..fileEndOffset = enclosingFunction.fileEndOffset;
final closureFunction =
- new FunctionDeclaration(nestedClosureVariable, function);
+ new FunctionDeclaration(nestedClosureVariable, function)
+ ..fileOffset = enclosingFunction.parent.fileOffset;
// return new _SyncIterable(:sync_body);
final arguments = new Arguments([new VariableGet(nestedClosureVariable)]);
@@ -186,8 +190,7 @@
ExpressionLifter expressionRewriter;
AsyncRewriterBase(helper, enclosingFunction)
- // Body is wrapped in the try-catch so initial currentTryDepth is 1.
- : super(helper, enclosingFunction, currentTryDepth: 1) {}
+ : super(helper, enclosingFunction) {}
void setupAsyncContinuations(List<Statement> statements) {
expressionRewriter = new ExpressionLifter(this);
@@ -209,7 +212,9 @@
final function = new FunctionNode(buildWrappedBody(),
positionalParameters: parameters,
requiredParameterCount: 0,
- asyncMarker: AsyncMarker.SyncYielding);
+ asyncMarker: AsyncMarker.SyncYielding)
+ ..fileOffset = enclosingFunction.fileOffset
+ ..fileEndOffset = enclosingFunction.fileEndOffset;
// The await expression lifter might have created a number of
// [VariableDeclarations].
@@ -220,7 +225,8 @@
// Now add the closure function itself.
final closureFunction =
- new FunctionDeclaration(nestedClosureVariable, function);
+ new FunctionDeclaration(nestedClosureVariable, function)
+ ..fileOffset = enclosingFunction.parent.fileOffset;
statements.add(closureFunction);
// :async_op_then = _asyncThenWrapperHelper(asyncBody);
@@ -241,9 +247,11 @@
}
Statement buildWrappedBody() {
+ ++currentTryDepth;
labeledBody = new LabeledStatement(null);
labeledBody.body = visitDelimited(enclosingFunction.body)
..parent = labeledBody;
+ --currentTryDepth;
var exceptionVariable = new VariableDeclaration(":exception");
var stackTraceVariable = new VariableDeclaration(":stack_trace");
@@ -535,7 +543,7 @@
var condition = new AwaitExpression(new MethodInvocation(
new VariableGet(iteratorVariable),
new Name('moveNext'),
- new Arguments(<Expression>[])));
+ new Arguments(<Expression>[])))..fileOffset = stmt.fileOffset;
// var <variable> = iterator.current;
var valueVariable = stmt.variable;
@@ -611,7 +619,9 @@
++currentTryDepth;
stmt.body = visitDelimited(stmt.body)..parent = stmt;
--currentTryDepth;
+ ++currentCatchDepth;
stmt.finalizer = visitDelimited(stmt.finalizer)..parent = stmt;
+ --currentCatchDepth;
statements.add(stmt);
return null;
}
@@ -659,8 +669,9 @@
// :controller = new _AsyncController(:async_op);
var arguments =
new Arguments(<Expression>[new VariableGet(nestedClosureVariable)]);
- var buildController = new ConstructorInvocation(
- helper.streamControllerConstructor, arguments);
+ var buildController =
+ new ConstructorInvocation(helper.streamControllerConstructor, arguments)
+ ..fileOffset = enclosingFunction.fileOffset;
var setController = new ExpressionStatement(
new VariableSet(controllerVariable, buildController));
statements.add(setController);
@@ -677,10 +688,24 @@
return enclosingFunction;
}
+ Statement buildWrappedBody() {
+ ++currentTryDepth;
+ Statement body = super.buildWrappedBody();
+ --currentTryDepth;
+
+ var finallyBody = new ExpressionStatement(new MethodInvocation(
+ new VariableGet(controllerVariable),
+ new Name("close", helper.asyncLibrary),
+ new Arguments(<Expression>[])));
+
+ var tryFinally = new TryFinally(body, new Block(<Statement>[finallyBody]));
+ return tryFinally;
+ }
+
Statement buildCatchBody(exceptionVariable, stackTraceVariable) {
return new ExpressionStatement(new MethodInvocation(
new VariableGet(controllerVariable),
- new Name("completeError", helper.asyncLibrary),
+ new Name("addError", helper.asyncLibrary),
new Arguments(<Expression>[
new VariableGet(exceptionVariable),
new VariableGet(stackTraceVariable)
@@ -692,11 +717,7 @@
// have been translated into breaks from the labeled body.
return new Block(<Statement>[
body,
- new ExpressionStatement(new MethodInvocation(
- new VariableGet(controllerVariable),
- new Name("close", helper.asyncLibrary),
- new Arguments(<Expression>[]))),
- new ReturnStatement()
+ new ReturnStatement()..fileOffset = enclosingFunction.fileEndOffset,
]);
}
@@ -706,10 +727,12 @@
var addExpression = new MethodInvocation(
new VariableGet(controllerVariable),
new Name(stmt.isYieldStar ? 'addStream' : 'add', helper.asyncLibrary),
- new Arguments(<Expression>[expr]));
+ new Arguments(<Expression>[expr]))..fileOffset = stmt.fileOffset;
- statements.add(new IfStatement(addExpression,
- new ReturnStatement(new NullLiteral()), createContinuationPoint()));
+ statements.add(new IfStatement(
+ addExpression,
+ new ReturnStatement(new NullLiteral()),
+ createContinuationPoint()..fileOffset = stmt.fileOffset));
return null;
}
@@ -735,7 +758,8 @@
// var :completer = new Completer.sync();
completerVariable = new VariableDeclaration(":completer",
initializer: new StaticInvocation(helper.completerConstructor,
- new Arguments([], types: [const DynamicType()])),
+ new Arguments([], types: [const DynamicType()]))
+ ..fileOffset = enclosingFunction.body.fileOffset,
isFinal: true);
statements.add(completerVariable);
@@ -748,7 +772,8 @@
var newMicrotaskStatement = new ExpressionStatement(new StaticInvocation(
helper.futureMicrotaskConstructor,
new Arguments([new VariableGet(nestedClosureVariable)],
- types: [const DynamicType()])));
+ types: [const DynamicType()]))
+ ..fileOffset = enclosingFunction.fileOffset);
statements.add(newMicrotaskStatement);
// return :completer.future;
@@ -760,6 +785,7 @@
enclosingFunction.body = new Block(statements);
enclosingFunction.body.parent = enclosingFunction;
enclosingFunction.asyncMarker = AsyncMarker.Sync;
+ enclosingFunction.debuggable = false;
return enclosingFunction;
}
@@ -782,7 +808,7 @@
new VariableGet(completerVariable),
new Name("complete", helper.asyncLibrary),
new Arguments([new VariableGet(returnVariable)]))),
- new ReturnStatement()
+ new ReturnStatement()..fileOffset = enclosingFunction.fileEndOffset
]);
}
diff --git a/pkg/kernel/lib/transformations/insert_covariance_checks.dart b/pkg/kernel/lib/transformations/insert_covariance_checks.dart
new file mode 100644
index 0000000..b4e1869
--- /dev/null
+++ b/pkg/kernel/lib/transformations/insert_covariance_checks.dart
@@ -0,0 +1,516 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+library kernel.transformations.insert_covariance_checks;
+
+import '../class_hierarchy.dart';
+import '../clone.dart';
+import '../core_types.dart';
+import '../kernel.dart';
+import '../log.dart';
+import '../type_algebra.dart';
+import '../type_environment.dart';
+
+// TODO: Should helper be removed?
+DartType substituteBounds(DartType type, Map<TypeParameter, DartType> upper,
+ Map<TypeParameter, DartType> lower) {
+ return Substitution
+ .fromUpperAndLowerBounds(upper, lower)
+ .substituteType(type);
+}
+
+/// Inserts checked entry points for methods in order to enforce type safety
+/// in face on covariant subtyping.
+///
+/// An 'unsafe parameter' is a parameter whose type mentions a class type
+/// parameter T, but is not contravariant in T. For instance, the argument
+/// to `List.add` is unsafe, whereas the function parameter to `List.forEach`
+/// is safe:
+///
+/// class List<T> {
+/// ...
+/// void add(T x) {...} // unsafe
+/// void forEach(void action(T x)) {...} // safe
+/// }
+///
+/// For every method with unsafe parameters, a checked entry point suffixed
+/// with `$cc` is inserted, which casts the unsafe parameters to their expected
+/// types and calls the actual implementation:
+///
+/// class List<T> {
+/// ...
+/// void add$cc(Object x) => this.add(x as T);
+/// }
+///
+/// Calls whose interface target declares unsafe parameters are then rewritten
+/// to target the `$cc` entry point instead, unless it can be determined that
+/// the type argument is exact. For example:
+///
+/// void foo(List<num> numbers) {
+/// numbers.add(3.5); // before
+/// numbers.add$cc(3.5); // after
+/// }
+///
+/// Currently, we only deduce that the type arguments are exact when the
+/// receiver is `this`.
+class InsertCovarianceChecks {
+ ClassHierarchy hierarchy;
+ CoreTypes coreTypes;
+ TypeEnvironment types;
+
+ /// Maps unsafe members to their checked entry point, to be used at call sites
+ /// where the arguments cannot be guaranteed to satisfy the generic parameter
+ /// types of the actual target.
+ final Map<Member, Procedure> unsafeMemberEntryPoint = <Member, Procedure>{};
+
+ /// Members that may be invoked through a checked entry point.
+ ///
+ /// Note that these members are not necessarily unsafe, because a safe member
+ /// can override an unsafe member, and thereby be invoked through a checked
+ /// entry point. This set is not therefore not the same as the set of keys
+ /// in [unsafeMemberEntryPoint].
+ final Set<Member> membersWithCheckedEntryPoint = new Set<Member>();
+
+ InsertCovarianceChecks({this.hierarchy, this.coreTypes});
+
+ void transformProgram(Program program) {
+ hierarchy ??= new ClassHierarchy(program);
+ coreTypes ??= new CoreTypes(program);
+ types = new TypeEnvironment(coreTypes, hierarchy);
+ // We transform every class before their subtypes.
+ // This ensures that transitive overrides are taken into account.
+ hierarchy.classes.forEach(transformClass);
+
+ program.accept(new _CallTransformer(this));
+ }
+
+ void transformClass(Class class_) {
+ new _ClassTransformer(class_, this).transformClass();
+ }
+}
+
+class _ClassTransformer {
+ final Class host;
+ final ClassHierarchy hierarchy;
+ final TypeEnvironment types;
+ final InsertCovarianceChecks global;
+
+ final Map<Field, VariableDeclaration> fieldSetterParameter =
+ <Field, VariableDeclaration>{};
+
+ final Map<VariableDeclaration, List<DartType>> unsafeParameterTypes =
+ new Map<VariableDeclaration, List<DartType>>();
+
+ // The following four maps translate types from the context of a supertype
+ // into the context of the current class.
+ //
+ // When analyzing an override relation "ownMember <: superMember", the two
+ // "own" maps translate types from the context of the ownMember, while the
+ // "super" maps translate types from the context of superMember.
+ //
+ // The "substitution" maps translate type parameters to their exact type,
+ // while the "upper bound" maps translate type parameters to their erased
+ // upper bounds.
+ Map<TypeParameter, DartType> ownSubstitution;
+ Map<TypeParameter, DartType> ownUpperBounds;
+ Map<TypeParameter, DartType> superSubstitution;
+ Map<TypeParameter, DartType> superUpperBounds;
+
+ /// Members for which a checked entry point must be created in this current
+ /// class.
+ Set<Member> membersNeedingCheckedEntryPoint = new Set<Member>();
+
+ _ClassTransformer(this.host, InsertCovarianceChecks global)
+ : hierarchy = global.hierarchy,
+ types = global.types,
+ this.global = global;
+
+ /// Mark [parameter] unsafe, with [type] as a potential argument type.
+ void addUnsafeParameter(
+ VariableDeclaration parameter, DartType type, Member member) {
+ unsafeParameterTypes.putIfAbsent(parameter, () => <DartType>[]).add(type);
+ requireLocalCheckedEntryPoint(member);
+ }
+
+ /// Get a parameter representing the argument to the implicit setter
+ /// for [field].
+ VariableDeclaration getFieldSetterParameter(Field field) {
+ return fieldSetterParameter.putIfAbsent(field, () {
+ return new VariableDeclaration('${field.name.name}_', type: field.type);
+ });
+ }
+
+ /// Mark [field] as unsafe, with [type] as a potential argument to its setter.
+ void addUnsafeField(Field field, DartType type) {
+ addUnsafeParameter(getFieldSetterParameter(field), type, field);
+ }
+
+ /// True if [member] can be invoked through a checked entry point.
+ ///
+ /// This does not imply that the member has unsafe parameters.
+ bool hasCheckedEntryPoint(Member member, {bool setter: false}) {
+ if (!setter && member is Field) {
+ return false; // Field getters never have checked entry points.
+ }
+ return global.membersWithCheckedEntryPoint.contains(member);
+ }
+
+ /// Ensures that a checked entry point for [member] will be emitted in the
+ /// current class.
+ void requireLocalCheckedEntryPoint(Member member) {
+ if (membersNeedingCheckedEntryPoint.add(member)) {
+ global.membersWithCheckedEntryPoint.add(member);
+ }
+ }
+
+ void transformClass() {
+ if (host.isMixinApplication) {
+ // TODO(asgerf): We need a way to support mixin applications with unsafe
+ // overrides. This version assumes mixins have been resolved by cloning.
+ // We could generate a subclass of the mixin application containing the
+ // checked entry points.
+ throw 'Mixin applications must be resolved before inserting covariance '
+ 'checks';
+ }
+ // Find parameters with an unsafe reference to a class type parameter.
+ if (host.typeParameters.isNotEmpty) {
+ var upperBounds = getUpperBoundSubstitutionMap(host);
+ for (var field in host.fields) {
+ if (field.hasImplicitSetter) {
+ var rawType = substituteBounds(field.type, upperBounds, {});
+ if (!identical(rawType, field.type)) {
+ requireLocalCheckedEntryPoint(field);
+ addUnsafeField(field, rawType);
+ }
+ }
+ }
+ for (var procedure in host.procedures) {
+ if (procedure.isStatic) continue;
+ void handleParameter(VariableDeclaration parameter) {
+ var rawType = substituteBounds(parameter.type, upperBounds, {});
+ if (!identical(rawType, parameter.type)) {
+ requireLocalCheckedEntryPoint(procedure);
+ addUnsafeParameter(parameter, rawType, procedure);
+ }
+ }
+
+ procedure.function.positionalParameters.forEach(handleParameter);
+ procedure.function.namedParameters.forEach(handleParameter);
+ }
+ }
+
+ // Find (possibly inherited) members that override a method that has
+ // unsafe parameters.
+ hierarchy.forEachOverridePair(host,
+ (Member ownMember, Member superMember, bool isSetter) {
+ if (hasCheckedEntryPoint(superMember, setter: isSetter)) {
+ requireLocalCheckedEntryPoint(ownMember);
+ }
+ if (superMember.enclosingClass.typeParameters.isEmpty) return;
+ ownSubstitution = getSubstitutionMap(
+ hierarchy.getClassAsInstanceOf(host, ownMember.enclosingClass));
+ ownUpperBounds = getUpperBoundSubstitutionMap(ownMember.enclosingClass);
+ superSubstitution = getSubstitutionMap(
+ hierarchy.getClassAsInstanceOf(host, superMember.enclosingClass));
+ superUpperBounds =
+ getUpperBoundSubstitutionMap(superMember.enclosingClass);
+ if (ownMember is Procedure) {
+ if (superMember is Procedure) {
+ checkProcedureOverride(ownMember, superMember);
+ } else if (superMember is Field && isSetter) {
+ checkSetterFieldOverride(ownMember, superMember);
+ }
+ } else if (isSetter) {
+ checkFieldOverride(ownMember, superMember);
+ }
+ });
+
+ for (Member member in membersNeedingCheckedEntryPoint) {
+ ownSubstitution = getSubstitutionMap(
+ hierarchy.getClassAsInstanceOf(host, member.enclosingClass));
+ ownSubstitution = ensureMutable(ownSubstitution);
+ generateCheckedEntryPoint(member);
+ }
+ }
+
+ /// Compute an upper bound of the types in [inputTypes].
+ ///
+ /// We use this to compute a trustworthy type for a parameter, given a list
+ /// of types that may actually be passed into the parameter.
+ DartType getSafeType(List<DartType> inputTypes) {
+ var safeType = inputTypes[0];
+ for (int i = 1; i < inputTypes.length; ++i) {
+ if (inputTypes[i] != safeType) {
+ // Multiple types are being overridden. Fall back to dynamic.
+ // There are cases where a better upper bound could be found, but they
+ // are quite rare.
+ return const DynamicType();
+ }
+ }
+ return safeType;
+ }
+
+ void fail(String message) {
+ log.warning('[unsoundness] $message');
+ }
+
+ void checkFieldOverride(Field field, Member superMember) {
+ var fieldType =
+ substituteBounds(field.type, ownUpperBounds, ownSubstitution);
+ var superType = substituteBounds(
+ superMember.setterType, superUpperBounds, superSubstitution);
+ if (!types.isSubtypeOf(superType, fieldType)) {
+ addUnsafeField(field, superType);
+ }
+ }
+
+ void checkSetterFieldOverride(Procedure ownMember, Field superMember) {
+ assert(ownMember.isSetter);
+ var ownParameter = ownMember.function.positionalParameters[0];
+ var ownType =
+ substituteBounds(ownParameter.type, ownUpperBounds, ownSubstitution);
+ var superType = substituteBounds(
+ superMember.setterType, superUpperBounds, superSubstitution);
+ if (!types.isSubtypeOf(superType, ownType)) {
+ addUnsafeParameter(ownParameter, superType, ownMember);
+ }
+ }
+
+ void checkProcedureOverride(Procedure ownMember, Procedure superMember) {
+ var ownFunction = ownMember.function;
+ var superFunction = superMember.function;
+ // We perform some checks here to avoid crashing, but the frontend is
+ // responsible for generating IR that does not violate these restrictions.
+ if (ownFunction.requiredParameterCount >
+ superFunction.requiredParameterCount) {
+ fail('$ownMember requires more parameters than $superMember');
+ return;
+ }
+ if (ownFunction.positionalParameters.length <
+ superFunction.positionalParameters.length) {
+ fail('$ownMember allows fewer parameters than $superMember');
+ return;
+ }
+ if (ownFunction.typeParameters.length !=
+ superFunction.typeParameters.length) {
+ fail('$ownMember declares a different number of type parameters '
+ 'than $superMember');
+ return;
+ }
+ if (superFunction.typeParameters.isNotEmpty) {
+ // Ensure these maps are not constant, so we can add bindings for the
+ // function type parameters.
+ superSubstitution = ensureMutable(superSubstitution);
+ superUpperBounds = ensureMutable(superUpperBounds);
+ }
+ for (int i = 0; i < superFunction.typeParameters.length; ++i) {
+ var ownTypeParameter = ownFunction.typeParameters[i];
+ var superTypeParameter = superFunction.typeParameters[i];
+ var type = new TypeParameterType(ownTypeParameter);
+ superSubstitution[superTypeParameter] = type;
+ superUpperBounds[superTypeParameter] = type;
+ }
+ void checkParameterPair(
+ VariableDeclaration ownParameter, VariableDeclaration superParameter) {
+ var ownType = substitute(ownParameter.type, ownSubstitution);
+ var superType = substituteBounds(
+ superParameter.type, superUpperBounds, superSubstitution);
+ if (!types.isSubtypeOf(superType, ownType)) {
+ addUnsafeParameter(ownParameter, superType, ownMember);
+ }
+ }
+
+ for (int i = 0; i < superFunction.positionalParameters.length; ++i) {
+ checkParameterPair(ownFunction.positionalParameters[i],
+ superFunction.positionalParameters[i]);
+ }
+ for (int i = 0; i < superFunction.namedParameters.length; ++i) {
+ var superParameter = superFunction.namedParameters[i];
+ bool found = false;
+ for (int j = 0; j < ownFunction.namedParameters.length; ++j) {
+ var ownParameter = ownFunction.namedParameters[j];
+ if (ownParameter.name == superParameter.name) {
+ found = true;
+ checkParameterPair(ownParameter, superParameter);
+ break;
+ }
+ }
+ if (!found) {
+ fail('$ownMember is missing the named parameter '
+ '${superParameter.name} from $superMember');
+ }
+ }
+ }
+
+ void generateCheckedEntryPoint(Member member) {
+ // TODO(asgerf): It may be worthwhile to try to reuse a checked entry
+ // point from the supertype when the same checks are needed and the
+ // dispatch target is the same.
+ if (member is Procedure) {
+ generateCheckedProcedure(member);
+ } else {
+ generateCheckedFieldSetter(member);
+ }
+ }
+
+ void generateCheckedProcedure(Procedure procedure) {
+ var function = procedure.function;
+
+ // Clone the function without its body.
+ var body = function.body;
+ function.body = null;
+ var cloner = new CloneVisitor(typeSubstitution: ownSubstitution);
+ Procedure checkedProcedure = cloner.clone(procedure);
+ FunctionNode checkedFunction = checkedProcedure.function;
+ function.body = body;
+
+ checkedFunction.asyncMarker = AsyncMarker.Sync;
+ checkedProcedure.isExternal = false;
+
+ Expression getParameter(VariableDeclaration parameter) {
+ var cloneParameter = cloner.variables[parameter];
+ var unsafeInputs = unsafeParameterTypes[parameter];
+ if (unsafeInputs == null) {
+ return new VariableGet(cloneParameter); // No check needed.
+ }
+ // Change the actual parameter type to the safe type, and cast to the
+ // type declared on the original parameter.
+ // Use the cloner to map function type parameters to the cloned
+ // function type parameters (in case the function is generic).
+ var targetType = cloneParameter.type;
+ cloneParameter.type = cloner.visitType(getSafeType(unsafeInputs));
+ return new AsExpression(new VariableGet(cloneParameter), targetType);
+ }
+
+ // TODO: Insert checks for type parameter bounds.
+ var types = checkedFunction.typeParameters
+ .map((p) => new TypeParameterType(p))
+ .toList();
+ var positional = function.positionalParameters.map(getParameter).toList();
+ var named = function.namedParameters
+ .map((p) => new NamedExpression(p.name, getParameter(p)))
+ .toList();
+
+ checkedProcedure.name = covariantCheckedName(procedure.name);
+ host.addMember(checkedProcedure);
+
+ // Only generate a body if the original method had one.
+ if (!procedure.isAbstract && !procedure.isInExternalLibrary) {
+ var call = procedure.isSetter
+ ? new DirectPropertySet(
+ new ThisExpression(), procedure, positional[0])
+ : new DirectMethodInvocation(new ThisExpression(), procedure,
+ new Arguments(positional, named: named, types: types));
+ var checkedBody = function.returnType is VoidType
+ ? new ExpressionStatement(call)
+ : new ReturnStatement(call);
+ checkedFunction.body = checkedBody..parent = checkedFunction;
+ }
+
+ if (procedure.enclosingClass == host) {
+ global.unsafeMemberEntryPoint[procedure] = checkedProcedure;
+ }
+ }
+
+ void generateCheckedFieldSetter(Field field) {
+ var parameter = getFieldSetterParameter(field);
+ var unsafeTypes = unsafeParameterTypes[parameter];
+ Expression argument = new VariableGet(parameter);
+ if (unsafeTypes != null) {
+ var castType = substitute(field.type, ownSubstitution);
+ argument = new AsExpression(argument, castType);
+ var inputType = substitute(getSafeType(unsafeTypes), ownSubstitution);
+ parameter.type = inputType;
+ }
+
+ Statement body = field.isInExternalLibrary
+ ? null
+ : new ExpressionStatement(
+ new DirectPropertySet(new ThisExpression(), field, argument));
+
+ var setter = new Procedure(
+ covariantCheckedName(field.name),
+ ProcedureKind.Setter,
+ new FunctionNode(body, positionalParameters: [parameter]));
+ host.addMember(setter);
+
+ if (field.enclosingClass == host) {
+ global.unsafeMemberEntryPoint[field] = setter;
+ }
+ }
+
+ /// Generates a synthetic name representing the covariant-checked entry point
+ /// to a method.
+ static Name covariantCheckedName(Name name) {
+ return new Name('${name.name}\$cc', name.library);
+ }
+
+ static Map<TypeParameter, DartType> ensureMutable(
+ Map<TypeParameter, DartType> map) {
+ if (map.isEmpty) return <TypeParameter, DartType>{};
+ return map;
+ }
+}
+
+// TODO(asgerf): We should be able to avoid checked calls in a lot more cases:
+// - the arguments to every unsafe parameter is null or is omitted
+// - allocation site of receiver can easily be seen statically
+class _CallTransformer extends RecursiveVisitor {
+ final InsertCovarianceChecks global;
+ final TypeEnvironment types;
+ final Map<Member, Procedure> checkedInterfaceMethod;
+
+ _CallTransformer(InsertCovarianceChecks global)
+ : checkedInterfaceMethod = global.unsafeMemberEntryPoint,
+ types = global.types,
+ this.global = global;
+
+ Member getChecked(Expression receiver, Member member) {
+ var checked = checkedInterfaceMethod[member];
+ if (checked == null) return member;
+ if (!receiverNeedsChecks(receiver)) return member;
+ return checked;
+ }
+
+ bool receiverNeedsChecks(Expression node) {
+ if (node is ThisExpression) return false;
+ var type = node.getStaticType(types);
+ if (type is InterfaceType && type.typeArguments.every(isSealedType)) {
+ return false;
+ }
+ return true;
+ }
+
+ bool isSealedType(DartType type) {
+ return type is InterfaceType && types.isSealedClass(type.classNode);
+ }
+
+ bool isTrustedLibrary(Library node) {
+ return node.importUri.scheme == 'dart';
+ }
+
+ @override
+ visitClass(Class node) {
+ types.thisType = node.thisType;
+ node.visitChildren(this);
+ }
+
+ @override
+ visitLibrary(Library node) {
+ if (!isTrustedLibrary(node)) {
+ node.visitChildren(this);
+ }
+ }
+
+ @override
+ visitMethodInvocation(MethodInvocation node) {
+ node.interfaceTarget = getChecked(node.receiver, node.interfaceTarget);
+ node.visitChildren(this);
+ }
+
+ @override
+ visitPropertySet(PropertySet node) {
+ node.interfaceTarget = getChecked(node.receiver, node.interfaceTarget);
+ node.visitChildren(this);
+ }
+}
diff --git a/pkg/kernel/lib/transformations/insert_type_checks.dart b/pkg/kernel/lib/transformations/insert_type_checks.dart
new file mode 100644
index 0000000..01db445
--- /dev/null
+++ b/pkg/kernel/lib/transformations/insert_type_checks.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+library kernel.transformations.insert_type_checks;
+
+import '../ast.dart';
+import '../class_hierarchy.dart';
+import '../core_types.dart';
+import '../log.dart';
+import '../type_checker.dart';
+
+/// Inserts implicit downcasts in method bodies to ensure type safety.
+///
+/// This does not deal with covariant override and covariant use of type
+/// parameters.
+///
+/// Ideally this should be done when initially generating kernel IR, but this
+/// is not practical at the moment.
+class InsertTypeChecks {
+ CoreTypes coreTypes;
+ ClassHierarchy hierarchy;
+
+ InsertTypeChecks({this.coreTypes, this.hierarchy});
+
+ void transformProgram(Program program) {
+ coreTypes ??= new CoreTypes(program);
+ hierarchy ??= new ClassHierarchy(program);
+ new CheckInsertingTypeChecker(coreTypes, hierarchy).checkProgram(program);
+ }
+}
+
+class CheckInsertingTypeChecker extends TypeChecker {
+ CheckInsertingTypeChecker(CoreTypes coreTypes, ClassHierarchy hierarchy)
+ : super(coreTypes, hierarchy);
+
+ @override
+ void fail(TreeNode where, String message) {
+ log.severe('${where.location}: $message');
+ }
+
+ @override
+ void checkAssignable(TreeNode where, DartType from, DartType to) {
+ if (!environment.isSubtypeOf(from, to)) {
+ fail(where, '$from cannot be assigned to $to');
+ }
+ }
+
+ @override
+ Expression checkAndDowncastExpression(
+ Expression expression, DartType from, DartType to) {
+ if (!environment.isSubtypeOf(from, to)) {
+ return new AsExpression(expression, to)
+ ..fileOffset = expression.fileOffset;
+ } else {
+ return expression;
+ }
+ }
+}
diff --git a/pkg/kernel/lib/type_algebra.dart b/pkg/kernel/lib/type_algebra.dart
index 19508b1..ce4a553 100644
--- a/pkg/kernel/lib/type_algebra.dart
+++ b/pkg/kernel/lib/type_algebra.dart
@@ -30,6 +30,18 @@
type.classNode.typeParameters, type.typeArguments);
}
+Map<TypeParameter, DartType> getUpperBoundSubstitutionMap(Class host) {
+ if (host.typeParameters.isEmpty) return const <TypeParameter, DartType>{};
+ var result = <TypeParameter, DartType>{};
+ for (var parameter in host.typeParameters) {
+ result[parameter] = const DynamicType();
+ }
+ for (var parameter in host.typeParameters) {
+ result[parameter] = substitute(parameter.bound, result);
+ }
+ return result;
+}
+
/// Like [substitute], except when a type in the [substitution] map references
/// another substituted type variable, the mapping for that type is recursively
/// inserted.
@@ -180,6 +192,21 @@
return new _ClassBottomSubstitution(class_);
}
+ /// Substitutes covariant uses of [class_]'s type parameters with the upper
+ /// bound of that type parameter. Recursive references in the bound have
+ /// been replaced by dynamic.
+ static Substitution upperBoundForClass(Class class_) {
+ if (class_.typeParameters.isEmpty) return _NullSubstitution.instance;
+ var upper = <TypeParameter, DartType>{};
+ for (var parameter in class_.typeParameters) {
+ upper[parameter] = const DynamicType();
+ }
+ for (var parameter in class_.typeParameters) {
+ upper[parameter] = substitute(parameter.bound, upper);
+ }
+ return fromUpperAndLowerBounds(upper, {});
+ }
+
/// Substitutes both variables from [first] and [second], favoring those from
/// [first] if they overlap.
///
diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart
index ab0351e..45159b2 100644
--- a/pkg/kernel/lib/type_checker.dart
+++ b/pkg/kernel/lib/type_checker.dart
@@ -85,6 +85,16 @@
/// [where] is an AST node indicating roughly where the check is required.
void checkAssignable(TreeNode where, DartType from, DartType to);
+ /// Checks that [expression], which has type [from], can be assigned to [to].
+ ///
+ /// Should return a downcast if necessary, or [expression] if no cast is
+ /// needed.
+ Expression checkAndDowncastExpression(
+ Expression expression, DartType from, DartType to) {
+ checkAssignable(expression, from, to);
+ return expression;
+ }
+
/// Indicates that type checking failed.
void fail(TreeNode where, String message);
}
@@ -108,8 +118,16 @@
checker.checkAssignable(where, from, to);
}
- void checkAssignableExpression(Expression from, DartType to) {
- checker.checkAssignable(from, visitExpression(from), to);
+ Expression checkAndDowncastExpression(Expression from, DartType to) {
+ var parent = from.parent;
+ var type = visitExpression(from);
+ var result = checker.checkAndDowncastExpression(from, type, to);
+ result.parent = parent;
+ return result;
+ }
+
+ void checkExpressionNoDowncast(Expression expression, DartType to) {
+ checkAssignable(expression, visitExpression(expression), to);
}
void fail(TreeNode node, String message) {
@@ -146,7 +164,8 @@
visitField(Field node) {
if (node.initializer != null) {
- checkAssignableExpression(node.initializer, node.type);
+ node.initializer =
+ checkAndDowncastExpression(node.initializer, node.type);
}
}
@@ -188,7 +207,8 @@
void handleOptionalParameter(VariableDeclaration parameter) {
if (parameter.initializer != null) {
- checkAssignableExpression(parameter.initializer, parameter.type);
+ // Default parameter values cannot be downcast.
+ checkExpressionNoDowncast(parameter.initializer, parameter.type);
}
}
@@ -255,7 +275,8 @@
var expectedType = substitution.substituteType(
function.positionalParameters[i].type,
contravariant: true);
- checkAssignableExpression(arguments.positional[i], expectedType);
+ arguments.positional[i] =
+ checkAndDowncastExpression(arguments.positional[i], expectedType);
}
for (int i = 0; i < arguments.named.length; ++i) {
var argument = arguments.named[i];
@@ -265,7 +286,8 @@
var expectedType = substitution.substituteType(
function.namedParameters[j].type,
contravariant: true);
- checkAssignableExpression(argument.value, expectedType);
+ argument.value =
+ checkAndDowncastExpression(argument.value, expectedType);
found = true;
break;
}
@@ -344,9 +366,11 @@
@override
DartType visitConditionalExpression(ConditionalExpression node) {
- checkAssignableExpression(node.condition, environment.boolType);
- checkAssignableExpression(node.then, node.staticType);
- checkAssignableExpression(node.otherwise, node.staticType);
+ node.condition =
+ checkAndDowncastExpression(node.condition, environment.boolType);
+ node.then = checkAndDowncastExpression(node.then, node.staticType);
+ node.otherwise =
+ checkAndDowncastExpression(node.otherwise, node.staticType);
return node.staticType;
}
@@ -419,24 +443,25 @@
@override
DartType visitListLiteral(ListLiteral node) {
- for (var item in node.expressions) {
- checkAssignableExpression(item, node.typeArgument);
+ for (int i = 0; i < node.expressions.length; ++i) {
+ node.expressions[i] =
+ checkAndDowncastExpression(node.expressions[i], node.typeArgument);
}
return environment.literalListType(node.typeArgument);
}
@override
DartType visitLogicalExpression(LogicalExpression node) {
- checkAssignableExpression(node.left, environment.boolType);
- checkAssignableExpression(node.right, environment.boolType);
+ node.left = checkAndDowncastExpression(node.left, environment.boolType);
+ node.right = checkAndDowncastExpression(node.right, environment.boolType);
return environment.boolType;
}
@override
DartType visitMapLiteral(MapLiteral node) {
for (var entry in node.entries) {
- checkAssignableExpression(entry.key, node.keyType);
- checkAssignableExpression(entry.value, node.valueType);
+ entry.key = checkAndDowncastExpression(entry.key, node.keyType);
+ entry.value = checkAndDowncastExpression(entry.value, node.valueType);
}
return environment.literalMapType(node.keyType, node.valueType);
}
@@ -467,7 +492,8 @@
var expectedType = instantiation.substituteType(
function.positionalParameters[i],
contravariant: true);
- checkAssignableExpression(arguments.positional[i], expectedType);
+ arguments.positional[i] =
+ checkAndDowncastExpression(arguments.positional[i], expectedType);
}
for (int i = 0; i < arguments.named.length; ++i) {
var argument = arguments.named[i];
@@ -477,7 +503,8 @@
var expectedType = instantiation.substituteType(
function.namedParameters[j].type,
contravariant: true);
- checkAssignableExpression(argument.value, expectedType);
+ argument.value =
+ checkAndDowncastExpression(argument.value, expectedType);
found = true;
break;
}
@@ -674,7 +701,8 @@
@override
visitDoStatement(DoStatement node) {
visitStatement(node.body);
- checkAssignableExpression(node.condition, environment.boolType);
+ node.condition =
+ checkAndDowncastExpression(node.condition, environment.boolType);
}
@override
@@ -700,23 +728,27 @@
}
static final Name iteratorName = new Name('iterator');
- static final Name nextName = new Name('next');
+ static final Name currentName = new Name('current');
DartType getIterableElementType(DartType iterable) {
if (iterable is InterfaceType) {
var iteratorGetter =
hierarchy.getInterfaceMember(iterable.classNode, iteratorName);
if (iteratorGetter == null) return const DynamicType();
+ var castedIterable = hierarchy.getTypeAsInstanceOf(
+ iterable, iteratorGetter.enclosingClass);
var iteratorType = Substitution
- .fromInterfaceType(iterable)
+ .fromInterfaceType(castedIterable)
.substituteType(iteratorGetter.getterType);
if (iteratorType is InterfaceType) {
- var nextGetter =
- hierarchy.getInterfaceMember(iteratorType.classNode, nextName);
- if (nextGetter == null) return const DynamicType();
+ var currentGetter =
+ hierarchy.getInterfaceMember(iteratorType.classNode, currentName);
+ if (currentGetter == null) return const DynamicType();
+ var castedIteratorType = hierarchy.getTypeAsInstanceOf(
+ iteratorType, currentGetter.enclosingClass);
return Substitution
- .fromInterfaceType(iteratorType)
- .substituteType(nextGetter.getterType);
+ .fromInterfaceType(castedIteratorType)
+ .substituteType(currentGetter.getterType);
}
}
return const DynamicType();
@@ -736,7 +768,8 @@
visitForStatement(ForStatement node) {
node.variables.forEach(visitVariableDeclaration);
if (node.condition != null) {
- checkAssignableExpression(node.condition, environment.boolType);
+ node.condition =
+ checkAndDowncastExpression(node.condition, environment.boolType);
}
node.updates.forEach(visitExpression);
visitStatement(node.body);
@@ -749,7 +782,8 @@
@override
visitIfStatement(IfStatement node) {
- checkAssignableExpression(node.condition, environment.boolType);
+ node.condition =
+ checkAndDowncastExpression(node.condition, environment.boolType);
visitStatement(node.then);
if (node.otherwise != null) {
visitStatement(node.otherwise);
@@ -805,13 +839,15 @@
@override
visitVariableDeclaration(VariableDeclaration node) {
if (node.initializer != null) {
- checkAssignableExpression(node.initializer, node.type);
+ node.initializer =
+ checkAndDowncastExpression(node.initializer, node.type);
}
}
@override
visitWhileStatement(WhileStatement node) {
- checkAssignableExpression(node.condition, environment.boolType);
+ node.condition =
+ checkAndDowncastExpression(node.condition, environment.boolType);
visitStatement(node.body);
}
@@ -832,13 +868,14 @@
fail(node.expression, '$type is not an instance of $container');
}
} else {
- checkAssignableExpression(node.expression, environment.yieldType);
+ node.expression =
+ checkAndDowncastExpression(node.expression, environment.yieldType);
}
}
@override
visitFieldInitializer(FieldInitializer node) {
- checkAssignableExpression(node.value, node.field.type);
+ node.value = checkAndDowncastExpression(node.value, node.field.type);
}
@override
@@ -850,7 +887,8 @@
@override
visitSuperInitializer(SuperInitializer node) {
handleCall(node.arguments, node.target.function,
- typeParameters: const <TypeParameter>[]);
+ typeParameters: const <TypeParameter>[],
+ receiver: getSuperReceiverType(node.target));
}
@override
diff --git a/pkg/kernel/lib/type_environment.dart b/pkg/kernel/lib/type_environment.dart
index c354c44..0b90cb4 100644
--- a/pkg/kernel/lib/type_environment.dart
+++ b/pkg/kernel/lib/type_environment.dart
@@ -95,7 +95,11 @@
Class class_ = member.enclosingClass;
if (class_ == coreTypes.intClass || class_ == coreTypes.numClass) {
String name = member.name.name;
- return name == '+' || name == '-' || name == '*' || name == 'remainder';
+ return name == '+' ||
+ name == '-' ||
+ name == '*' ||
+ name == 'remainder' ||
+ name == '%';
}
return false;
}
@@ -114,6 +118,21 @@
if (type1 == doubleType || type2 == doubleType) return doubleType;
return numType;
}
+
+ /// Returns true if [class_] has no proper subtypes that are usable as type
+ /// argument.
+ bool isSealedClass(Class class_) {
+ // The sealed core classes have subtypes in the patched SDK, but those
+ // classes cannot occur as type argument.
+ if (class_ == coreTypes.intClass ||
+ class_ == coreTypes.doubleClass ||
+ class_ == coreTypes.stringClass ||
+ class_ == coreTypes.boolClass ||
+ class_ == coreTypes.nullClass) {
+ return true;
+ }
+ return !hierarchy.hasProperSubtypes(class_);
+ }
}
/// The part of [TypeEnvironment] that deals with subtype tests.
@@ -128,7 +147,9 @@
bool isSubtypeOf(DartType subtype, DartType supertype) {
if (identical(subtype, supertype)) return true;
if (subtype is BottomType) return true;
- if (supertype is DynamicType || supertype == objectType) {
+ if (supertype is DynamicType ||
+ supertype is VoidType ||
+ supertype == objectType) {
return true;
}
if (subtype is InterfaceType && supertype is InterfaceType) {
@@ -194,8 +215,7 @@
}
subtype = substitute(subtype.withoutTypeParameters, substitution);
}
- if (supertype.returnType is! VoidType &&
- !isSubtypeOf(subtype.returnType, supertype.returnType)) {
+ if (!isSubtypeOf(subtype.returnType, supertype.returnType)) {
return false;
}
for (int i = 0; i < supertype.positionalParameters.length; ++i) {
diff --git a/pkg/kernel/lib/verifier.dart b/pkg/kernel/lib/verifier.dart
index bed5417..1a1b5ad 100644
--- a/pkg/kernel/lib/verifier.dart
+++ b/pkg/kernel/lib/verifier.dart
@@ -238,6 +238,7 @@
visitVariableGet(VariableGet node) {
checkVariableInScope(node.variable, node);
+ visitChildren(node);
}
visitVariableSet(VariableSet node) {
diff --git a/pkg/kernel/test/baseline_strong_mode_test.dart b/pkg/kernel/test/baseline_strong_mode_test.dart
index 51d2a7c..a252bff 100644
--- a/pkg/kernel/test/baseline_strong_mode_test.dart
+++ b/pkg/kernel/test/baseline_strong_mode_test.dart
@@ -4,6 +4,8 @@
import 'package:kernel/class_hierarchy.dart';
import 'package:kernel/core_types.dart';
import 'package:kernel/kernel.dart';
+import 'package:kernel/transformations/insert_covariance_checks.dart';
+import 'package:kernel/transformations/insert_type_checks.dart';
import 'package:kernel/transformations/mixin_full_resolution.dart';
import 'package:kernel/type_checker.dart';
import 'package:path/path.dart' as pathlib;
@@ -24,6 +26,8 @@
List<String> transformProgram(Program program) {
List<String> errors = <String>[];
new MixinFullResolution().transform(program);
+ new InsertTypeChecks().transformProgram(program);
+ new InsertCovarianceChecks().transformProgram(program);
new TestTypeChecker(
errors, new CoreTypes(program), new ClassHierarchy(program))
.checkProgram(program);
diff --git a/pkg/kernel/testcases/closures/capture_closure.dart.expect b/pkg/kernel/testcases/closures/capture_closure.dart.expect
index dae8d72..115cb6b 100644
--- a/pkg/kernel/testcases/closures/capture_closure.dart.expect
+++ b/pkg/kernel/testcases/closures/capture_closure.dart.expect
@@ -31,6 +31,6 @@
final mock::Context #context = new mock::Context::•(1);
#context.parent = null;
#context.[]=(0, new self::Closure#main#f::•(#context));
- final dynamic g = new self::Closure#main#g::•(#context);
+ final() → dynamic g = new self::Closure#main#g::•(#context);
g.call();
}
diff --git a/pkg/kernel/testcases/closures/capture_closure_parameter.dart.expect b/pkg/kernel/testcases/closures/capture_closure_parameter.dart.expect
index 2800725..204b5c1 100644
--- a/pkg/kernel/testcases/closures/capture_closure_parameter.dart.expect
+++ b/pkg/kernel/testcases/closures/capture_closure_parameter.dart.expect
@@ -27,11 +27,11 @@
final mock::Context #context = new mock::Context::•(1);
#context.parent = #contextParameter;
#context.[]=(0, null);
- final dynamic bar = new self::Closure#main#foo#bar::•(#context);
+ final() → dynamic bar = new self::Closure#main#foo#bar::•(#context);
return bar;
}
}
static method main(core::List<core::String> arguments) → dynamic {
- final dynamic foo = new self::Closure#main#foo::•(null);
+ final(dynamic) → dynamic foo = new self::Closure#main#foo::•(null);
foo.call(arguments.[](0)).call();
}
diff --git a/pkg/kernel/testcases/closures/named_closure.dart.expect b/pkg/kernel/testcases/closures/named_closure.dart.expect
index ae1d5a6..c1b236d 100644
--- a/pkg/kernel/testcases/closures/named_closure.dart.expect
+++ b/pkg/kernel/testcases/closures/named_closure.dart.expect
@@ -23,7 +23,7 @@
final mock::Context #context = new mock::Context::•(1);
#context.parent = null;
#context.[]=(0, arguments);
- final dynamic g = new self::Closure#main#g::•(#context);
+ final(dynamic) → dynamic g = new self::Closure#main#g::•(#context);
self::f = g;
self::foo();
}
diff --git a/pkg/kernel/testcases/closures/type_variables.dart.expect b/pkg/kernel/testcases/closures/type_variables.dart.expect
index bf7dd96..189739d 100644
--- a/pkg/kernel/testcases/closures/type_variables.dart.expect
+++ b/pkg/kernel/testcases/closures/type_variables.dart.expect
@@ -20,7 +20,7 @@
return new self::Closure#C#baz#function::•<self::C::T, self::C::S>(null);
}
static factory •<T extends core::Object, S extends core::Object>() → self::C<self::C::•::T, self::C::•::S> {
- final dynamic local = new self::Closure#C#function#local::•<self::C::•::T, self::C::•::S>(null);
+ final() → dynamic local = new self::Closure#C#function#local::•<self::C::•::T, self::C::•::S>(null);
return local.call();
}
}
diff --git a/pkg/kernel/testcases/input/covariant_generic.dart b/pkg/kernel/testcases/input/covariant_generic.dart
new file mode 100644
index 0000000..a0234a6
--- /dev/null
+++ b/pkg/kernel/testcases/input/covariant_generic.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2016, 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.
+typedef void Callback<T>(T x);
+
+class Foo<T> {
+ final T finalField;
+ final Callback<T> callbackField;
+
+ T mutableField;
+ Callback<T> mutableCallbackField;
+
+ Foo(this.finalField, this.callbackField);
+
+ void method(T x) {}
+
+ set setter(T x) {}
+
+ void withCallback(Callback<T> callback) {
+ callback(finalField);
+ }
+}
+
+main() {
+ Foo<int> fooInt = new Foo<int>(1, (int x) {});
+
+ fooInt.method(3);
+ fooInt.setter = 3;
+ fooInt.withCallback((int x) {});
+ fooInt.withCallback((num x) {});
+ fooInt.mutableField = 3;
+ fooInt.mutableCallbackField = (int x) {};
+
+ Foo<num> fooNum = fooInt;
+ fooNum.method(3);
+ fooNum.method(2.5);
+ fooNum.setter = 3;
+ fooNum.setter = 2.5;
+ fooNum.withCallback((num x) {});
+ fooNum.mutableField = 3;
+ fooNum.mutableField = 2.5;
+ fooNum.mutableCallbackField(3);
+ fooNum.mutableCallbackField(2.5);
+ fooNum.mutableCallbackField = (num x) {};
+}
diff --git a/pkg/kernel/testcases/spec-mode/covariant_generic.baseline.txt b/pkg/kernel/testcases/spec-mode/covariant_generic.baseline.txt
new file mode 100644
index 0000000..063394e
--- /dev/null
+++ b/pkg/kernel/testcases/spec-mode/covariant_generic.baseline.txt
@@ -0,0 +1,38 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Foo<T extends core::Object> extends core::Object {
+ final field self::Foo::T finalField;
+ final field (self::Foo::T) → void callbackField;
+ field self::Foo::T mutableField = null;
+ field (self::Foo::T) → void mutableCallbackField = null;
+ constructor •(self::Foo::T finalField, (self::Foo::T) → void callbackField) → void
+ : self::Foo::finalField = finalField, self::Foo::callbackField = callbackField, super core::Object::•()
+ ;
+ method method(self::Foo::T x) → void {}
+ set setter(self::Foo::T x) → dynamic {}
+ method withCallback((self::Foo::T) → void callback) → void {
+ callback.call(this.finalField);
+ }
+}
+static method main() → dynamic {
+ self::Foo<core::int> fooInt = new self::Foo::•<core::int>(1, (core::int x) → dynamic {});
+ fooInt.method(3);
+ fooInt.setter = 3;
+ fooInt.withCallback((core::int x) → dynamic {});
+ fooInt.withCallback((core::num x) → dynamic {});
+ fooInt.mutableField = 3;
+ fooInt.mutableCallbackField = (core::int x) → dynamic {};
+ self::Foo<core::num> fooNum = fooInt;
+ fooNum.method(3);
+ fooNum.method(2.5);
+ fooNum.setter = 3;
+ fooNum.setter = 2.5;
+ fooNum.withCallback((core::num x) → dynamic {});
+ fooNum.mutableField = 3;
+ fooNum.mutableField = 2.5;
+ fooNum.mutableCallbackField(3);
+ fooNum.mutableCallbackField(2.5);
+ fooNum.mutableCallbackField = (core::num x) → dynamic {};
+}
diff --git a/pkg/kernel/testcases/strong-mode/DeltaBlue.baseline.txt b/pkg/kernel/testcases/strong-mode/DeltaBlue.baseline.txt
index f2735c6..7f44a83 100644
--- a/pkg/kernel/testcases/strong-mode/DeltaBlue.baseline.txt
+++ b/pkg/kernel/testcases/strong-mode/DeltaBlue.baseline.txt
@@ -1,7 +1,4 @@
-// dynamic is not a subtype of dart.core::int (DeltaBlue.dart:126:17)
-// dynamic is not a subtype of dart.core::int (DeltaBlue.dart:133:15)
-// dynamic is not a subtype of dart.core::int (DeltaBlue.dart:138:36)
-// dynamic is not a subtype of dart.core::int (DeltaBlue.dart:139:15)
+// dynamic is not a subtype of dart.core::int (DeltaBlue.dart:139:16)
library;
import self as self;
import "dart:core" as core;
@@ -56,20 +53,20 @@
self::planner.{self::Planner::incrementalAdd}(this);
}
method satisfy(dynamic mark) → self::Constraint {
- this.{self::Constraint::chooseMethod}(mark);
+ this.{self::Constraint::chooseMethod}(mark as core::int);
if(!this.{self::Constraint::isSatisfied}()) {
if(this.{self::Constraint::strength}.{core::Object::==}(self::REQUIRED)) {
core::print("Could not satisfy a required constraint!");
}
return null;
}
- this.{self::Constraint::markInputs}(mark);
+ this.{self::Constraint::markInputs}(mark as core::int);
self::Variable out = this.{self::Constraint::output}();
self::Constraint overridden = out.{self::Variable::determinedBy};
if(!overridden.{core::Object::==}(null))
overridden.{self::Constraint::markUnsatisfied}();
out.{self::Variable::determinedBy} = this;
- if(!self::planner.{self::Planner::addPropagate}(this, mark))
+ if(!self::planner.{self::Planner::addPropagate}(this, mark as core::int))
core::print("Cycle encountered");
out.{self::Variable::mark} = mark;
return overridden;
@@ -250,7 +247,7 @@
: self::Variable::name = name, self::Variable::value = value, super core::Object::•()
;
method addConstraint(self::Constraint c) → void {
- this.{self::Variable::constraints}.{core::List::add}(c);
+ this.{self::Variable::constraints}.{core::List::add$cc}(c);
}
method removeConstraint(self::Constraint c) → void {
this.{self::Variable::constraints}.{core::List::remove}(c);
@@ -305,7 +302,7 @@
for (core::int i = 0; i.{core::num::<}(constraints.{core::List::length}); i = i.{core::num::+}(1)) {
self::Constraint c = constraints.{core::List::[]}(i);
if(c.{self::Constraint::isInput}() && c.{self::Constraint::isSatisfied}())
- sources.{core::List::add}(c);
+ sources.{core::List::add$cc}(c);
}
return this.{self::Planner::makePlan}(sources);
}
@@ -333,7 +330,7 @@
for (core::int i = 0; i.{core::num::<}(v.{self::Variable::constraints}.{core::List::length}); i = i.{core::num::+}(1)) {
self::Constraint c = v.{self::Variable::constraints}.{core::List::[]}(i);
if(!c.{self::Constraint::isSatisfied}())
- unsatisfied.{core::List::add}(c);
+ unsatisfied.{core::List::add$cc}(c);
}
self::Constraint determining = v.{self::Variable::determinedBy};
for (core::int i = 0; i.{core::num::<}(v.{self::Variable::constraints}.{core::List::length}); i = i.{core::num::+}(1)) {
@@ -351,7 +348,7 @@
for (core::int i = 0; i.{core::num::<}(v.{self::Variable::constraints}.{core::List::length}); i = i.{core::num::+}(1)) {
self::Constraint c = v.{self::Variable::constraints}.{core::List::[]}(i);
if(!c.{core::Object::==}(determining) && c.{self::Constraint::isSatisfied}())
- coll.{core::List::add}(c);
+ coll.{core::List::add$cc}(c);
}
}
}
@@ -361,7 +358,7 @@
: super core::Object::•()
;
method addConstraint(self::Constraint c) → void {
- this.{self::Plan::list}.{core::List::add}(c);
+ this.{self::Plan::list}.{core::List::add$cc}(c);
}
method size() → core::int
return this.{self::Plan::list}.{core::List::length};
diff --git a/pkg/kernel/testcases/strong-mode/call.baseline.txt b/pkg/kernel/testcases/strong-mode/call.baseline.txt
index 387757e..65b0561 100644
--- a/pkg/kernel/testcases/strong-mode/call.baseline.txt
+++ b/pkg/kernel/testcases/strong-mode/call.baseline.txt
@@ -1,8 +1,8 @@
-// Too few positional arguments (call.dart:30:17)
-// Too few positional arguments (call.dart:31:25)
-// Too few positional arguments (call.dart:35:17)
-// Too few positional arguments (call.dart:36:26)
-// Too few positional arguments (call.dart:37:31)
+// Too few positional arguments (call.dart:30:18)
+// Too few positional arguments (call.dart:31:26)
+// Too few positional arguments (call.dart:35:18)
+// Too few positional arguments (call.dart:36:27)
+// Too few positional arguments (call.dart:37:32)
library;
import self as self;
import "dart:core" as core;
diff --git a/pkg/kernel/testcases/strong-mode/covariant_generic.baseline.txt b/pkg/kernel/testcases/strong-mode/covariant_generic.baseline.txt
new file mode 100644
index 0000000..9b0d0d7
--- /dev/null
+++ b/pkg/kernel/testcases/strong-mode/covariant_generic.baseline.txt
@@ -0,0 +1,44 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Foo<T extends core::Object> extends core::Object {
+ final field self::Foo::T finalField;
+ final field (self::Foo::T) → void callbackField;
+ field self::Foo::T mutableField = null;
+ field (self::Foo::T) → void mutableCallbackField = null;
+ constructor •(self::Foo::T finalField, (self::Foo::T) → void callbackField) → void
+ : self::Foo::finalField = finalField, self::Foo::callbackField = callbackField, super core::Object::•()
+ ;
+ method method(self::Foo::T x) → void {}
+ set setter(self::Foo::T x) → void {}
+ method withCallback((self::Foo::T) → void callback) → void {
+ callback.call(this.{self::Foo::finalField});
+ }
+ set /* from null */ mutableField$cc(core::Object mutableField_) → dynamic
+ this.{=self::Foo::mutableField} = mutableField_ as self::Foo::T;
+ method method$cc(core::Object x) → void
+ this.{=self::Foo::method}(x as self::Foo::T);
+ set setter$cc(core::Object x) → void
+ this.{=self::Foo::setter} = x as self::Foo::T;
+}
+static method main() → dynamic {
+ self::Foo<core::int> fooInt = new self::Foo::•<core::int>(1, (core::int x) → void {});
+ fooInt.{self::Foo::method}(3);
+ fooInt.{self::Foo::setter} = 3;
+ fooInt.{self::Foo::withCallback}((core::int x) → void {});
+ fooInt.{self::Foo::withCallback}((core::num x) → void {});
+ fooInt.{self::Foo::mutableField} = 3;
+ fooInt.{self::Foo::mutableCallbackField} = (core::int x) → void {};
+ self::Foo<core::num> fooNum = fooInt;
+ fooNum.{self::Foo::method$cc}(3);
+ fooNum.{self::Foo::method$cc}(2.5);
+ fooNum.{self::Foo::setter$cc} = 3;
+ fooNum.{self::Foo::setter$cc} = 2.5;
+ fooNum.{self::Foo::withCallback}((core::num x) → void {});
+ fooNum.{self::Foo::mutableField$cc} = 3;
+ fooNum.{self::Foo::mutableField$cc} = 2.5;
+ fooNum.{self::Foo::mutableCallbackField}.call(3);
+ fooNum.{self::Foo::mutableCallbackField}.call(2.5);
+ fooNum.{self::Foo::mutableCallbackField} = (core::num x) → void {};
+}
diff --git a/pkg/kernel/testcases/strong-mode/optional.baseline.txt b/pkg/kernel/testcases/strong-mode/optional.baseline.txt
index 1087a03..0ba01b9 100644
--- a/pkg/kernel/testcases/strong-mode/optional.baseline.txt
+++ b/pkg/kernel/testcases/strong-mode/optional.baseline.txt
@@ -1,8 +1,7 @@
-// #lib1::InvalidListener is not a subtype of #lib1::Listener (optional.dart:42:20)
-// Too few positional arguments (optional.dart:44:21)
-// Too many positional arguments (optional.dart:45:21)
-// Too few positional arguments (optional.dart:46:24)
-// Too many positional arguments (optional.dart:47:24)
+// Too few positional arguments (optional.dart:44:22)
+// Too many positional arguments (optional.dart:45:22)
+// Too few positional arguments (optional.dart:46:25)
+// Too many positional arguments (optional.dart:47:25)
library;
import self as self;
import "dart:core" as core;
@@ -58,7 +57,7 @@
core::String string6 = extern.{self::External::externalMethod}(1, 2, 3);
extern.{self::External::listen}(new self::TestListener::•());
extern.{self::External::listen}(new self::ExtendedListener::•());
- extern.{self::External::listen}(new self::InvalidListener::•());
+ extern.{self::External::listen}(new self::InvalidListener::•() as self::Listener);
dynamic nothing1 = foo.{self::Foo::method}();
dynamic nothing2 = foo.{self::Foo::method}(1, 2, 3, 4);
core::String nothing3 = extern.{self::External::externalMethod}();
diff --git a/pkg/kernel/testcases/strong-mode/void-methods.baseline.txt b/pkg/kernel/testcases/strong-mode/void-methods.baseline.txt
index 73cd4d9..5120402 100644
--- a/pkg/kernel/testcases/strong-mode/void-methods.baseline.txt
+++ b/pkg/kernel/testcases/strong-mode/void-methods.baseline.txt
@@ -1,4 +1,3 @@
-// dynamic is not a subtype of dart.core::int (void-methods.dart:4:27)
library;
import self as self;
import "dart:core" as core;
@@ -9,9 +8,9 @@
: super core::Object::•()
;
set first(dynamic x) → void
- this.{self::Foo::list}.{core::List::[]=}(0, x);
+ this.{self::Foo::list}.{core::List::[]=$cc}(0, x);
operator []=(dynamic x, dynamic y) → dynamic
- this.{self::Foo::list}.{core::List::[]=}(x, y);
+ this.{self::Foo::list}.{core::List::[]=$cc}(x as core::int, y);
method clear() → void
this.{self::Foo::list}.{core::List::clear}();
}
diff --git a/pkg/kernel/testcases/type-propagation/covariant_generic.baseline.txt b/pkg/kernel/testcases/type-propagation/covariant_generic.baseline.txt
new file mode 100644
index 0000000..bc66a8f
--- /dev/null
+++ b/pkg/kernel/testcases/type-propagation/covariant_generic.baseline.txt
@@ -0,0 +1,38 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Foo<T extends core::Object> extends core::Object {
+ final field self::Foo::T/core::int* {int} finalField;
+ final field (self::Foo::T) → void/core::Function* {other} callbackField;
+ field self::Foo::T/core::num* {null,int,double} mutableField = null;
+ field (self::Foo::T) → void/core::Function* {null,other} mutableCallbackField = null;
+ constructor •(self::Foo::T/core::int* {int} finalField, (self::Foo::T) → void/core::Function* {other} callbackField) → void
+ : self::Foo::finalField = finalField, self::Foo::callbackField = callbackField, super core::Object::•()
+ ;
+ method method(self::Foo::T/core::num* {int,double} x) → void/Null {}
+ set setter(self::Foo::T/core::num* {int,double} x) → dynamic/Null {}
+ method withCallback((self::Foo::T) → void/core::Function* {other} callback) → void/Null {
+ callback.call(this.finalField);
+ }
+}
+static method main() → dynamic/Null {
+ self::Foo<core::int>/self::Foo! {other} fooInt = new self::Foo::•<core::int>(1, (core::int/Nothing x) → dynamic/Null {});
+ fooInt.method(3);
+ fooInt.setter = 3;
+ fooInt.withCallback((core::int/core::Object+ {*} x) → dynamic/Null {});
+ fooInt.withCallback((core::num/core::Object+ {*} x) → dynamic/Null {});
+ fooInt.mutableField = 3;
+ fooInt.mutableCallbackField = (core::int/core::Object+ {*} x) → dynamic/Null {};
+ self::Foo<core::num>/self::Foo! {other} fooNum = fooInt;
+ fooNum.method(3);
+ fooNum.method(2.5);
+ fooNum.setter = 3;
+ fooNum.setter = 2.5;
+ fooNum.withCallback((core::num/core::Object+ {*} x) → dynamic/Null {});
+ fooNum.mutableField = 3;
+ fooNum.mutableField = 2.5;
+ fooNum.mutableCallbackField(3);
+ fooNum.mutableCallbackField(2.5);
+ fooNum.mutableCallbackField = (core::num/core::Object+ {*} x) → dynamic/Null {};
+}
diff --git a/pkg/pkg.status b/pkg/pkg.status
index e347260..9a3c1ec 100644
--- a/pkg/pkg.status
+++ b/pkg/pkg.status
@@ -33,290 +33,6 @@
dev_compiler/gen/*: SkipByDesign
dev_compiler/test/options/*: SkipByDesign
-# Issue #28236
-analysis_server/test/analysis/get_errors_test: StaticWarning
-analysis_server/test/analysis/get_hover_test: StaticWarning
-analysis_server/test/analysis/get_navigation_test: StaticWarning
-analysis_server/test/analysis/navigation_collector_test: StaticWarning
-analysis_server/test/analysis/notification_analysis_options_test: StaticWarning
-analysis_server/test/analysis/notification_analyzedFiles_test: StaticWarning
-analysis_server/test/analysis/notification_errors_test: StaticWarning
-analysis_server/test/analysis/notification_highlights_test: StaticWarning
-analysis_server/test/analysis/notification_implemented_test: StaticWarning
-analysis_server/test/analysis/notification_navigation_test: StaticWarning
-analysis_server/test/analysis/notification_occurrences_test: StaticWarning
-analysis_server/test/analysis/notification_outline_test: StaticWarning
-analysis_server/test/analysis/notification_overrides_test: StaticWarning
-analysis_server/test/analysis/reanalyze_test: StaticWarning
-analysis_server/test/analysis/set_priority_files_test: StaticWarning
-analysis_server/test/analysis/update_content_test: StaticWarning
-analysis_server/test/analysis_server_test: StaticWarning
-analysis_server/test/channel/byte_stream_channel_test: StaticWarning
-analysis_server/test/channel/web_socket_channel_test: StaticWarning
-analysis_server/test/completion_test: StaticWarning
-analysis_server/test/context_manager_test: StaticWarning
-analysis_server/test/domain_analysis_test: StaticWarning
-analysis_server/test/domain_completion_test: StaticWarning
-analysis_server/test/domain_diagnostic_test: StaticWarning
-analysis_server/test/domain_execution_test: StaticWarning
-analysis_server/test/domain_server_test: StaticWarning
-analysis_server/test/edit/assists_test: StaticWarning
-analysis_server/test/edit/fixes_test: StaticWarning
-analysis_server/test/edit/format_test: StaticWarning
-analysis_server/test/edit/organize_directives_test: StaticWarning
-analysis_server/test/edit/refactoring_test: StaticWarning
-analysis_server/test/edit/sort_members_test: StaticWarning
-analysis_server/test/integration/analysis/analysis_options_test: StaticWarning
-analysis_server/test/integration/analysis/error_test: StaticWarning
-analysis_server/test/integration/analysis/get_errors_after_analysis_test: StaticWarning
-analysis_server/test/integration/analysis/get_errors_before_analysis_test: StaticWarning
-analysis_server/test/integration/analysis/get_hover_test: StaticWarning
-analysis_server/test/integration/analysis/highlights_test: StaticWarning
-analysis_server/test/integration/analysis/lint_test: StaticWarning
-analysis_server/test/integration/analysis/navigation_test: StaticWarning
-analysis_server/test/integration/analysis/occurrences_test: StaticWarning
-analysis_server/test/integration/analysis/outline_test: StaticWarning
-analysis_server/test/integration/analysis/overrides_test: StaticWarning
-analysis_server/test/integration/analysis/package_root_test: StaticWarning
-analysis_server/test/integration/analysis/reanalyze_concurrent_test: StaticWarning
-analysis_server/test/integration/analysis/reanalyze_test: StaticWarning
-analysis_server/test/integration/analysis/update_content_list_test: StaticWarning
-analysis_server/test/integration/analysis/update_content_test: StaticWarning
-analysis_server/test/integration/completion/get_suggestions_test: StaticWarning
-analysis_server/test/integration/search/get_type_hierarchy_test: StaticWarning
-analysis_server/test/integration/server/get_version_test: StaticWarning
-analysis_server/test/integration/server/set_subscriptions_invalid_service_test: StaticWarning
-analysis_server/test/integration/server/set_subscriptions_test: StaticWarning
-analysis_server/test/integration/server/shutdown_test: StaticWarning
-analysis_server/test/integration/server/status_test: StaticWarning
-analysis_server/test/operation/operation_queue_test: StaticWarning
-analysis_server/test/operation/operation_test: StaticWarning
-analysis_server/test/plugin/protocol_dart_test: StaticWarning
-analysis_server/test/plugin/set_analysis_domain_test: StaticWarning
-analysis_server/test/protocol_server_test: StaticWarning
-analysis_server/test/protocol_test: StaticWarning
-analysis_server/test/search/element_references_test: StaticWarning
-analysis_server/test/search/member_declarations_test: StaticWarning
-analysis_server/test/search/member_references_test: StaticWarning
-analysis_server/test/search/search_result_test: StaticWarning
-analysis_server/test/search/top_level_declarations_test: StaticWarning
-analysis_server/test/search/type_hierarchy_test: StaticWarning
-analysis_server/test/server_options_test: StaticWarning
-analysis_server/test/services/completion/completion_target_test: StaticWarning
-analysis_server/test/services/completion/dart/arglist_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/combinator_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/common_usage_sorter_test: StaticWarning
-analysis_server/test/services/completion/dart/completion_manager_test: StaticWarning
-analysis_server/test/services/completion/dart/field_formal_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/imported_reference_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/inherited_reference_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/keyword_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/label_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/library_member_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/library_prefix_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/local_constructor_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/local_declaration_visitor_test: StaticWarning
-analysis_server/test/services/completion/dart/local_library_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/local_reference_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/named_constructor_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/optype_test: StaticWarning
-analysis_server/test/services/completion/dart/override_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/static_member_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/type_member_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/uri_contributor_test: StaticWarning
-analysis_server/test/services/completion/dart/variable_name_contributor_test: StaticWarning
-analysis_server/test/services/correction/assist_test: StaticWarning
-analysis_server/test/services/correction/change_test: StaticWarning
-analysis_server/test/services/correction/fix_test: StaticWarning
-analysis_server/test/services/correction/levenshtein_test: StaticWarning
-analysis_server/test/services/correction/name_suggestion_test: StaticWarning
-analysis_server/test/services/correction/organize_directives_test: StaticWarning
-analysis_server/test/services/correction/sort_members_test: StaticWarning
-analysis_server/test/services/correction/source_range_test: StaticWarning
-analysis_server/test/services/correction/status_test: StaticWarning
-analysis_server/test/services/correction/strings_test: StaticWarning
-analysis_server/test/services/correction/util_test: StaticWarning
-analysis_server/test/services/dependencies/library_dependencies_test: StaticWarning
-analysis_server/test/services/dependencies/reachable_source_collector_test: StaticWarning
-analysis_server/test/services/index/index_test: StaticWarning
-analysis_server/test/services/index/index_unit_test: StaticWarning
-analysis_server/test/services/linter/linter_test: StaticWarning
-analysis_server/test/services/refactoring/convert_getter_to_method_test: StaticWarning
-analysis_server/test/services/refactoring/convert_method_to_getter_test: StaticWarning
-analysis_server/test/services/refactoring/extract_local_test: StaticWarning
-analysis_server/test/services/refactoring/extract_method_test: StaticWarning
-analysis_server/test/services/refactoring/inline_local_test: StaticWarning
-analysis_server/test/services/refactoring/inline_method_test: StaticWarning
-analysis_server/test/services/refactoring/move_file_test: StaticWarning
-analysis_server/test/services/refactoring/naming_conventions_test: StaticWarning
-analysis_server/test/services/refactoring/rename_class_member_test: StaticWarning
-analysis_server/test/services/refactoring/rename_constructor_test: StaticWarning
-analysis_server/test/services/refactoring/rename_import_test: StaticWarning
-analysis_server/test/services/refactoring/rename_label_test: StaticWarning
-analysis_server/test/services/refactoring/rename_library_test: StaticWarning
-analysis_server/test/services/refactoring/rename_local_test: StaticWarning
-analysis_server/test/services/refactoring/rename_unit_member_test: StaticWarning
-analysis_server/test/services/search/hierarchy_test: StaticWarning
-analysis_server/test/services/search/search_engine2_test: StaticWarning
-analysis_server/test/services/search/search_engine_test: StaticWarning
-analysis_server/test/single_context_manager_test: StaticWarning
-analysis_server/test/socket_server_test: StaticWarning
-analysis_server/test/source/caching_put_package_map_provider_test: StaticWarning
-analysis_server/test/src/utilities/change_builder_core_test: StaticWarning
-analysis_server/test/src/utilities/change_builder_dart_test: StaticWarning
-analysis_server/test/src/watch_manager_test: StaticWarning
-analyzer/test/cancelable_future_test: StaticWarning
-analyzer/test/context/declared_variables_test: StaticWarning
-analyzer/test/dart/ast/ast_test: StaticWarning
-analyzer/test/dart/ast/visitor_test: StaticWarning
-analyzer/test/dart/element/builder_test: StaticWarning
-analyzer/test/dart/element/element_test: StaticWarning
-analyzer/test/file_system/memory_file_system_test: StaticWarning
-analyzer/test/file_system/physical_resource_provider_test: StaticWarning
-analyzer/test/file_system/resource_uri_resolver_test: StaticWarning
-analyzer/test/generated/all_the_rest_test: StaticWarning
-analyzer/test/generated/bazel_test: StaticWarning
-analyzer/test/generated/checked_mode_compile_time_error_code_test: StaticWarning
-analyzer/test/generated/compile_time_error_code_test: StaticWarning
-analyzer/test/generated/constant_test: StaticWarning
-analyzer/test/generated/declaration_resolver_test: StaticWarning
-analyzer/test/generated/element_resolver_test: StaticWarning
-analyzer/test/generated/engine_test: StaticWarning
-analyzer/test/generated/error_suppression_test: StaticWarning
-analyzer/test/generated/hint_code_test: StaticWarning
-analyzer/test/generated/incremental_resolver_test: StaticWarning
-analyzer/test/generated/inheritance_manager_test: StaticWarning
-analyzer/test/generated/java_core_test: StaticWarning
-analyzer/test/generated/java_io_test: StaticWarning
-analyzer/test/generated/non_error_resolver_test: StaticWarning
-analyzer/test/generated/non_hint_code_test: StaticWarning
-analyzer/test/generated/package_test: StaticWarning
-analyzer/test/generated/parser_test: StaticWarning
-analyzer/test/generated/resolver_test: StaticWarning
-analyzer/test/generated/scanner_test: StaticWarning
-analyzer/test/generated/sdk_test: StaticWarning
-analyzer/test/generated/simple_resolver_test: StaticWarning
-analyzer/test/generated/source_factory_test: StaticWarning
-analyzer/test/generated/static_type_analyzer_test: StaticWarning
-analyzer/test/generated/static_type_warning_code_test: StaticWarning
-analyzer/test/generated/static_warning_code_test: StaticWarning
-analyzer/test/generated/strong_mode_test: StaticWarning
-analyzer/test/generated/type_system_test: StaticWarning
-analyzer/test/generated/utilities_dart_test: StaticWarning
-analyzer/test/generated/utilities_test: StaticWarning
-analyzer/test/instrumentation/instrumentation_test: StaticWarning
-analyzer/test/parse_compilation_unit_test: StaticWarning
-analyzer/test/source/analysis_options_provider_test: StaticWarning
-analyzer/test/source/embedder_test: StaticWarning
-analyzer/test/source/error_processor_test: StaticWarning
-analyzer/test/source/package_map_provider_test: StaticWarning
-analyzer/test/source/package_map_resolver_test: StaticWarning
-analyzer/test/source/path_filter_test: StaticWarning
-analyzer/test/source/sdk_ext_test: StaticWarning
-analyzer/test/src/command_line/arguments_test: StaticWarning
-analyzer/test/src/context/builder_test: StaticWarning
-analyzer/test/src/context/cache_test: StaticWarning
-analyzer/test/src/context/context_test: StaticWarning
-analyzer/test/src/dart/analysis/byte_store_test: StaticWarning
-analyzer/test/src/dart/analysis/driver_test: StaticWarning
-analyzer/test/src/dart/analysis/file_state_test: StaticWarning
-analyzer/test/src/dart/analysis/index_test: StaticWarning
-analyzer/test/src/dart/analysis/referenced_names_test: StaticWarning
-analyzer/test/src/dart/analysis/search_test: StaticWarning
-analyzer/test/src/dart/ast/utilities_test: StaticWarning
-analyzer/test/src/dart/constant/evaluation_test: StaticWarning
-analyzer/test/src/dart/constant/utilities_test: StaticWarning
-analyzer/test/src/dart/constant/value_test: StaticWarning
-analyzer/test/src/dart/element/element_test: StaticWarning
-analyzer/test/src/dart/sdk/patch_test: StaticWarning
-analyzer/test/src/dart/sdk/sdk_test: StaticWarning
-analyzer/test/src/lint/config_test: StaticWarning
-analyzer/test/src/lint/io_test: StaticWarning
-analyzer/test/src/lint/project_test: StaticWarning
-analyzer/test/src/lint/pub_test: StaticWarning
-analyzer/test/src/source/source_resource_test: StaticWarning
-analyzer/test/src/summary/api_signature_test: StaticWarning
-analyzer/test/src/summary/bazel_summary_test: StaticWarning
-analyzer/test/src/summary/flat_buffers_test: StaticWarning
-analyzer/test/src/summary/in_summary_source_test: StaticWarning
-analyzer/test/src/summary/linker_test: StaticWarning
-analyzer/test/src/summary/name_filter_test: StaticWarning
-analyzer/test/src/summary/package_bundle_reader_test: StaticWarning
-analyzer/test/src/summary/prelinker_test: StaticWarning
-analyzer/test/src/summary/pub_summary_test: StaticWarning
-analyzer/test/src/summary/resynthesize_ast_test: StaticWarning
-analyzer/test/src/summary/summarize_ast_strong_test: StaticWarning
-analyzer/test/src/summary/summarize_ast_test: StaticWarning
-analyzer/test/src/task/dart_test: StaticWarning
-analyzer/test/src/task/dart_work_manager_test: StaticWarning
-analyzer/test/src/task/driver_test: StaticWarning
-analyzer/test/src/task/general_test: StaticWarning
-analyzer/test/src/task/html_test: StaticWarning
-analyzer/test/src/task/html_work_manager_test: StaticWarning
-analyzer/test/src/task/incremental_element_builder_test: StaticWarning
-analyzer/test/src/task/inputs_test: StaticWarning
-analyzer/test/src/task/manager_test: StaticWarning
-analyzer/test/src/task/model_test: StaticWarning
-analyzer/test/src/task/options_test: StaticWarning
-analyzer/test/src/task/options_work_manager_test: StaticWarning
-analyzer/test/src/task/strong/checker_test: StaticWarning
-analyzer/test/src/task/strong/inferred_type_test: StaticWarning
-analyzer/test/src/task/strong/non_null_checker_test: StaticWarning
-analyzer/test/src/task/strong_mode_test: StaticWarning
-analyzer/test/src/task/yaml_test: StaticWarning
-analyzer/test/src/util/absolute_path_test: StaticWarning
-analyzer/test/src/util/asserts_test: StaticWarning
-analyzer/test/src/util/fast_uri_test: StaticWarning
-analyzer/test/src/util/glob_test: StaticWarning
-analyzer/test/src/util/lru_map_test: StaticWarning
-analyzer/test/src/util/yaml_test: StaticWarning
-analyzer/tool/summary/check_test: StaticWarning
-analyzer/tool/task_dependency_graph/check_test: StaticWarning
-analyzer_cli/test/build_mode_test: StaticWarning
-analyzer_cli/test/driver_test: StaticWarning
-analyzer_cli/test/embedder_test: StaticWarning
-analyzer_cli/test/error_test: StaticWarning
-analyzer_cli/test/options_test: StaticWarning
-analyzer_cli/test/package_prefix_test: StaticWarning
-analyzer_cli/test/perf_report_test: StaticWarning
-analyzer_cli/test/reporter_test: StaticWarning
-analyzer_cli/test/sdk_ext_test: StaticWarning
-analyzer_cli/test/strong_mode_test: StaticWarning
-analyzer_cli/test/super_mixin_test: StaticWarning
-analyzer_cli/tool/perf_test: StaticWarning
-compiler/tool/perf_test: StaticWarning
-dev_compiler/test/closure/closure_annotation_test: StaticWarning
-dev_compiler/test/closure/closure_type_test: StaticWarning
-dev_compiler/test/codegen_test: StaticWarning
-dev_compiler/test/js/builder_test: StaticWarning
-dev_compiler/test/worker/worker_test: StaticWarning
-front_end/test/dependency_grapher_test: StaticWarning
-front_end/test/memory_file_system_test: StaticWarning
-front_end/test/physical_file_system_test: StaticWarning
-front_end/test/scanner_test: StaticWarning
-front_end/test/src/async_dependency_walker_test: StaticWarning
-front_end/test/src/base/libraries_reader_test: StaticWarning
-front_end/test/src/base/processed_options_test: StaticWarning
-front_end/test/src/base/uri_resolver_test: StaticWarning
-front_end/test/src/dependency_walker_test: StaticWarning
-front_end/tool/perf_test: StaticWarning
-js_ast/test/printer_callback_test: StaticWarning
-js_ast/test/string_escape_test: StaticWarning
-kernel/test/baseline_spec_mode_test: StaticWarning
-kernel/test/baseline_strong_mode_test: StaticWarning
-kernel/test/baseline_type_propagation_test: StaticWarning
-kernel/test/type_hashcode_test: StaticWarning
-kernel/test/type_substitute_bounds_test: StaticWarning
-kernel/test/type_substitution_identity_test: StaticWarning
-kernel/test/type_subtype_test: StaticWarning
-kernel/test/type_unification_test: StaticWarning
-kernel/test/uint31_pair_map_test: StaticWarning
-kernel/test/verify_test: StaticWarning
-lookup_map/test/lookup_map_test: StaticWarning
-lookup_map/test/version_check_test: StaticWarning
-typed_mock/test/typed_mock_test: StaticWarning
-
-
[ $compiler == none && ($runtime == drt || $runtime == dartium) ]
mutation_observer: Skip # Issue 21149
unittest/*: Skip # Issue 21949
diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn
index e7c13da..50ae8ce61 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -163,7 +163,7 @@
]
if (dart_debug) {
- cflags += [ "-O1" ]
+ cflags += [ "-O2" ]
} else {
cflags += [ "-O3" ]
}
diff --git a/runtime/bin/directory_fuchsia.cc b/runtime/bin/directory_fuchsia.cc
index 9259bd0..c931171 100644
--- a/runtime/bin/directory_fuchsia.cc
+++ b/runtime/bin/directory_fuchsia.cc
@@ -126,91 +126,61 @@
done_ = true;
return kListError;
}
- switch (entry->d_type) {
- case DT_DIR:
+ // TODO(MG-450): When entry->d_type is filled out correctly, we can avoid
+ // this call to stat().
+ struct stat64 entry_info;
+ int stat_success;
+ stat_success = NO_RETRY_EXPECTED(
+ lstat64(listing->path_buffer().AsString(), &entry_info));
+ if (stat_success == -1) {
+ perror("lstat64 failed: ");
+ return kListError;
+ }
+ if (listing->follow_links() && S_ISLNK(entry_info.st_mode)) {
+ // Check to see if we are in a loop created by a symbolic link.
+ LinkList current_link = {entry_info.st_dev, entry_info.st_ino, link_};
+ LinkList* previous = link_;
+ while (previous != NULL) {
+ if ((previous->dev == current_link.dev) &&
+ (previous->ino == current_link.ino)) {
+ // Report the looping link as a link, rather than following it.
+ return kListLink;
+ }
+ previous = previous->next;
+ }
+ stat_success = NO_RETRY_EXPECTED(
+ stat64(listing->path_buffer().AsString(), &entry_info));
+ if (stat_success == -1) {
+ perror("lstat64 failed");
+ // Report a broken link as a link, even if follow_links is true.
+ return kListLink;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ // Recurse into the subdirectory with current_link added to the
+ // linked list of seen file system links.
+ link_ = new LinkList(current_link);
if ((strcmp(entry->d_name, ".") == 0) ||
(strcmp(entry->d_name, "..") == 0)) {
return Next(listing);
}
return kListDirectory;
- case DT_BLK:
- case DT_CHR:
- case DT_FIFO:
- case DT_SOCK:
- case DT_REG:
- return kListFile;
- case DT_LNK:
- if (!listing->follow_links()) {
- return kListLink;
- }
- // Else fall through to next case.
- // Fall through.
- case DT_UNKNOWN: {
- // On some file systems the entry type is not determined by
- // readdir. For those and for links we use stat to determine
- // the actual entry type. Notice that stat returns the type of
- // the file pointed to.
- struct stat64 entry_info;
- int stat_success;
- stat_success = NO_RETRY_EXPECTED(
- lstat64(listing->path_buffer().AsString(), &entry_info));
- if (stat_success == -1) {
- perror("lstat64 failed: ");
- return kListError;
- }
- if (listing->follow_links() && S_ISLNK(entry_info.st_mode)) {
- // Check to see if we are in a loop created by a symbolic link.
- LinkList current_link = {entry_info.st_dev, entry_info.st_ino, link_};
- LinkList* previous = link_;
- while (previous != NULL) {
- if ((previous->dev == current_link.dev) &&
- (previous->ino == current_link.ino)) {
- // Report the looping link as a link, rather than following it.
- return kListLink;
- }
- previous = previous->next;
- }
- stat_success = NO_RETRY_EXPECTED(
- stat64(listing->path_buffer().AsString(), &entry_info));
- if (stat_success == -1) {
- perror("lstat64 failed");
- // Report a broken link as a link, even if follow_links is true.
- return kListLink;
- }
- if (S_ISDIR(entry_info.st_mode)) {
- // Recurse into the subdirectory with current_link added to the
- // linked list of seen file system links.
- link_ = new LinkList(current_link);
- if ((strcmp(entry->d_name, ".") == 0) ||
- (strcmp(entry->d_name, "..") == 0)) {
- return Next(listing);
- }
- return kListDirectory;
- }
- }
- if (S_ISDIR(entry_info.st_mode)) {
- if ((strcmp(entry->d_name, ".") == 0) ||
- (strcmp(entry->d_name, "..") == 0)) {
- return Next(listing);
- }
- return kListDirectory;
- } else if (S_ISREG(entry_info.st_mode) || S_ISCHR(entry_info.st_mode) ||
- S_ISBLK(entry_info.st_mode) ||
- S_ISFIFO(entry_info.st_mode) ||
- S_ISSOCK(entry_info.st_mode)) {
- return kListFile;
- } else if (S_ISLNK(entry_info.st_mode)) {
- return kListLink;
- } else {
- FATAL1("Unexpected st_mode: %d\n", entry_info.st_mode);
- return kListError;
- }
}
-
- default:
- // We should have covered all the bases. If not, let's get an error.
- FATAL1("Unexpected d_type: %d\n", entry->d_type);
- return kListError;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ if ((strcmp(entry->d_name, ".") == 0) ||
+ (strcmp(entry->d_name, "..") == 0)) {
+ return Next(listing);
+ }
+ return kListDirectory;
+ } else if (S_ISREG(entry_info.st_mode) || S_ISCHR(entry_info.st_mode) ||
+ S_ISBLK(entry_info.st_mode) || S_ISFIFO(entry_info.st_mode) ||
+ S_ISSOCK(entry_info.st_mode)) {
+ return kListFile;
+ } else if (S_ISLNK(entry_info.st_mode)) {
+ return kListLink;
+ } else {
+ FATAL1("Unexpected st_mode: %d\n", entry_info.st_mode);
+ return kListError;
}
}
done_ = true;
@@ -336,10 +306,7 @@
// Pattern has overflowed.
return NULL;
}
- char* result;
- do {
- result = mkdtemp(path.AsString());
- } while ((result == NULL) && (errno == EINTR));
+ char* result = mkdtemp(path.AsString());
if (result == NULL) {
return NULL;
}
@@ -347,6 +314,98 @@
}
+static bool DeleteRecursively(PathBuffer* path);
+
+
+static bool DeleteFile(char* file_name, PathBuffer* path) {
+ return path->Add(file_name) &&
+ (NO_RETRY_EXPECTED(unlink(path->AsString())) == 0);
+}
+
+
+static bool DeleteDir(char* dir_name, PathBuffer* path) {
+ if ((strcmp(dir_name, ".") == 0) || (strcmp(dir_name, "..") == 0)) {
+ return true;
+ }
+ return path->Add(dir_name) && DeleteRecursively(path);
+}
+
+
+static bool DeleteRecursively(PathBuffer* path) {
+ // Do not recurse into links for deletion. Instead delete the link.
+ // If it's a file, delete it.
+ struct stat64 st;
+ if (NO_RETRY_EXPECTED(lstat64(path->AsString(), &st)) == -1) {
+ return false;
+ } else if (!S_ISDIR(st.st_mode)) {
+ return NO_RETRY_EXPECTED(unlink(path->AsString())) == 0;
+ }
+
+ if (!path->Add(File::PathSeparator())) {
+ return false;
+ }
+
+ // Not a link. Attempt to open as a directory and recurse into the
+ // directory.
+ DIR* dir_pointer = opendir(path->AsString());
+ if (dir_pointer == NULL) {
+ return false;
+ }
+
+ // Iterate the directory and delete all files and directories.
+ int path_length = path->length();
+ while (true) {
+ // In case `readdir()` returns `NULL` we distinguish between end-of-stream
+ // and error by looking if `errno` was updated.
+ errno = 0;
+ // In glibc 2.24+, readdir_r is deprecated.
+ // According to the man page for readdir:
+ // "readdir(3) is not required to be thread-safe. However, in modern
+ // implementations (including the glibc implementation), concurrent calls to
+ // readdir(3) that specify different directory streams are thread-safe."
+ dirent* entry = readdir(dir_pointer);
+ if (entry == NULL) {
+ // Failed to read next directory entry.
+ if (errno != 0) {
+ break;
+ }
+ // End of directory.
+ return (NO_RETRY_EXPECTED(closedir(dir_pointer)) == 0) &&
+ (NO_RETRY_EXPECTED(remove(path->AsString())) == 0);
+ }
+ bool ok = false;
+ if (!path->Add(entry->d_name)) {
+ break;
+ }
+ // TODO(MG-450): When entry->d_type is filled out correctly, we can avoid
+ // this call to stat().
+ struct stat64 entry_info;
+ if (NO_RETRY_EXPECTED(lstat64(path->AsString(), &entry_info)) == -1) {
+ break;
+ }
+ path->Reset(path_length);
+ if (S_ISDIR(entry_info.st_mode)) {
+ ok = DeleteDir(entry->d_name, path);
+ } else {
+ // Treat links as files. This will delete the link which is
+ // what we want no matter if the link target is a file or a
+ // directory.
+ ok = DeleteFile(entry->d_name, path);
+ }
+ if (!ok) {
+ break;
+ }
+ path->Reset(path_length);
+ }
+ // Only happens if there was an error.
+ ASSERT(errno != 0);
+ int err = errno;
+ VOID_NO_RETRY_EXPECTED(closedir(dir_pointer));
+ errno = err;
+ return false;
+}
+
+
bool Directory::Delete(const char* dir_name, bool recursive) {
if (!recursive) {
if ((File::GetType(dir_name, false) == File::kIsLink) &&
@@ -355,10 +414,11 @@
}
return NO_RETRY_EXPECTED(rmdir(dir_name)) == 0;
} else {
- // TODO(MG-416): After the issue is addressed, this can use the same code
- // as on Linux, etc.
- UNIMPLEMENTED();
- return false;
+ PathBuffer path;
+ if (!path.Add(dir_name)) {
+ return false;
+ }
+ return DeleteRecursively(&path);
}
}
diff --git a/runtime/bin/eventhandler_fuchsia.cc b/runtime/bin/eventhandler_fuchsia.cc
index 39be1ff..667e9b0 100644
--- a/runtime/bin/eventhandler_fuchsia.cc
+++ b/runtime/bin/eventhandler_fuchsia.cc
@@ -327,7 +327,10 @@
delete di;
}
- DartUtils::PostInt32(port, 1 << kDestroyedEvent);
+ bool success = DartUtils::PostInt32(port, 1 << kDestroyedEvent);
+ if (!success) {
+ LOG_ERR("Failed to post destroy event to port %ld", port);
+ }
} else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) {
int count = TOKEN_COUNT(msg[i].data);
intptr_t old_mask = di->Mask();
@@ -404,7 +407,8 @@
if (!success) {
// This can happen if e.g. the isolate that owns the port has died
// for some reason.
- FATAL2("Failed to post event for fd %ld to port %ld", di->fd(), port);
+ LOG_ERR("Failed to post event for fd %ld to port %ld", di->fd(),
+ port);
}
}
}
diff --git a/runtime/bin/process_fuchsia.cc b/runtime/bin/process_fuchsia.cc
index 88b115a..81a4af3 100644
--- a/runtime/bin/process_fuchsia.cc
+++ b/runtime/bin/process_fuchsia.cc
@@ -61,6 +61,7 @@
if (closed != 0) {
FATAL("Failed to close process exit code pipe");
}
+ mx_handle_close(process_);
}
mx_handle_t process() const { return process_; }
intptr_t exit_pipe_fd() const { return exit_pipe_fd_; }
@@ -87,7 +88,6 @@
active_processes_ = info;
}
-
static intptr_t LookupProcessExitFd(mx_handle_t process) {
MutexLocker locker(mutex_);
ProcessInfo* current = active_processes_;
@@ -100,6 +100,9 @@
return 0;
}
+ static bool Exists(mx_handle_t process) {
+ return LookupProcessExitFd(process) != 0;
+ }
static void RemoveProcess(mx_handle_t process) {
MutexLocker locker(mutex_);
@@ -305,8 +308,8 @@
return_code, exit_code_fd);
if (exit_code_fd != 0) {
int exit_message[2];
- exit_message[0] = return_code;
- exit_message[1] = 0; // Do not negate return_code.
+ exit_message[0] = abs(return_code);
+ exit_message[1] = return_code >= 0 ? 0 : 1;
intptr_t result = FDUtils::WriteToBlocking(exit_code_fd, &exit_message,
sizeof(exit_message));
ASSERT((result == -1) || (result == sizeof(exit_code_fd)));
@@ -551,13 +554,37 @@
}
result->set_exit_code(exit_code);
+ // Close the process handle.
+ mx_handle_t process = static_cast<mx_handle_t>(pid);
+ mx_handle_close(process);
return true;
}
bool Process::Kill(intptr_t id, int signal) {
- errno = ENOSYS;
- return false;
+ LOG_INFO("Sending signal %d to process with id %ld\n", signal, id);
+ // mx_task_kill is definitely going to kill the process.
+ if ((signal != SIGTERM) && (signal != SIGKILL)) {
+ LOG_ERR("Signal %d not supported\n", signal);
+ errno = ENOSYS;
+ return false;
+ }
+ // We can only use mx_task_kill if we know id is a process handle, and we only
+ // know that for sure if it's in our list.
+ mx_handle_t process = static_cast<mx_handle_t>(id);
+ if (!ProcessInfoList::Exists(process)) {
+ LOG_ERR("Process %ld wasn't in the ProcessInfoList\n", id);
+ errno = ESRCH; // No such process.
+ return false;
+ }
+ mx_status_t status = mx_task_kill(process);
+ if (status != NO_ERROR) {
+ LOG_ERR("mx_task_kill failed: %s\n", mx_status_get_string(status));
+ errno = EPERM; // TODO(zra): Figure out what it really should be.
+ return false;
+ }
+ LOG_INFO("Signal %d sent successfully to process %ld\n", signal, id);
+ return true;
}
@@ -708,7 +735,12 @@
launchpad_t* lp;
mx_status_t status;
- status = launchpad_create(0, program_arguments_[0], &lp);
+ mx_handle_t job = MX_HANDLE_INVALID;
+ status = mx_handle_duplicate(launchpad_get_mxio_job(), MX_RIGHT_SAME_RIGHTS,
+ &job);
+ CHECK_FOR_ERROR(status, "mx_handle_duplicate");
+
+ status = launchpad_create(job, program_arguments_[0], &lp);
CHECK_FOR_ERROR(status, "launchpad_create");
launchpad_ = lp;
diff --git a/runtime/bin/run_vm_tests_fuchsia.cc b/runtime/bin/run_vm_tests_fuchsia.cc
index c83a9cf..e7d4015 100644
--- a/runtime/bin/run_vm_tests_fuchsia.cc
+++ b/runtime/bin/run_vm_tests_fuchsia.cc
@@ -133,7 +133,11 @@
}
launchpad_t* lp;
mx_status_t status;
- status = launchpad_create(0, argv[0], &lp);
+ mx_handle_t job = MX_HANDLE_INVALID;
+ status =
+ mx_handle_duplicate(launchpad_get_mxio_job(), MX_RIGHT_SAME_RIGHTS, &job);
+ RETURN_IF_ERROR(status);
+ status = launchpad_create(job, argv[0], &lp);
RETURN_IF_ERROR(status);
status = launchpad_arguments(lp, argc, argv);
RETURN_IF_ERROR(status);
diff --git a/runtime/bin/vmservice/loader.dart b/runtime/bin/vmservice/loader.dart
index 8af63b5..a72e735 100644
--- a/runtime/bin/vmservice/loader.dart
+++ b/runtime/bin/vmservice/loader.dart
@@ -53,6 +53,15 @@
return uri;
}
+class FileRequest {
+ final SendPort sp;
+ final int tag;
+ final Uri uri;
+ final Uri resolvedUri;
+ final String libraryUrl;
+ FileRequest(this.sp, this.tag, this.uri, this.resolvedUri, this.libraryUrl);
+}
+
// State associated with the isolate that is used for loading.
class IsolateLoaderState extends IsolateEmbedderData {
IsolateLoaderState(this.isolateId);
@@ -78,6 +87,7 @@
if (packagesConfigFlag != null) {
_setPackagesConfig(packagesConfigFlag);
}
+ _fileRequestQueue = new List<FileRequest>();
}
void cleanup() {
@@ -114,6 +124,24 @@
Uri _packageConfig = null;
Map<String, Uri> _packageMap = null;
+ // We issue only 16 concurrent calls to File.readAsBytes() to stay within
+ // platform-specific resource limits (e.g. max open files). The rest go on
+ // _fileRequestQueue and are processed when we can safely issue them.
+ static const int _maxFileRequests = 16;
+ int currentFileRequests = 0;
+ List<FileRequest> _fileRequestQueue;
+
+ bool get shouldIssueFileRequest => currentFileRequests < _maxFileRequests;
+ void enqueueFileRequest(FileRequest fr) {
+ _fileRequestQueue.add(fr);
+ }
+ FileRequest dequeueFileRequest() {
+ if (_fileRequestQueue.length == 0) {
+ return null;
+ }
+ return _fileRequestQueue.removeAt(0);
+ }
+
_setPackageRoot(String packageRoot) {
packageRoot = _sanitizeWindowsPath(packageRoot);
if (packageRoot.startsWith('file:') ||
@@ -399,7 +427,8 @@
Timer.run(() {});
}
-void _loadFile(SendPort sp,
+void _loadFile(IsolateLoaderState loaderState,
+ SendPort sp,
int tag,
Uri uri,
Uri resolvedUri,
@@ -411,6 +440,17 @@
},
onError: (e) {
_sendResourceResponse(sp, tag, uri, resolvedUri, libraryUrl, e.toString());
+ }).whenComplete(() {
+ loaderState.currentFileRequests--;
+ while (loaderState.shouldIssueFileRequest) {
+ FileRequest fr = loaderState.dequeueFileRequest();
+ if (fr == null) {
+ break;
+ }
+ _loadFile(
+ loaderState, fr.sp, fr.tag, fr.uri, fr.resolvedUri, fr.libraryUrl);
+ loaderState.currentFileRequests++;
+ }
});
}
@@ -507,7 +547,13 @@
Uri resolvedUri,
String libraryUrl) {
if (resolvedUri.scheme == '' || resolvedUri.scheme == 'file') {
- _loadFile(sp, tag, uri, resolvedUri, libraryUrl);
+ if (loaderState.shouldIssueFileRequest) {
+ _loadFile(loaderState, sp, tag, uri, resolvedUri, libraryUrl);
+ loaderState.currentFileRequests++;
+ } else {
+ FileRequest fr = new FileRequest(sp, tag, uri, resolvedUri, libraryUrl);
+ loaderState.enqueueFileRequest(fr);
+ }
} else if ((resolvedUri.scheme == 'http') ||
(resolvedUri.scheme == 'https')) {
_loadHttp(sp, tag, uri, resolvedUri, libraryUrl);
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index f99b111..a64dbed 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -819,6 +819,70 @@
}
+DEFINE_NATIVE_ENTRY(Mirrors_instantiateGenericType, 2) {
+ GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(1));
+
+ ASSERT(type.HasResolvedTypeClass());
+ const Class& clz = Class::Handle(type.type_class());
+ if (!clz.IsGeneric()) {
+ const Array& error_args = Array::Handle(Array::New(3));
+ error_args.SetAt(0, type);
+ error_args.SetAt(1, String::Handle(String::New("key")));
+ error_args.SetAt(2, String::Handle(String::New(
+ "Type must be a generic class or function.")));
+ Exceptions::ThrowByType(Exceptions::kArgumentValue, error_args);
+ UNREACHABLE();
+ }
+ if (clz.NumTypeParameters() != args.Length()) {
+ const Array& error_args = Array::Handle(Array::New(3));
+ error_args.SetAt(0, args);
+ error_args.SetAt(1, String::Handle(String::New("typeArguments")));
+ error_args.SetAt(2, String::Handle(String::New(
+ "Number of type arguments does not match.")));
+ Exceptions::ThrowByType(Exceptions::kArgumentValue, error_args);
+ UNREACHABLE();
+ }
+
+ intptr_t num_expected_type_arguments = args.Length();
+ TypeArguments& type_args_obj = TypeArguments::Handle();
+ type_args_obj ^= TypeArguments::New(num_expected_type_arguments);
+ AbstractType& type_arg = AbstractType::Handle();
+ Instance& instance = Instance::Handle();
+ for (intptr_t i = 0; i < args.Length(); i++) {
+ instance ^= args.At(i);
+ if (!instance.IsType()) {
+ const Array& error_args = Array::Handle(Array::New(3));
+ error_args.SetAt(0, args);
+ error_args.SetAt(1, String::Handle(String::New("typeArguments")));
+ error_args.SetAt(2, String::Handle(String::New(
+ "Type arguments must be instances of Type.")));
+ Exceptions::ThrowByType(Exceptions::kArgumentValue, error_args);
+ UNREACHABLE();
+ }
+ type_arg ^= args.At(i);
+ type_args_obj.SetTypeAt(i, type_arg);
+ }
+
+ Type& instantiated_type =
+ Type::Handle(Type::New(clz, type_args_obj, TokenPosition::kNoSource));
+ instantiated_type ^= ClassFinalizer::FinalizeType(
+ clz, instantiated_type, ClassFinalizer::kCanonicalize);
+ if (instantiated_type.IsMalbounded()) {
+ const LanguageError& type_error =
+ LanguageError::Handle(instantiated_type.error());
+ const Array& error_args = Array::Handle(Array::New(3));
+ error_args.SetAt(0, args);
+ error_args.SetAt(1, String::Handle(String::New("typeArguments")));
+ error_args.SetAt(2, String::Handle(type_error.FormatMessage()));
+ Exceptions::ThrowByType(Exceptions::kArgumentValue, error_args);
+ UNREACHABLE();
+ }
+
+ return instantiated_type.raw();
+}
+
+
DEFINE_NATIVE_ENTRY(Mirrors_mangleName, 2) {
GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index fe1c56e..f152adb 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -1645,6 +1645,8 @@
native "Mirrors_makeLocalClassMirror";
static TypeMirror makeLocalTypeMirror(Type key)
native "Mirrors_makeLocalTypeMirror";
+ static Type instantiateGenericType(Type key, typeArguments)
+ native "Mirrors_instantiateGenericType";
static Expando<ClassMirror> _declarationCache = new Expando("ClassMirror");
static Expando<TypeMirror> _instantiationCache = new Expando("TypeMirror");
@@ -1661,7 +1663,10 @@
return classMirror;
}
- static TypeMirror reflectType(Type key) {
+ static TypeMirror reflectType(Type key, [List<Type> typeArguments]) {
+ if (typeArguments != null) {
+ key = _instantiateType(key, typeArguments);
+ }
var typeMirror = _instantiationCache[key];
if (typeMirror == null) {
typeMirror = makeLocalTypeMirror(key);
@@ -1672,4 +1677,12 @@
}
return typeMirror;
}
+
+ static Type _instantiateType(Type key, List<Type> typeArguments) {
+ if (typeArguments.isEmpty) {
+ throw new ArgumentError.value(
+ typeArguments, 'typeArguments', 'Type arguments list cannot be empty.');
+ }
+ return instantiateGenericType(key, typeArguments.toList(growable: false));
+ }
}
diff --git a/runtime/lib/mirrors_patch.dart b/runtime/lib/mirrors_patch.dart
index 03bd1b6..c168026 100644
--- a/runtime/lib/mirrors_patch.dart
+++ b/runtime/lib/mirrors_patch.dart
@@ -33,8 +33,8 @@
return _Mirrors.reflectClass(key);
}
-@patch TypeMirror reflectType(Type key) {
- return _Mirrors.reflectType(key);
+@patch TypeMirror reflectType(Type key, [List<Type> typeArguments]) {
+ return _Mirrors.reflectType(key, typeArguments);
}
@patch class MirrorSystem {
diff --git a/runtime/observatory/tests/service/service.status b/runtime/observatory/tests/service/service.status
index 08d5bad..6e63e33 100644
--- a/runtime/observatory/tests/service/service.status
+++ b/runtime/observatory/tests/service/service.status
@@ -43,126 +43,6 @@
developer_extension_test: SkipByDesign
get_isolate_after_language_error_test: SkipByDesign
-# Issue #28236
-add_breakpoint_rpc_test: StaticWarning
-address_mapper_test: StaticWarning
-allocations_test: StaticWarning
-async_generator_breakpoint_test: StaticWarning
-async_next_test: StaticWarning
-async_scope_test: StaticWarning
-auth_token1_test: StaticWarning
-auth_token_test: StaticWarning
-bad_web_socket_address_test: StaticWarning
-break_on_activation_test: StaticWarning
-break_on_function_test: StaticWarning
-breakpoint_two_args_checked_test: StaticWarning
-caching_test: StaticWarning
-capture_stdio_test: StaticWarning
-code_test: StaticWarning
-command_test: StaticWarning
-complex_reload_test: StaticWarning
-contexts_test: StaticWarning
-crash_dump_test: StaticWarning
-debugger_inspect_test: StaticWarning
-debugger_location_second_test: StaticWarning
-debugger_location_test: StaticWarning
-debugging_inlined_finally_test: StaticWarning
-debugging_test: StaticWarning
-dev_fs_http_put_test: StaticWarning
-dev_fs_http_put_weird_char_test: StaticWarning
-dev_fs_spawn_test: StaticWarning
-dev_fs_test: StaticWarning
-dev_fs_weird_char_test: StaticWarning
-developer_server_control_test: StaticWarning
-developer_service_get_isolate_id_test: StaticWarning
-dominator_tree_user_test: StaticWarning
-dominator_tree_vm_test: StaticWarning
-echo_test: StaticWarning
-eval_internal_class_test: StaticWarning
-eval_test: StaticWarning
-evaluate_activation_test/instance: StaticWarning
-evaluate_activation_test/none: StaticWarning
-evaluate_activation_test/scope: StaticWarning
-evaluate_in_async_activation_test: StaticWarning
-evaluate_in_async_star_activation_test: StaticWarning
-evaluate_in_frame_rpc_test: StaticWarning
-evaluate_in_sync_star_activation_test: StaticWarning
-file_service_test: StaticWarning
-gc_test: StaticWarning
-get_allocation_profile_rpc_test: StaticWarning
-get_allocation_samples_test: StaticWarning
-get_cpu_profile_timeline_rpc_test: StaticWarning
-get_flag_list_rpc_test: StaticWarning
-get_heap_map_rpc_test: StaticWarning
-get_instances_rpc_test: StaticWarning
-get_isolate_after_async_error_test: StaticWarning
-get_isolate_after_stack_overflow_error_test: StaticWarning
-get_isolate_after_sync_error_test: StaticWarning
-get_isolate_rpc_test: StaticWarning
-get_object_rpc_test: StaticWarning
-get_object_store_rpc_test: StaticWarning
-get_ports_rpc_test: StaticWarning
-get_retained_size_rpc_test: StaticWarning
-get_retaining_path_rpc_test: StaticWarning
-get_source_report_test: StaticWarning
-get_stack_rpc_test: StaticWarning
-get_version_rpc_test: StaticWarning
-get_vm_rpc_test: StaticWarning
-get_vm_timeline_rpc_test: StaticWarning
-get_zone_memory_info_rpc_test: StaticWarning
-implicit_getter_setter_test: StaticWarning
-inbound_references_test: StaticWarning
-instance_field_order_rpc_test: StaticWarning
-isolate_lifecycle_test: StaticWarning
-issue_25465_test: StaticWarning
-issue_27238_test: StaticWarning
-issue_27287_test: StaticWarning
-library_dependency_test: StaticWarning
-local_variable_declaration_test: StaticWarning
-logging_test: StaticWarning
-malformed_test: StaticWarning
-metrics_test: StaticWarning
-mirror_references_test: StaticWarning
-native_metrics_test: StaticWarning
-object_graph_stack_reference_test: StaticWarning
-object_graph_user_test: StaticWarning
-object_graph_vm_test: StaticWarning
-observatory_assets_test: StaticWarning
-parameters_in_scope_at_entry_test: StaticWarning
-pause_idle_isolate_test: StaticWarning
-pause_on_exceptions_test: StaticWarning
-pause_on_start_and_exit_test: StaticWarning
-pause_on_start_then_step_test: StaticWarning
-pause_on_unhandled_exceptions_test: StaticWarning
-positive_token_pos_test: StaticWarning
-process_service_test: StaticWarning
-reachable_size_test: StaticWarning
-read_stream_test: StaticWarning
-regexp_function_test: StaticWarning
-reload_sources_test: StaticWarning
-rewind_optimized_out_test: StaticWarning
-rewind_test: StaticWarning
-set_library_debuggable_rpc_test: StaticWarning
-set_library_debuggable_test: StaticWarning
-set_name_rpc_test: StaticWarning
-set_vm_name_rpc_test: StaticWarning
-smart_next_test: StaticWarning
-steal_breakpoint_test: StaticWarning
-step_into_async_no_await_test: StaticWarning
-step_over_await_test: StaticWarning
-step_test: StaticWarning
-string_escaping_test: StaticWarning
-tcp_socket_closing_service_test: StaticWarning
-tcp_socket_service_test: StaticWarning
-type_arguments_test: StaticWarning
-typed_data_test: StaticWarning
-udp_socket_service_test: StaticWarning
-vm_restart_test: StaticWarning
-vm_test: StaticWarning
-vm_timeline_events_test: StaticWarning
-vm_timeline_flags_test: StaticWarning
-weak_properties_test: StaticWarning
-
[ $arch == arm ]
process_service_test: Pass, Fail # Issue 24344
diff --git a/runtime/tests/vm/dart/hello_fuchsia_test.dart b/runtime/tests/vm/dart/hello_fuchsia_test.dart
index 8053b85..8d597f2 100644
--- a/runtime/tests/vm/dart/hello_fuchsia_test.dart
+++ b/runtime/tests/vm/dart/hello_fuchsia_test.dart
@@ -397,6 +397,17 @@
print("$exe --version had stderr = '${result.stderr}'");
}
+Future testKill() async {
+ String exe = Platform.resolvedExecutable;
+ String script = Platform.script.path;
+ print("Running $exe $script");
+ Process p = await Process.start(exe, [script, "infinite-loop"]);
+ await new Future.delayed(const Duration(seconds: 1));
+ p.kill();
+ int code = await p.exitCode;
+ print("$exe $script exited with code $code");
+}
+
Future testLs(String path) async {
Stream<FileSystemEntity> stream = (new Directory(path)).list();
await for (FileSystemEntity fse in stream) {
@@ -431,7 +442,35 @@
await tmp.delete();
}
-main() async {
+Future testRecursiveDelete() async {
+ Directory tmp0 = await Directory.systemTemp.createTemp("testRD");
+ Directory tmp1 = await tmp0.createTemp("testRD");
+ Directory tmp2 = await tmp1.createTemp("testRD");
+ File file0 = new File("${tmp0.path}/file");
+ File file1 = new File("${tmp1.path}/file");
+ File file2 = new File("${tmp2.path}/file");
+ List<int> data = new List<int>.generate(10 * 1024, (int i) => i & 0xff);
+ await file0.writeAsBytes(data);
+ await file1.writeAsBytes(data);
+ await file2.writeAsBytes(data);
+
+ await tmp0.delete(recursive: true);
+
+ assert(!await file2.exists());
+ assert(!await file1.exists());
+ assert(!await file0.exists());
+ assert(!await tmp2.exists());
+ assert(!await tmp1.exists());
+ assert(!await tmp0.exists());
+}
+
+main(List<String> args) async {
+ if (args.length >= 1) {
+ if (args[0] == "infinite-loop") {
+ while (true);
+ }
+ }
+
print("Hello, Fuchsia!");
print("testAddressParse");
@@ -478,9 +517,17 @@
testProcessRunSync();
print("testProcessRunSync done");
+ print("testKill");
+ await testKill();
+ print("testKill done");
+
print("testCopy");
await testCopy();
print("testCopy done");
+ print("testRecursiveDelete");
+ await testRecursiveDelete();
+ print("testRecursiveDelete done");
+
print("Goodbyte, Fuchsia!");
}
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index 0a2934a..fdcb0b4 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -30,6 +30,24 @@
dart/data_uri_import_test/none: SkipByDesign
+[ $mode == debug && $arch != ia32 && $system != windows ]
+cc/Profiler_ArrayAllocation: Fail # 28304
+cc/Profiler_BasicSourcePosition: Fail # 28304
+cc/Profiler_BasicSourcePositionOptimized: Fail, Crash # 28304, # 28282
+cc/Profiler_BinaryOperatorSourcePosition: Fail # 28304
+cc/Profiler_BinaryOperatorSourcePositionOptimized: Fail # 28304
+cc/Profiler_ChainedSamples: Fail # 28304
+cc/Profiler_ClosureAllocation: Fail # 28304
+cc/Profiler_CodeTicks: Fail # 28304
+cc/Profiler_ContextAllocation: Fail # 28304
+cc/Profiler_FunctionInline: Fail # 28304
+cc/Profiler_FunctionTicks: Fail # 28304
+cc/Profiler_SourcePosition: Fail # 28304
+cc/Profiler_SourcePositionOptimized: Fail # 28304
+cc/Profiler_ToggleRecordAllocation: Fail # 28304
+cc/Profiler_TrivialRecordAllocation: Fail # 28304
+cc/Profiler_TypedArrayAllocation: Fail # 28304
+
[ $mode == debug ]
# This is a benchmark that is not informative in debug mode.
cc/CorelibIsolateStartup: Skip
@@ -149,6 +167,82 @@
[ $builder_tag == asan ]
cc/CodeImmutability: Fail,OK # Address Sanitizer turns a crash into a failure.
+[ $builder_tag == asan && $arch == x64 ]
+cc/Service_Profile: Fail # Issue 28342
+cc/Service_PersistentHandles: Fail # Issue 28342
+cc/Service_EmbedderIsolateHandler: Fail # Issue 28342
+cc/Service_LocalVarDescriptors: Fail # Issue 28342
+cc/Service_Code: Fail # Issue 28342
+cc/Service_EmbedderRootHandler: Fail # Issue 28342
+cc/Service_TokenStream: Fail # Issue 28342
+cc/Service_PcDescriptors: Fail # Issue 28342
+cc/Service_Address: Fail # Issue 28342
+
+cc/EmbeddedScript: Fail # Issue 28345
+
+cc/Log_Basic: Fail # Issue 28347
+cc/Log_Block: Fail # Issue 28347
+cc/Log_Macro: Fail # Issue 28347
+
+cc/Debug_DeleteBreakpoint: Fail # Issue 28348
+
+cc/IsolateReload_ChangeInstanceFormat7: Fail # Issue 28349
+cc/IsolateReload_ClassAdded: Fail # Issue 28349
+cc/IsolateReload_ComplexInheritanceChange: Fail # Issue 28349
+cc/IsolateReload_ConstFieldUpdate: Fail # Issue 28349
+cc/IsolateReload_ConstantIdentical: Fail # Issue 28349
+cc/IsolateReload_ConstructorChanged: Fail # Issue 28349
+cc/IsolateReload_DanglingGetter_Class: Fail # Issue 28349
+cc/IsolateReload_DanglingGetter_Instance: Fail # Issue 28349
+cc/IsolateReload_DanglingGetter_Library: Fail # Issue 28349
+cc/IsolateReload_DanglingSetter_Class: Fail # Issue 28349
+cc/IsolateReload_DanglingSetter_Instance: Fail # Issue 28349
+cc/IsolateReload_DanglingSetter_Library: Fail # Issue 28349
+cc/IsolateReload_DirectSubclasses_GhostSubclass: Fail # Issue 28349
+cc/IsolateReload_DirectSubclasses_Success: Fail # Issue 28349
+cc/IsolateReload_EnumAddition: Fail # Issue 28349
+cc/IsolateReload_EnumDelete: Fail # Issue 28349
+cc/IsolateReload_EnumEquality: Fail # Issue 28349
+cc/IsolateReload_EnumIdentical: Fail # Issue 28349
+cc/IsolateReload_EnumIdentityReload: Fail # Issue 28349
+cc/IsolateReload_EnumReorderIdentical: Fail # Issue 28349
+cc/IsolateReload_EnumValuesToString: Fail # Issue 28349
+cc/IsolateReload_ExportedLibModified: Fail # Issue 28349
+cc/IsolateReload_FunctionReplacement: Fail # Issue 28349
+cc/IsolateReload_Generics: Fail # Issue 28349
+cc/IsolateReload_ImplicitConstructorChanged: Fail # Issue 28349
+cc/IsolateReload_ImportedLibModified: Fail # Issue 28349
+cc/IsolateReload_ImportedMixinFunction: Fail # Issue 28349
+cc/IsolateReload_LibraryDebuggable: Fail # Issue 28349
+cc/IsolateReload_LibraryHide: Fail # Issue 28349
+cc/IsolateReload_LibraryImportAdded: Fail # Issue 28349
+cc/IsolateReload_LibraryImportRemoved: Fail # Issue 28349
+cc/IsolateReload_LibraryLookup: Fail # Issue 28349
+cc/IsolateReload_LibraryShow: Fail # Issue 28349
+cc/IsolateReload_LiveStack: Fail # Issue 28349
+cc/IsolateReload_MainLibModified: Fail # Issue 28349
+cc/IsolateReload_MixinChanged: Fail # Issue 28349
+cc/IsolateReload_PendingSuperCall: Fail # Issue 28349
+cc/IsolateReload_PrefixImportedLibModified: Fail # Issue 28349
+cc/IsolateReload_SavedClosure: Fail # Issue 28349
+cc/IsolateReload_SavedClosure: Fail # Issue 28349
+cc/IsolateReload_SimpleConstFieldUpdate: Fail # Issue 28349
+cc/IsolateReload_SmiFastPathStubs: Fail # Issue 28349
+cc/IsolateReload_StaticTearOffRetainsHash: Fail # Issue 28349
+cc/IsolateReload_StaticValuePreserved: Fail # Issue 28349
+cc/IsolateReload_StaticValuePreserved: Fail # Issue 28349
+cc/IsolateReload_SuperClassChanged: Fail # Issue 28349
+cc/IsolateReload_TearOff_AddArguments2: Fail # Issue 28349
+cc/IsolateReload_TearOff_AddArguments: Fail # Issue 28349
+cc/IsolateReload_TearOff_Class_Identity: Fail # Issue 28349
+cc/IsolateReload_TearOff_Instance_Equality: Fail # Issue 28349
+cc/IsolateReload_TearOff_Library_Identity: Fail # Issue 28349
+cc/IsolateReload_TearOff_List_Set: Fail # Issue 28349
+cc/IsolateReload_TopLevelFieldAdded: Fail # Issue 28349
+cc/IsolateReload_TypeIdentity: Fail # Issue 28349
+cc/IsolateReload_TypeIdentityGeneric: Fail # Issue 28349
+cc/IsolateReload_TypeIdentityParameter: Fail # Issue 28349
+
[ $noopt || $compiler == precompiler ]
dart/byte_array_test: Skip # Incompatible flag --disable_alloc_stubs_after_gc
diff --git a/runtime/vm/ast_transformer.cc b/runtime/vm/ast_transformer.cc
index 974259e..fa1028d 100644
--- a/runtime/vm/ast_transformer.cc
+++ b/runtime/vm/ast_transformer.cc
@@ -207,8 +207,8 @@
new (Z) LoadLocalNode(token_pos, stack_trace_param);
SequenceNode* error_ne_null_branch =
new (Z) SequenceNode(token_pos, ChainNewScope(preamble_->scope()));
- error_ne_null_branch->Add(
- new (Z) ThrowNode(token_pos, load_error_param, load_stack_trace_param));
+ error_ne_null_branch->Add(new (Z) ThrowNode(
+ node->token_pos(), load_error_param, load_stack_trace_param));
preamble_->Add(new (Z) IfNode(
token_pos, new (Z) ComparisonNode(
token_pos, Token::kNE, load_error_param,
diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc
index db3bfc4..e2f8790 100644
--- a/runtime/vm/benchmark_test.cc
+++ b/runtime/vm/benchmark_test.cc
@@ -96,9 +96,8 @@
Dart_Isolate Benchmark::CreateIsolate(const uint8_t* buffer) {
- bin::IsolateData* isolate_data = new bin::IsolateData(NULL, NULL, NULL);
char* err = NULL;
- isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, isolate_data, &err);
+ isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, NULL, &err);
EXPECT(isolate_ != NULL);
free(err);
return isolate_;
@@ -520,6 +519,9 @@
const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
ASSERT(snapshot->kind() == Snapshot::kCore);
benchmark->set_score(snapshot->length());
+
+ free(vm_isolate_snapshot_buffer);
+ free(isolate_snapshot_buffer);
}
@@ -554,6 +556,9 @@
const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
ASSERT(snapshot->kind() == Snapshot::kCore);
benchmark->set_score(snapshot->length());
+
+ free(vm_isolate_snapshot_buffer);
+ free(isolate_snapshot_buffer);
}
diff --git a/runtime/vm/bootstrap_natives.h b/runtime/vm/bootstrap_natives.h
index 1260f7c..725af06 100644
--- a/runtime/vm/bootstrap_natives.h
+++ b/runtime/vm/bootstrap_natives.h
@@ -366,6 +366,7 @@
V(Mirrors_evalInLibraryWithPrivateKey, 2) \
V(Mirrors_makeLocalClassMirror, 1) \
V(Mirrors_makeLocalTypeMirror, 1) \
+ V(Mirrors_instantiateGenericType, 2) \
V(Mirrors_mangleName, 2) \
V(MirrorReference_equals, 2) \
V(MirrorSystem_libraries, 0) \
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index f239661..be24a41 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -2518,8 +2518,9 @@
cls.SetFunctions(functions);
}
// Every class should have at least a constructor, unless it is a top level
- // class or a typedef class.
- ASSERT(cls.IsTopLevel() || cls.IsTypedefClass() ||
+ // class or a typedef class. The Kernel frontend does not create an implicit
+ // constructor for abstract classes.
+ ASSERT(cls.IsTopLevel() || cls.IsTypedefClass() || cls.is_abstract() ||
(Array::Handle(cls.functions()).Length() > 0));
// Resolve and finalize all member types.
ResolveAndFinalizeMemberTypes(cls);
diff --git a/runtime/vm/compiler_test.cc b/runtime/vm/compiler_test.cc
index 5225c53..6e44b6c 100644
--- a/runtime/vm/compiler_test.cc
+++ b/runtime/vm/compiler_test.cc
@@ -102,10 +102,13 @@
ASSERT(isolate->background_compiler() != NULL);
isolate->background_compiler()->CompileOptimized(func);
Monitor* m = new Monitor();
- MonitorLocker ml(m);
- while (!func.HasOptimizedCode()) {
- ml.WaitWithSafepointCheck(thread, 1);
+ {
+ MonitorLocker ml(m);
+ while (!func.HasOptimizedCode()) {
+ ml.WaitWithSafepointCheck(thread, 1);
+ }
}
+ delete m;
BackgroundCompiler::Stop(isolate);
}
diff --git a/runtime/vm/kernel.cc b/runtime/vm/kernel.cc
index f30e100..48dcbde 100644
--- a/runtime/vm/kernel.cc
+++ b/runtime/vm/kernel.cc
@@ -752,20 +752,6 @@
}
-BlockExpression::~BlockExpression() {}
-
-
-void BlockExpression::AcceptExpressionVisitor(ExpressionVisitor* visitor) {
- visitor->VisitBlockExpression(this);
-}
-
-
-void BlockExpression::VisitChildren(Visitor* visitor) {
- visitor->VisitBlock(body());
- value()->AcceptExpressionVisitor(visitor);
-}
-
-
Statement::~Statement() {}
diff --git a/runtime/vm/kernel.h b/runtime/vm/kernel.h
index 998bc5e..ea04b73 100644
--- a/runtime/vm/kernel.h
+++ b/runtime/vm/kernel.h
@@ -79,7 +79,6 @@
M(AwaitExpression) \
M(FunctionExpression) \
M(Let) \
- M(BlockExpression) \
M(Statement) \
M(InvalidStatement) \
M(ExpressionStatement) \
@@ -489,6 +488,7 @@
intptr_t source_uri_index() { return source_uri_index_; }
bool is_abstract() { return is_abstract_; }
List<Expression>& annotations() { return annotations_; }
+ TokenPosition position() { return position_; }
virtual List<TypeParameter>& type_parameters() = 0;
virtual List<InterfaceType>& implemented_classes() = 0;
@@ -497,7 +497,7 @@
virtual List<Procedure>& procedures() = 0;
protected:
- Class() : is_abstract_(false) {}
+ Class() : is_abstract_(false), position_(TokenPosition::kNoSource) {}
private:
template <typename T>
@@ -508,6 +508,7 @@
intptr_t source_uri_index_;
bool is_abstract_;
List<Expression> annotations_;
+ TokenPosition position_;
DISALLOW_COPY_AND_ASSIGN(Class);
};
@@ -608,9 +609,13 @@
TreeNode* parent() { return parent_; }
Name* name() { return name_; }
List<Expression>& annotations() { return annotations_; }
+ TokenPosition position() { return position_; }
+ TokenPosition end_position() { return end_position_; }
protected:
- Member() {}
+ Member()
+ : position_(TokenPosition::kNoSource),
+ end_position_(TokenPosition::kNoSource) {}
template <typename T>
friend class List;
@@ -618,6 +623,8 @@
Ref<TreeNode> parent_;
Child<Name> name_;
List<Expression> annotations_;
+ TokenPosition position_;
+ TokenPosition end_position_;
private:
DISALLOW_COPY_AND_ASSIGN(Member);
@@ -651,10 +658,9 @@
DartType* type() { return type_; }
InferredValue* inferred_value() { return inferred_value_; }
Expression* initializer() { return initializer_; }
- TokenPosition position() { return position_; }
private:
- Field() : position_(TokenPosition::kNoSource) {}
+ Field() {}
template <typename T>
friend class List;
@@ -664,7 +670,6 @@
Child<DartType> type_;
Child<InferredValue> inferred_value_;
Child<Expression> initializer_;
- TokenPosition position_;
DISALLOW_COPY_AND_ASSIGN(Field);
};
@@ -920,6 +925,7 @@
virtual void VisitChildren(Visitor* visitor);
AsyncMarker async_marker() { return async_marker_; }
+ bool debuggable() { return debuggable_; }
TypeParameterList& type_parameters() { return type_parameters_; }
int required_parameter_count() { return required_parameter_count_; }
List<VariableDeclaration>& positional_parameters() {
@@ -929,11 +935,16 @@
DartType* return_type() { return return_type_; }
InferredValue* inferred_return_value() { return inferred_return_value_; }
Statement* body() { return body_; }
+ TokenPosition position() { return position_; }
+ TokenPosition end_position() { return end_position_; }
private:
- FunctionNode() {}
+ FunctionNode()
+ : position_(TokenPosition::kNoSource),
+ end_position_(TokenPosition::kNoSource) {}
AsyncMarker async_marker_;
+ bool debuggable_;
TypeParameterList type_parameters_;
int required_parameter_count_;
List<VariableDeclaration> positional_parameters_;
@@ -941,6 +952,8 @@
Child<DartType> return_type_;
Child<InferredValue> inferred_return_value_;
Child<Statement> body_;
+ TokenPosition position_;
+ TokenPosition end_position_;
DISALLOW_COPY_AND_ASSIGN(FunctionNode);
};
@@ -1894,42 +1907,23 @@
VariableDeclaration* variable() { return variable_; }
Expression* body() { return body_; }
+ TokenPosition position() { return position_; }
+ TokenPosition end_position() { return end_position_; }
private:
- Let() {}
+ Let()
+ : position_(TokenPosition::kNoSource),
+ end_position_(TokenPosition::kNoSource) {}
Child<VariableDeclaration> variable_;
Child<Expression> body_;
+ TokenPosition position_;
+ TokenPosition end_position_;
DISALLOW_COPY_AND_ASSIGN(Let);
};
-class BlockExpression : public Expression {
- public:
- static BlockExpression* ReadFrom(Reader* reader);
- virtual void WriteTo(Writer* writer);
-
- virtual ~BlockExpression();
-
- DEFINE_CASTING_OPERATIONS(BlockExpression);
-
- virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
- virtual void VisitChildren(Visitor* visitor);
-
- Block* body() { return body_; }
- Expression* value() { return value_; }
-
- private:
- BlockExpression() {}
-
- Child<Block> body_;
- Child<Expression> value_;
-
- DISALLOW_COPY_AND_ASSIGN(BlockExpression);
-};
-
-
class Statement : public TreeNode {
public:
static Statement* ReadFrom(Reader* reader);
@@ -1941,9 +1935,11 @@
virtual void AcceptTreeVisitor(TreeVisitor* visitor);
virtual void AcceptStatementVisitor(StatementVisitor* visitor) = 0;
+ TokenPosition position() { return position_; }
protected:
- Statement() {}
+ Statement() : position_(TokenPosition::kNoSource) {}
+ TokenPosition position_;
private:
DISALLOW_COPY_AND_ASSIGN(Statement);
@@ -2941,9 +2937,6 @@
VisitDefaultBasicLiteral(node);
}
virtual void VisitLet(Let* node) { VisitDefaultExpression(node); }
- virtual void VisitBlockExpression(BlockExpression* node) {
- VisitDefaultExpression(node);
- }
};
diff --git a/runtime/vm/kernel_binary.cc b/runtime/vm/kernel_binary.cc
index f204854..4cdc004 100644
--- a/runtime/vm/kernel_binary.cc
+++ b/runtime/vm/kernel_binary.cc
@@ -94,7 +94,6 @@
kAwaitExpression = 51,
kFunctionExpression = 52,
kLet = 53,
- kBlockExpression = 54,
kPositiveIntLiteral = 55,
kNegativeIntLiteral = 56,
@@ -919,6 +918,7 @@
Class* Class::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
+ position_ = reader->ReadPosition();
is_abstract_ = reader->ReadBool();
name_ = Reference::ReadStringFrom(reader);
source_uri_index_ = reader->ReadUInt();
@@ -930,6 +930,7 @@
void Class::WriteTo(Writer* writer) {
TRACE_WRITE_OFFSET();
+ writer->WritePosition(position_);
writer->WriteBool(is_abstract_);
name_->WriteTo(writer);
writer->WriteUInt(source_uri_index_);
@@ -1167,6 +1168,7 @@
ASSERT(tag == kField);
position_ = reader->ReadPosition();
+ end_position_ = reader->ReadPosition();
flags_ = reader->ReadFlags();
name_ = Name::ReadFrom(reader);
source_uri_index_ = reader->ReadUInt();
@@ -1182,6 +1184,7 @@
TRACE_WRITE_OFFSET();
writer->WriteTag(kField);
writer->WritePosition(position_);
+ writer->WritePosition(end_position_);
writer->WriteFlags(flags_);
name_->WriteTo(writer);
writer->WriteUInt(source_uri_index_);
@@ -1198,6 +1201,8 @@
ASSERT(tag == kConstructor);
VariableScope<ReaderHelper> parameters(reader->helper());
+ position_ = reader->ReadPosition();
+ end_position_ = reader->ReadPosition();
flags_ = reader->ReadFlags();
name_ = Name::ReadFrom(reader);
annotations_.ReadFromStatic<Expression>(reader);
@@ -1211,6 +1216,8 @@
TRACE_WRITE_OFFSET();
writer->WriteTag(kConstructor);
+ writer->WritePosition(position_);
+ writer->WritePosition(end_position_);
VariableScope<WriterHelper> parameters(writer->helper());
writer->WriteFlags(flags_);
name_->WriteTo(writer);
@@ -1226,6 +1233,8 @@
ASSERT(tag == kProcedure);
VariableScope<ReaderHelper> parameters(reader->helper());
+ position_ = reader->ReadPosition();
+ end_position_ = reader->ReadPosition();
kind_ = static_cast<ProcedureKind>(reader->ReadByte());
flags_ = reader->ReadFlags();
name_ = Name::ReadFrom(reader);
@@ -1240,6 +1249,8 @@
TRACE_WRITE_OFFSET();
writer->WriteTag(kProcedure);
+ writer->WritePosition(position_);
+ writer->WritePosition(end_position_);
VariableScope<WriterHelper> parameters(writer->helper());
writer->WriteByte(kind_);
writer->WriteFlags(flags_);
@@ -1424,8 +1435,6 @@
return FunctionExpression::ReadFrom(reader);
case kLet:
return Let::ReadFrom(reader);
- case kBlockExpression:
- return BlockExpression::ReadFrom(reader);
case kBigIntLiteral:
return BigintLiteral::ReadFrom(reader);
case kStringLiteral:
@@ -1466,6 +1475,7 @@
VariableGet* VariableGet::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
VariableGet* get = new VariableGet();
+ get->position_ = reader->ReadPosition();
get->variable_ = reader->helper()->variables().Lookup(reader->ReadUInt());
reader->ReadOptional<DartType>(); // Unused promoted type.
return get;
@@ -1475,6 +1485,7 @@
VariableGet* VariableGet::ReadFrom(Reader* reader, uint8_t payload) {
TRACE_READ_OFFSET();
VariableGet* get = new VariableGet();
+ get->position_ = reader->ReadPosition();
get->variable_ = reader->helper()->variables().Lookup(payload);
return get;
}
@@ -1485,8 +1496,10 @@
int index = writer->helper()->variables().Lookup(variable_);
if ((index & kSpecializedPayloadMask) == index) {
writer->WriteTag(kSpecializedVariableGet, static_cast<uint8_t>(index));
+ writer->WritePosition(position_);
} else {
writer->WriteTag(kVariableGet);
+ writer->WritePosition(position_);
writer->WriteUInt(index);
writer->WriteOptional<DartType>(NULL);
}
@@ -1496,6 +1509,7 @@
VariableSet* VariableSet::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
VariableSet* set = new VariableSet();
+ set->position_ = reader->ReadPosition();
set->variable_ = reader->helper()->variables().Lookup(reader->ReadUInt());
set->expression_ = Expression::ReadFrom(reader);
return set;
@@ -1506,6 +1520,7 @@
TRACE_READ_OFFSET();
VariableSet* set = new VariableSet();
set->variable_ = reader->helper()->variables().Lookup(payload);
+ set->position_ = reader->ReadPosition();
set->expression_ = Expression::ReadFrom(reader);
return set;
}
@@ -1516,8 +1531,10 @@
int index = writer->helper()->variables().Lookup(variable_);
if ((index & kSpecializedPayloadMask) == index) {
writer->WriteTag(kSpecializedVariableSet, static_cast<uint8_t>(index));
+ writer->WritePosition(position_);
} else {
writer->WriteTag(kVariableSet);
+ writer->WritePosition(position_);
writer->WriteUInt(index);
}
expression_->WriteTo(writer);
@@ -1813,6 +1830,7 @@
StringConcatenation* StringConcatenation::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
StringConcatenation* concat = new StringConcatenation();
+ concat->position_ = reader->ReadPosition();
concat->expressions_.ReadFromStatic<Expression>(reader);
return concat;
}
@@ -1821,6 +1839,7 @@
void StringConcatenation::WriteTo(Writer* writer) {
TRACE_WRITE_OFFSET();
writer->WriteTag(kStringConcatenation);
+ writer->WritePosition(position_);
expressions_.WriteTo(writer);
}
@@ -1828,6 +1847,7 @@
IsExpression* IsExpression::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
IsExpression* expr = new IsExpression();
+ expr->position_ = reader->ReadPosition();
expr->operand_ = Expression::ReadFrom(reader);
expr->type_ = DartType::ReadFrom(reader);
return expr;
@@ -1837,6 +1857,7 @@
void IsExpression::WriteTo(Writer* writer) {
TRACE_WRITE_OFFSET();
writer->WriteTag(kIsExpression);
+ writer->WritePosition(position_);
operand_->WriteTo(writer);
type_->WriteTo(writer);
}
@@ -2048,6 +2069,7 @@
TRACE_READ_OFFSET();
MapLiteral* literal = new MapLiteral();
literal->is_const_ = is_const;
+ literal->position_ = reader->ReadPosition();
literal->key_type_ = DartType::ReadFrom(reader);
literal->value_type_ = DartType::ReadFrom(reader);
literal->entries_.ReadFromStatic<MapEntry>(reader);
@@ -2058,6 +2080,7 @@
void MapLiteral::WriteTo(Writer* writer) {
TRACE_WRITE_OFFSET();
writer->WriteTag(is_const_ ? kConstMapLiteral : kMapLiteral);
+ writer->WritePosition(position_);
key_type_->WriteTo(writer);
value_type_->WriteTo(writer);
entries_.WriteTo(writer);
@@ -2130,23 +2153,6 @@
}
-BlockExpression* BlockExpression::ReadFrom(Reader* reader) {
- TRACE_READ_OFFSET();
- BlockExpression* be = new BlockExpression();
- be->body_ = Block::ReadFromImpl(reader);
- be->value_ = Expression::ReadFrom(reader);
- return be;
-}
-
-
-void BlockExpression::WriteTo(Writer* writer) {
- TRACE_WRITE_OFFSET();
- writer->WriteTag(kBlockExpression);
- body_->WriteToImpl(writer);
- value_->WriteTo(writer);
-}
-
-
Statement* Statement::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
Tag tag = reader->ReadTag();
@@ -2476,6 +2482,7 @@
ReturnStatement* ReturnStatement::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
ReturnStatement* ret = new ReturnStatement();
+ ret->position_ = reader->ReadPosition();
ret->expression_ = reader->ReadOptional<Expression>();
return ret;
}
@@ -2484,6 +2491,7 @@
void ReturnStatement::WriteTo(Writer* writer) {
TRACE_WRITE_OFFSET();
writer->WriteTag(kReturnStatement);
+ writer->WritePosition(position_);
writer->WriteOptional<Expression>(expression_);
}
@@ -2551,6 +2559,7 @@
YieldStatement* YieldStatement::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
YieldStatement* stmt = new YieldStatement();
+ stmt->position_ = reader->ReadPosition();
stmt->flags_ = reader->ReadByte();
stmt->expression_ = Expression::ReadFrom(reader);
return stmt;
@@ -2560,6 +2569,7 @@
void YieldStatement::WriteTo(Writer* writer) {
TRACE_WRITE_OFFSET();
writer->WriteTag(kYieldStatement);
+ writer->WritePosition(position_);
writer->WriteByte(flags_);
expression_->WriteTo(writer);
}
@@ -2576,6 +2586,7 @@
VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) {
TRACE_READ_OFFSET();
VariableDeclaration* decl = new VariableDeclaration();
+ decl->position_ = reader->ReadPosition();
decl->flags_ = reader->ReadFlags();
decl->name_ = Reference::ReadStringFrom(reader);
decl->type_ = DartType::ReadFrom(reader);
@@ -2595,6 +2606,7 @@
void VariableDeclaration::WriteToImpl(Writer* writer) {
TRACE_WRITE_OFFSET();
+ writer->WritePosition(position_);
writer->WriteFlags(flags_);
name_->WriteTo(writer);
type_->WriteTo(writer);
@@ -2607,6 +2619,7 @@
FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
FunctionDeclaration* decl = new FunctionDeclaration();
+ decl->position_ = reader->ReadPosition();
decl->variable_ = VariableDeclaration::ReadFromImpl(reader);
VariableScope<ReaderHelper> parameters(reader->helper());
decl->function_ = FunctionNode::ReadFrom(reader);
@@ -2617,6 +2630,7 @@
void FunctionDeclaration::WriteTo(Writer* writer) {
TRACE_WRITE_OFFSET();
writer->WriteTag(kFunctionDeclaration);
+ writer->WritePosition(position_);
variable_->WriteToImpl(writer);
VariableScope<WriterHelper> parameters(writer->helper());
function_->WriteTo(writer);
@@ -2869,8 +2883,11 @@
TypeParameterScope<ReaderHelper> scope(reader->helper());
FunctionNode* function = new FunctionNode();
+ function->position_ = reader->ReadPosition();
+ function->end_position_ = reader->ReadPosition();
function->async_marker_ =
static_cast<FunctionNode::AsyncMarker>(reader->ReadByte());
+ function->debuggable_ = reader->ReadByte() == 1 ? true : false;
function->type_parameters().ReadFrom(reader);
function->required_parameter_count_ = reader->ReadUInt();
function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>(
@@ -2891,7 +2908,10 @@
TRACE_WRITE_OFFSET();
TypeParameterScope<WriterHelper> scope(writer->helper());
+ writer->WritePosition(position_);
+ writer->WritePosition(end_position_);
writer->WriteByte(static_cast<uint8_t>(async_marker_));
+ writer->WriteByte(debuggable_ ? 1 : 0);
type_parameters().WriteTo(writer);
writer->WriteUInt(required_parameter_count());
positional_parameters().WriteToStatic<VariableDeclarationImpl>(writer);
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc
index 5b76f17..8a23a7d 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -23,9 +23,9 @@
class SimpleExpressionConverter : public ExpressionVisitor {
public:
- SimpleExpressionConverter(Thread* thread, Zone* zone)
- : translation_helper_(thread, zone, NULL),
- zone_(zone),
+ explicit SimpleExpressionConverter(Thread* thread)
+ : translation_helper_(thread),
+ zone_(translation_helper_.zone()),
is_simple_(false),
simple_value_(NULL) {}
@@ -99,7 +99,7 @@
zone_(thread_->zone()),
isolate_(thread_->isolate()),
scripts_(Array::ZoneHandle(zone_)),
- translation_helper_(this, thread_, zone_, isolate_),
+ translation_helper_(this, thread_),
type_translator_(&translation_helper_,
&active_class_,
/*finalize=*/false) {
@@ -473,7 +473,7 @@
// Static fields with initializers either have the static value set to the
// initializer value if it is simple enough or else set to an uninitialized
// sentinel.
- SimpleExpressionConverter converter(H.thread(), Z);
+ SimpleExpressionConverter converter(H.thread());
if (converter.IsSimple(kernel_field->initializer())) {
// We do not need a getter.
field.SetStaticValue(converter.SimpleValue(), true);
diff --git a/runtime/vm/kernel_reader.h b/runtime/vm/kernel_reader.h
index a4c739d..a483d38 100644
--- a/runtime/vm/kernel_reader.h
+++ b/runtime/vm/kernel_reader.h
@@ -19,11 +19,8 @@
class BuildingTranslationHelper : public TranslationHelper {
public:
- BuildingTranslationHelper(KernelReader* reader,
- dart::Thread* thread,
- dart::Zone* zone,
- Isolate* isolate)
- : TranslationHelper(thread, zone, isolate), reader_(reader) {}
+ BuildingTranslationHelper(KernelReader* reader, dart::Thread* thread)
+ : TranslationHelper(thread), reader_(reader) {}
virtual ~BuildingTranslationHelper() {}
virtual RawLibrary* LookupLibraryByKernelLibrary(Library* library);
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index 98f83f8..9745cd3 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -1319,7 +1319,7 @@
if (setjmp(*jump.Set()) == 0) {
return EvaluateExpression(expression);
} else {
- Thread* thread = Thread::Current();
+ Thread* thread = H.thread();
Error& error = Error::Handle(Z);
error = thread->sticky_error();
thread->clear_sticky_error();
@@ -1770,6 +1770,28 @@
}
+void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) {
+ const size_t kLengthLen = strlen("length");
+
+ String* string = node->name()->string();
+ if (string->size() == kLengthLen &&
+ memcmp(string->buffer(), "length", kLengthLen) == 0) {
+ node->receiver()->AcceptExpressionVisitor(this);
+ if (result_.IsString()) {
+ const dart::String& str =
+ dart::String::Handle(Z, dart::String::RawCast(result_.raw()));
+ result_ = Integer::New(str.Length());
+ } else {
+ H.ReportError(
+ "Constant expressions can only call "
+ "'length' on string constants.");
+ }
+ } else {
+ VisitDefaultExpression(node);
+ }
+}
+
+
const TypeArguments* ConstantEvaluator::TranslateTypeArguments(
const Function& target,
dart::Class* target_klass,
@@ -1850,10 +1872,8 @@
InlineExitCollector* exit_collector,
intptr_t osr_id,
intptr_t first_block_id)
- : zone_(Thread::Current()->zone()),
- translation_helper_(Thread::Current(),
- zone_,
- Thread::Current()->isolate()),
+ : translation_helper_(Thread::Current()),
+ zone_(translation_helper_.zone()),
node_(node),
parsed_function_(parsed_function),
osr_id_(osr_id),
@@ -2048,6 +2068,14 @@
}
+Fragment FlowGraphBuilder::InstantiateType(const AbstractType& type) {
+ InstantiateTypeInstr* instr = new (Z) InstantiateTypeInstr(
+ TokenPosition::kNoSource, type, *active_class_.klass, Pop());
+ Push(instr);
+ return Fragment(instr);
+}
+
+
Fragment FlowGraphBuilder::InstantiateTypeArguments(
const TypeArguments& type_arguments) {
InstantiateTypeArgumentsInstr* instr = new (Z) InstantiateTypeArgumentsInstr(
@@ -2192,7 +2220,7 @@
CatchBlockEntryInstr* entry = new (Z) CatchBlockEntryInstr(
AllocateBlockId(), CurrentTryIndex(), graph_entry_, handler_types,
handler_index, *CurrentException(), *CurrentStackTrace(),
- /* needs_stacktrace = */ true, Thread::Current()->GetNextDeoptId(),
+ /* needs_stacktrace = */ true, H.thread()->GetNextDeoptId(),
should_restore_closure_context);
graph_entry_->AddCatchEntry(entry);
Fragment instructions(entry);
@@ -2562,11 +2590,9 @@
if (FLAG_use_field_guards) {
LocalVariable* store_expression = MakeTemporary();
instructions += LoadLocal(store_expression);
- instructions +=
- GuardFieldClass(field_clone, Thread::Current()->GetNextDeoptId());
+ instructions += GuardFieldClass(field_clone, H.thread()->GetNextDeoptId());
instructions += LoadLocal(store_expression);
- instructions +=
- GuardFieldLength(field_clone, Thread::Current()->GetNextDeoptId());
+ instructions += GuardFieldLength(field_clone, H.thread()->GetNextDeoptId());
}
instructions += StoreInstanceField(field_clone);
return instructions;
@@ -4208,7 +4234,14 @@
const AbstractType& type = T.TranslateType(node->type());
if (type.IsMalformed()) H.ReportError("Malformed type literal");
- fragment_ = Constant(type);
+ Fragment instructions;
+ if (type.IsInstantiated()) {
+ instructions += Constant(type);
+ } else {
+ instructions += LoadInstantiatorTypeArguments();
+ instructions += InstantiateType(type);
+ }
+ fragment_ = instructions;
}
@@ -4253,12 +4286,7 @@
fragment_ = StaticCall(node->position(), target, 0);
} else if (procedure->kind() == Procedure::kMethod) {
ASSERT(procedure->IsStatic());
- Function& closure_function =
- Function::ZoneHandle(Z, target.ImplicitClosureFunction());
- closure_function.set_kernel_function(target.kernel_function());
- const Instance& closure =
- Instance::ZoneHandle(Z, closure_function.ImplicitStaticClosure());
- fragment_ = Constant(closure);
+ fragment_ = Constant(constant_evaluator_.EvaluateExpression(node));
} else {
UNIMPLEMENTED();
}
@@ -4548,26 +4576,21 @@
const TypeArguments& type_arguments = T.TranslateInstantiatedTypeArguments(
klass, kernel_type_arguments.raw_array(),
kernel_type_arguments.length());
+ if (!klass.IsGeneric()) {
+ Type& type = Type::ZoneHandle(Z, T.ReceiverType(klass).raw());
- if (type_arguments.IsNull() || type_arguments.IsInstantiated()) {
- instructions += TranslateInstantiatedTypeArguments(type_arguments);
+ // TODO(27590): Can we move this code into [ReceiverType]?
+ type ^= ClassFinalizer::FinalizeType(*active_class_.klass, type,
+ ClassFinalizer::kFinalize);
+ ASSERT(!type.IsMalformedOrMalbounded());
+
+ TypeArguments& canonicalized_type_arguments =
+ TypeArguments::ZoneHandle(Z, type.arguments());
+ canonicalized_type_arguments =
+ canonicalized_type_arguments.Canonicalize();
+ instructions += Constant(canonicalized_type_arguments);
} else {
- if (!klass.IsGeneric()) {
- Type& type = Type::ZoneHandle(Z, T.ReceiverType(klass).raw());
-
- // TODO(27590): Can we move this code into [ReceiverType]?
- type ^= ClassFinalizer::FinalizeType(*active_class_.klass, type,
- ClassFinalizer::kFinalize);
- ASSERT(!type.IsMalformedOrMalbounded());
-
- TypeArguments& canonicalized_type_arguments =
- TypeArguments::ZoneHandle(Z, type.arguments());
- canonicalized_type_arguments =
- canonicalized_type_arguments.Canonicalize();
- instructions += Constant(canonicalized_type_arguments);
- } else {
- instructions += TranslateInstantiatedTypeArguments(type_arguments);
- }
+ instructions += TranslateInstantiatedTypeArguments(type_arguments);
}
instructions += PushArgument();
@@ -4692,12 +4715,13 @@
then_fragment += TranslateExpression(node->then());
then_fragment += StoreLocal(parsed_function_->expression_temp_var());
then_fragment += Drop();
-
ASSERT(stack_ == top);
+
Fragment otherwise_fragment(otherwise_entry);
otherwise_fragment += TranslateExpression(node->otherwise());
otherwise_fragment += StoreLocal(parsed_function_->expression_temp_var());
otherwise_fragment += Drop();
+ ASSERT(stack_ == top);
JoinEntryInstr* join = BuildJoinEntry();
then_fragment += Goto(join);
@@ -4910,13 +4934,6 @@
}
-void FlowGraphBuilder::VisitBlockExpression(BlockExpression* node) {
- Fragment instructions = TranslateStatement(node->body());
- instructions += TranslateExpression(node->value());
- fragment_ = instructions;
-}
-
-
Fragment FlowGraphBuilder::TranslateArguments(Arguments* node,
Array* argument_names) {
Fragment instructions;
diff --git a/runtime/vm/kernel_to_il.h b/runtime/vm/kernel_to_il.h
index b3cc174..9a7a71a 100644
--- a/runtime/vm/kernel_to_il.h
+++ b/runtime/vm/kernel_to_il.h
@@ -188,12 +188,12 @@
class TranslationHelper {
public:
- TranslationHelper(dart::Thread* thread, dart::Zone* zone, Isolate* isolate)
+ explicit TranslationHelper(dart::Thread* thread)
: thread_(thread),
- zone_(zone),
- isolate_(isolate),
- allocation_space_(thread_->IsMutatorThread() ? Heap::kNew
- : Heap::kOld) {}
+ zone_(thread->zone()),
+ isolate_(thread->isolate()),
+ allocation_space_(thread->IsMutatorThread() ? Heap::kNew : Heap::kOld) {
+ }
virtual ~TranslationHelper() {}
Thread* thread() { return thread_; }
@@ -414,6 +414,7 @@
virtual void VisitConditionalExpression(ConditionalExpression* node);
virtual void VisitLogicalExpression(LogicalExpression* node);
virtual void VisitNot(Not* node);
+ virtual void VisitPropertyGet(PropertyGet* node);
private:
// This will translate type arguments form [kernel_arguments]. If no type
@@ -519,8 +520,8 @@
: result_(NULL),
parsed_function_(parsed_function),
node_(node),
- zone_(Thread::Current()->zone()),
- translation_helper_(Thread::Current(), zone_, Isolate::Current()),
+ translation_helper_(Thread::Current()),
+ zone_(translation_helper_.zone()),
type_translator_(&translation_helper_,
&active_class_,
/*finalize=*/true),
@@ -615,8 +616,8 @@
ActiveClass active_class_;
- Zone* zone_;
TranslationHelper translation_helper_;
+ Zone* zone_;
DartTypeTranslator type_translator_;
FunctionNode* current_function_node_;
@@ -628,7 +629,7 @@
};
-class FlowGraphBuilder : public TreeVisitor {
+class FlowGraphBuilder : public ExpressionVisitor, public StatementVisitor {
public:
FlowGraphBuilder(TreeNode* node,
ParsedFunction* parsed_function,
@@ -640,7 +641,8 @@
FlowGraph* BuildGraph();
- virtual void VisitDefaultTreeNode(TreeNode* node) { UNREACHABLE(); }
+ virtual void VisitDefaultExpression(Expression* node) { UNREACHABLE(); }
+ virtual void VisitDefaultStatement(Statement* node) { UNREACHABLE(); }
virtual void VisitInvalidExpression(InvalidExpression* node);
virtual void VisitNullLiteral(NullLiteral* node);
@@ -676,7 +678,6 @@
virtual void VisitLet(Let* node);
virtual void VisitThrow(Throw* node);
virtual void VisitRethrow(Rethrow* node);
- virtual void VisitBlockExpression(BlockExpression* node);
virtual void VisitInvalidStatement(InvalidStatement* node);
virtual void VisitEmptyStatement(EmptyStatement* node);
@@ -744,6 +745,7 @@
Fragment PopContext();
Fragment LoadInstantiatorTypeArguments();
+ Fragment InstantiateType(const AbstractType& type);
Fragment InstantiateTypeArguments(const TypeArguments& type_arguments);
Fragment TranslateInstantiatedTypeArguments(
const TypeArguments& type_arguments);
@@ -854,8 +856,8 @@
void InlineBailout(const char* reason);
- Zone* zone_;
TranslationHelper translation_helper_;
+ Zone* zone_;
// The node we are currently compiling (e.g. FunctionNode, Constructor,
// Field)
diff --git a/runtime/vm/message_handler_test.cc b/runtime/vm/message_handler_test.cc
index fedb823..0e636d7 100644
--- a/runtime/vm/message_handler_test.cc
+++ b/runtime/vm/message_handler_test.cc
@@ -405,6 +405,7 @@
handler_peer.decrement_live_ports();
EXPECT(!handler.HasLivePorts());
PortMap::ClosePorts(&handler);
+ delete[] ports;
}
} // namespace dart
diff --git a/runtime/vm/native_api_impl.cc b/runtime/vm/native_api_impl.cc
index 08a8daa..4729375 100644
--- a/runtime/vm/native_api_impl.cc
+++ b/runtime/vm/native_api_impl.cc
@@ -16,7 +16,9 @@
// --- Message sending/receiving from native code ---
-static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
+static uint8_t* malloc_allocator(uint8_t* ptr,
+ intptr_t old_size,
+ intptr_t new_size) {
void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
return reinterpret_cast<uint8_t*>(new_ptr);
}
@@ -47,10 +49,13 @@
static bool PostCObjectHelper(Dart_Port port_id, Dart_CObject* message) {
uint8_t* buffer = NULL;
- ApiMessageWriter writer(&buffer, allocator);
+ ApiMessageWriter writer(&buffer, malloc_allocator);
bool success = writer.WriteCMessage(message);
- if (!success) return success;
+ if (!success) {
+ free(buffer);
+ return success;
+ }
// Post the message at the given port.
return PortMap::PostMessage(new Message(
diff --git a/runtime/vm/parser_test.cc b/runtime/vm/parser_test.cc
index ece6a9a..a4f3ce2 100644
--- a/runtime/vm/parser_test.cc
+++ b/runtime/vm/parser_test.cc
@@ -179,7 +179,7 @@
#ifndef PRODUCT
-static const char* saved_vars = NULL;
+static char* saved_vars = NULL;
static char* SkipIndex(const char* input) {
@@ -218,7 +218,7 @@
DebuggerStackTrace* stack = Isolate::Current()->debugger()->StackTrace();
intptr_t num_frames = stack->Length();
const int kBufferLen = 2048;
- char* buffer = new char[kBufferLen];
+ char* buffer = reinterpret_cast<char*>(malloc(kBufferLen));
char* pos = buffer;
LocalVarDescriptors& var_desc = LocalVarDescriptors::Handle();
for (intptr_t i = 0; i < num_frames; i++) {
@@ -233,15 +233,16 @@
delete[] var_str;
}
pos[0] = '\0';
+ if (saved_vars != NULL) {
+ free(saved_vars);
+ }
saved_vars = buffer;
}
// Uses the debugger to pause the program and capture the variable
// descriptors for all frames on the stack.
-static const char* CaptureVarsAtLine(Dart_Handle lib,
- const char* entry,
- int line) {
+static char* CaptureVarsAtLine(Dart_Handle lib, const char* entry, int line) {
EXPECT(ClassFinalizer::ProcessPendingClasses());
bool saved_flag = FLAG_show_invisible_frames;
FLAG_show_invisible_frames = true;
@@ -249,7 +250,7 @@
EXPECT_VALID(Dart_SetBreakpoint(NewString(TestCase::url()), line));
saved_vars = NULL;
EXPECT_VALID(Dart_Invoke(lib, NewString(entry), 0, NULL));
- const char* tmp = saved_vars;
+ char* tmp = saved_vars;
saved_vars = NULL;
FLAG_show_invisible_frames = saved_flag;
return tmp;
@@ -267,6 +268,7 @@
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
+ char* vars = CaptureVarsAtLine(lib, "main", 4);
EXPECT_STREQ(
// function f uses one ctx var at (0); doesn't save ctx.
"main.f\n"
@@ -288,7 +290,8 @@
" 1 ContextLevel level=1 scope=2 begin=4 end=37\n"
" 2 ContextVar level=1 begin=10 end=37 name=value\n"
" 3 StackVar scope=2 begin=12 end=37 name=f\n",
- CaptureVarsAtLine(lib, "main", 4));
+ vars);
+ free(vars);
}
@@ -306,6 +309,7 @@
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
+ char* vars = CaptureVarsAtLine(lib, "a", 5);
EXPECT_STREQ(
// Innermost function uses captured variable 'value' from middle
// function.
@@ -343,7 +347,8 @@
" 0 CurrentCtx scope=0 begin=0 end=0"
" name=:current_context_var\n"
" 1 StackVar scope=2 begin=6 end=46 name=b\n",
- CaptureVarsAtLine(lib, "a", 5));
+ vars);
+ free(vars);
}
@@ -366,6 +371,7 @@
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
+ char* vars = CaptureVarsAtLine(lib, "a", 7);
EXPECT_STREQ(
// bb captures only value2 from aa. No others.
"a.b.aa.bb\n"
@@ -415,7 +421,8 @@
" 1 ContextLevel level=1 scope=2 begin=4 end=70\n"
" 2 ContextVar level=1 begin=10 end=70 name=value1\n"
" 3 StackVar scope=2 begin=12 end=70 name=b\n",
- CaptureVarsAtLine(lib, "a", 7));
+ vars);
+ free(vars);
}
@@ -447,6 +454,7 @@
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
+ char* vars = CaptureVarsAtLine(lib, "doIt", 12);
EXPECT_STREQ(
// This frame saves the entry context instead of chaining. Good.
"doIt.<anonymous closure>\n"
@@ -471,7 +479,8 @@
" 0 CurrentCtx scope=0 begin=0 end=0"
" name=:current_context_var\n"
" 1 StackVar scope=2 begin=35 end=77 name=x\n",
- CaptureVarsAtLine(lib, "doIt", 12));
+ vars);
+ free(vars);
}
@@ -493,6 +502,7 @@
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
+ char* vars = CaptureVarsAtLine(lib, "outer", 5);
EXPECT_STREQ(
// inner function captures variable value. That's fine.
"outer.inner\n"
@@ -515,7 +525,8 @@
" 2 ContextLevel level=1 scope=4 begin=20 end=50\n"
" 3 ContextVar level=1 begin=28 end=50 name=value\n"
" 4 StackVar scope=4 begin=30 end=50 name=inner\n",
- CaptureVarsAtLine(lib, "outer", 5));
+ vars);
+ free(vars);
}
TEST_CASE(Parser_AllocateVariables_MiddleChain) {
@@ -537,6 +548,7 @@
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT_VALID(lib);
+ char* vars = CaptureVarsAtLine(lib, "a", 10);
EXPECT_STREQ(
"a.b.c\n"
" 0 ContextVar level=0 begin=50 end=62 name=x\n"
@@ -568,7 +580,8 @@
" 1 ContextLevel level=1 scope=2 begin=3 end=79\n"
" 2 ContextVar level=1 begin=9 end=79 name=x\n"
" 3 StackVar scope=2 begin=11 end=79 name=b\n",
- CaptureVarsAtLine(lib, "a", 10));
+ vars);
+ free(vars);
}
#endif // !PRODUCT
diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
index 0dd3b18..57381a3 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -245,6 +245,7 @@
if (!type.IsInstantiated()) return false;
if (type.IsFunctionType()) return false;
+ if (type.IsDartFunctionType()) return false;
Zone* zone = thread_->zone();
const TypeArguments& type_arguments =
@@ -271,6 +272,11 @@
Class& cls = Class::Handle(zone);
AbstractType& cls_type = AbstractType::Handle(zone);
for (intptr_t cid = kInstanceCid; cid < table->NumCids(); cid++) {
+ // Create local zone because deep hierarchies may allocate lots of handles
+ // within one iteration of this loop.
+ StackZone stack_zone(thread_);
+ HANDLESCOPE(thread_);
+
if (!table->HasValidClassAt(cid)) continue;
if (cid == kVoidCid) continue;
if (cid == kDynamicCid) continue;
@@ -281,7 +287,7 @@
if (cls.IsTopLevel()) continue;
cls_type = cls.RareType();
- if (cls_type.IsSubtypeOf(type, NULL, NULL, Heap::kOld)) {
+ if (cls_type.IsSubtypeOf(type, NULL, NULL, Heap::kNew)) {
last_matching_cid = cid;
if (*lower_limit == -1) {
// Found beginning of range.
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index f43b12e..7423157 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -702,6 +702,7 @@
friend class Object;
friend class RawInstance;
friend class RawInstructions;
+ friend class RawTypeArguments;
friend class SnapshotReader;
friend class InstanceSerializationCluster;
friend class CidRewriteVisitor;
@@ -1701,6 +1702,7 @@
int8_t type_state_;
friend class CidRewriteVisitor;
+ friend class RawTypeArguments;
};
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index 77f0576..95a71c1 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -504,7 +504,25 @@
// Write out the individual types.
intptr_t len = Smi::Value(ptr()->length_);
for (intptr_t i = 0; i < len; i++) {
- writer->WriteObjectImpl(ptr()->types()[i], kAsReference);
+ // The Dart VM reuses type argument lists across instances in order
+ // to reduce memory footprint, this can sometimes lead to a type from
+ // such a shared type argument list being sent over to another isolate.
+ // In such scenarios where it is not appropriate to send the types
+ // across (isolates spawned using spawnURI) we send them as dynamic.
+ if (!writer->can_send_any_object()) {
+ // Lookup the type class.
+ RawType* raw_type = Type::RawCast(ptr()->types()[i]);
+ RawSmi* raw_type_class_id = Smi::RawCast(raw_type->ptr()->type_class_id_);
+ RawClass* type_class =
+ writer->isolate()->class_table()->At(Smi::Value(raw_type_class_id));
+ if (!writer->AllowObjectsInDartLibrary(type_class->ptr()->library_)) {
+ writer->WriteVMIsolateObject(kDynamicType);
+ } else {
+ writer->WriteObjectImpl(ptr()->types()[i], kAsReference);
+ }
+ } else {
+ writer->WriteObjectImpl(ptr()->types()[i], kAsReference);
+ }
}
}
diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md
index d372c79..b9cdf81 100644
--- a/runtime/vm/service/service.md
+++ b/runtime/vm/service/service.md
@@ -697,7 +697,8 @@
```
Success resume(string isolateId,
- StepOption step [optional])
+ StepOption step [optional],
+ int frameIndex [optional])
```
The _resume_ RPC is used to resume execution of a paused isolate.
@@ -715,6 +716,12 @@
Out | Single step until the current function exits
Rewind | Immediately exit the top frame(s) without executing any code. Isolate will be paused at the call of the last exited function.
+The _frameIndex_ parameter is only used when the _step_ parameter is Rewind. It
+specifies the stack frame to rewind to. Stack frame 0 is the currently executing
+function, so _frameIndex_ must be at least 1.
+
+If the _frameIndex_ parameter is not provided, it defaults to 1.
+
See [Success](#success), [StepOption](#StepOption).
### setExceptionPauseMode
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index 13757ec..b073188 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -1137,7 +1137,7 @@
}
if (newobj.raw() != objref->raw()) {
ZoneGrowableArray<intptr_t>* patches = backref.patch_records();
- ASSERT(newobj.IsCanonical());
+ ASSERT(newobj.IsNull() || newobj.IsCanonical());
ASSERT(patches != NULL);
// First we replace the back ref table with the canonical object.
*objref = newobj.raw();
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
index 79b5b1b..fec51a0 100644
--- a/runtime/vm/snapshot_test.cc
+++ b/runtime/vm/snapshot_test.cc
@@ -139,6 +139,8 @@
// Check that the two messages are the same.
CompareDartCObjects(root, new_root);
+
+ free(buffer);
}
@@ -147,6 +149,7 @@
ApiMessageWriter writer(&buffer, &malloc_allocator);
const bool result = writer.WriteCMessage(root);
EXPECT_EQ(false, result);
+ free(buffer);
}
@@ -1653,6 +1656,7 @@
EXPECT(isolate == NULL);
EXPECT(error != NULL);
EXPECT_SUBSTRING("got 'script', expected 'core'", error);
+ free(error);
}
{
diff --git a/runtime/vm/timeline_test.cc b/runtime/vm/timeline_test.cc
index 2266898..aa2972f 100644
--- a/runtime/vm/timeline_test.cc
+++ b/runtime/vm/timeline_test.cc
@@ -91,7 +91,7 @@
event->Complete();
}
- static void Clear(TimelineEventEndlessRecorder* recorder) {
+ static void Clear(TimelineEventRecorder* recorder) {
ASSERT(recorder != NULL);
recorder->Clear();
}
@@ -343,6 +343,8 @@
EXPECT_EQ(0, recorder->CountFor(TimelineEvent::kAsyncEnd));
event->Complete();
EXPECT_EQ(1, recorder->CountFor(TimelineEvent::kAsyncEnd));
+
+ delete recorder;
}
@@ -466,6 +468,9 @@
EXPECT(LabelMatch(it.Next(), "F"));
EXPECT(!it.HasNext());
}
+
+ TimelineTestHelper::Clear(recorder);
+ delete recorder;
}
@@ -502,6 +507,9 @@
const char* alpha = strstr(js.ToCString(), "Alpha");
const char* beta = strstr(js.ToCString(), "Beta");
EXPECT(alpha < beta);
+
+ TimelineTestHelper::Clear(recorder);
+ delete recorder;
}
@@ -674,6 +682,8 @@
EXPECT_EQ(8, pauses.MaxExclusiveTime("a"));
}
TimelineTestHelper::Clear(recorder);
+
+ delete recorder;
}
@@ -884,6 +894,8 @@
EXPECT(pauses.has_error());
}
TimelineTestHelper::Clear(recorder);
+
+ delete recorder;
}
#endif // !PRODUCT
diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc
index c036981..ce50f4d 100644
--- a/runtime/vm/unit_test.cc
+++ b/runtime/vm/unit_test.cc
@@ -52,10 +52,9 @@
Dart_Isolate TestCase::CreateIsolate(const uint8_t* buffer, const char* name) {
- bin::IsolateData* isolate_data = new bin::IsolateData(name, NULL, NULL);
char* err;
Dart_Isolate isolate =
- Dart_CreateIsolate(name, NULL, buffer, NULL, isolate_data, &err);
+ Dart_CreateIsolate(name, NULL, buffer, NULL, NULL, &err);
if (isolate == NULL) {
OS::Print("Creation of isolate failed '%s'\n", err);
free(err);
diff --git a/sdk/lib/_blink/dartium/_blink_dartium.dart b/sdk/lib/_blink/dartium/_blink_dartium.dart
index bb80827..eb77a67 100644
--- a/sdk/lib/_blink/dartium/_blink_dartium.dart
+++ b/sdk/lib/_blink/dartium/_blink_dartium.dart
@@ -7,8 +7,10 @@
*/
library dart.dom._blink;
+import 'dart:async';
import 'dart:js' as js;
import 'dart:html' show DomException;
+import 'dart:_internal' as internal;
// This is a place to put custom renames if we need them.
final resolverMap = {
@@ -23275,6 +23277,15 @@
static register(document, tag, customType, extendsTagName) native "Utils_register";
+ // Below code sets up VMLibraryHooks for resolvePackageUri.
+ static Uri resolvePackageUri(Uri packageUri) native "Utils_resolvePackageUri";
+ static Future<Uri> _resolvePackageUriFuture(Uri packageUri) async {
+ return resolvePackageUri(packageUri);
+ }
+ static void _setupHooks() {
+ internal.VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
+ }
+
// Defines an interceptor if there is an appropriate JavaScript prototype to define it on.
// In any case, returns a typed JS wrapper compatibile with dart:html and the new
// typed JS Interop.
diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
index 3715679..ba537fd 100644
--- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
@@ -706,6 +706,9 @@
}
// Called from kernel generated code.
+_malformedTypeError(message) => new RuntimeError(message);
+
+// Called from kernel generated code.
_genericNoSuchMethod(receiver, memberName, positionalArguments, namedArguments,
existingArguments) {
return new NoSuchMethodError(
@@ -730,4 +733,67 @@
}
// Called from kernel generated code.
-_malformedTypeError(message) => new RuntimeError(message);
+_unresolvedStaticGetterError(receiver, memberName, positionalArguments,
+ namedArguments, existingArguments) {
+ // TODO(sra): Generate customized message.
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
+
+// Called from kernel generated code.
+_unresolvedStaticSetterError(receiver, memberName, positionalArguments,
+ namedArguments, existingArguments) {
+ // TODO(sra): Generate customized message.
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
+
+// Called from kernel generated code.
+_unresolvedStaticMethodError(receiver, memberName, positionalArguments,
+ namedArguments, existingArguments) {
+ // TODO(sra): Generate customized message.
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
+
+// Called from kernel generated code.
+_unresolvedTopLevelGetterError(receiver, memberName, positionalArguments,
+ namedArguments, existingArguments) {
+ // TODO(sra): Generate customized message.
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
+
+// Called from kernel generated code.
+_unresolvedTopLevelSetterError(receiver, memberName, positionalArguments,
+ namedArguments, existingArguments) {
+ // TODO(sra): Generate customized message.
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
+
+// Called from kernel generated code.
+_unresolvedTopLevelMethodError(receiver, memberName, positionalArguments,
+ namedArguments, existingArguments) {
+ // TODO(sra): Generate customized message.
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 3be1e9d..638a31c 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -3467,8 +3467,7 @@
* field that is currently being initialized.
*/
void throwCyclicInit(String staticName) {
- throw new CyclicInitializationError(
- "Cyclic initialization for static $staticName");
+ throw new CyclicInitializationError(staticName);
}
/**
diff --git a/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart b/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart
index b554437..7489b21 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart
@@ -4,63 +4,60 @@
library dart._js_mirrors;
-import 'dart:_js_embedded_names' show
- JsGetName,
- ALL_CLASSES,
- LAZIES,
- LIBRARIES,
- STATICS,
- TYPE_INFORMATION,
- TYPEDEF_PREDICATE_PROPERTY_NAME,
- TYPEDEF_TYPE_PROPERTY_NAME;
+import 'dart:_js_embedded_names'
+ show
+ JsGetName,
+ ALL_CLASSES,
+ LAZIES,
+ LIBRARIES,
+ STATICS,
+ TYPE_INFORMATION,
+ TYPEDEF_PREDICATE_PROPERTY_NAME,
+ TYPEDEF_TYPE_PROPERTY_NAME;
-import 'dart:collection' show
- UnmodifiableListView,
- UnmodifiableMapView;
+import 'dart:collection' show UnmodifiableListView, UnmodifiableMapView;
import 'dart:mirrors';
-import 'dart:_foreign_helper' show
- JS,
- JS_GET_FLAG,
- JS_GET_STATIC_STATE,
- JS_CURRENT_ISOLATE_CONTEXT,
- JS_EMBEDDED_GLOBAL,
- JS_GET_NAME;
-
+import 'dart:_foreign_helper'
+ show
+ JS,
+ JS_GET_FLAG,
+ JS_GET_STATIC_STATE,
+ JS_CURRENT_ISOLATE_CONTEXT,
+ JS_EMBEDDED_GLOBAL,
+ JS_GET_NAME;
import 'dart:_internal' as _symbol_dev;
-import 'dart:_js_helper' show
- BoundClosure,
- CachedInvocation,
- Closure,
- JSInvocationMirror,
- JsCache,
- Primitives,
- ReflectionInfo,
- RuntimeError,
- TearOffClosure,
- TypeVariable,
- UnimplementedNoSuchMethodError,
- createRuntimeType,
- createUnmangledInvocationMirror,
- getMangledTypeName,
- getMetadata,
- getType,
- getRuntimeType,
- isDartFunctionType,
- runtimeTypeToString,
- setRuntimeTypeInfo,
- throwInvalidReflectionError,
- TypeImpl,
- deferredLoadHook;
+import 'dart:_js_helper'
+ show
+ BoundClosure,
+ CachedInvocation,
+ Closure,
+ JSInvocationMirror,
+ JsCache,
+ Primitives,
+ ReflectionInfo,
+ RuntimeError,
+ TearOffClosure,
+ TypeVariable,
+ UnimplementedNoSuchMethodError,
+ createRuntimeType,
+ createUnmangledInvocationMirror,
+ getMangledTypeName,
+ getMetadata,
+ getType,
+ getRuntimeType,
+ isDartFunctionType,
+ runtimeTypeToString,
+ setRuntimeTypeInfo,
+ throwInvalidReflectionError,
+ TypeImpl,
+ deferredLoadHook;
-import 'dart:_interceptors' show
- Interceptor,
- JSArray,
- JSExtendableArray,
- getInterceptor;
+import 'dart:_interceptors'
+ show Interceptor, JSArray, JSExtendableArray, getInterceptor;
import 'dart:_js_names';
@@ -152,10 +149,11 @@
if (uriString != "") {
uri = Uri.parse(uriString);
} else {
- uri = new Uri(scheme: 'https',
- host: 'dartlang.org',
- path: 'dart2js-stripped-uri',
- queryParameters: { 'lib': name });
+ uri = new Uri(
+ scheme: 'https',
+ host: 'dartlang.org',
+ path: 'dart2js-stripped-uri',
+ queryParameters: {'lib': name});
}
List<String> classes = data[2];
List<String> functions = data[3];
@@ -164,12 +162,11 @@
bool isRoot = data[6];
var globalObject = data[7];
List metadata = (metadataFunction == null)
- ? const [] : JS('List', '#()', metadataFunction);
+ ? const []
+ : JS('List', '#()', metadataFunction);
var libraries = result.putIfAbsent(name, () => <LibraryMirror>[]);
- libraries.add(
- new JsLibraryMirror(
- s(name), uri, classes, functions, metadata, fields, isRoot,
- globalObject));
+ libraries.add(new JsLibraryMirror(s(name), uri, classes, functions,
+ metadata, fields, isRoot, globalObject));
}
return result;
}
@@ -217,8 +214,8 @@
bool get isCurrent => JS_CURRENT_ISOLATE_CONTEXT() == _isolateContext;
LibraryMirror get rootLibrary {
- return currentJsMirrorSystem.libraries.values.firstWhere(
- (JsLibraryMirror library) => library._isRoot);
+ return currentJsMirrorSystem.libraries.values
+ .firstWhere((JsLibraryMirror library) => library._isRoot);
}
}
@@ -255,8 +252,8 @@
final int _metadataIndex;
TypeMirror _cachedUpperBound;
- JsTypeVariableMirror(TypeVariable typeVariable, this.owner,
- this._metadataIndex)
+ JsTypeVariableMirror(
+ TypeVariable typeVariable, this.owner, this._metadataIndex)
: this._typeVariable = typeVariable,
super(s(typeVariable.name));
@@ -291,8 +288,7 @@
}
class JsTypeMirror extends JsDeclarationMirror implements TypeMirror {
- JsTypeMirror(Symbol simpleName)
- : super(simpleName);
+ JsTypeMirror(Symbol simpleName) : super(simpleName);
String get _prettyName => 'TypeMirror';
@@ -325,7 +321,8 @@
}
}
-class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
+class JsLibraryMirror extends JsDeclarationMirror
+ with JsObjectMirror
implements LibraryMirror {
final Uri _uri;
final List<String> _classes;
@@ -345,14 +342,15 @@
UnmodifiableMapView<Symbol, DeclarationMirror> _cachedDeclarations;
UnmodifiableListView<InstanceMirror> _cachedMetadata;
- JsLibraryMirror(Symbol simpleName,
- this._uri,
- this._classes,
- this._functions,
- this._metadata,
- this._compactFieldSpecification,
- this._isRoot,
- this._globalObject)
+ JsLibraryMirror(
+ Symbol simpleName,
+ this._uri,
+ this._classes,
+ this._functions,
+ this._metadata,
+ this._compactFieldSpecification,
+ this._isRoot,
+ this._globalObject)
: super(simpleName) {
preserveLibraryNames();
}
@@ -379,7 +377,7 @@
if (cls is JsClassMirror) {
result[cls.simpleName] = cls;
cls._owner = this;
- } else if (cls is JsTypedefMirror) {
+ } else if (cls is JsTypedefMirror) {
result[cls.simpleName] = cls;
}
}
@@ -414,9 +412,8 @@
return reflect(JS("", "#()", getter));
}
- InstanceMirror invoke(Symbol memberName,
- List positionalArguments,
- [Map<Symbol, dynamic> namedArguments]) {
+ InstanceMirror invoke(Symbol memberName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
if (namedArguments != null && !namedArguments.isEmpty) {
throw new UnsupportedError('Named arguments are not implemented.');
}
@@ -474,14 +471,13 @@
continue;
}
bool isConstructor = unmangledName.startsWith('new ');
- bool isStatic = !isConstructor; // Top-level functions are static, but
- // constructors are not.
+ // Top-level functions are static, but constructors are not.
+ bool isStatic = !isConstructor;
if (isConstructor) {
unmangledName = unmangledName.substring(4).replaceAll(r'$', '.');
}
- JsMethodMirror mirror =
- new JsMethodMirror.fromUnmangledName(
- unmangledName, jsFunction, isStatic, isConstructor);
+ JsMethodMirror mirror = new JsMethodMirror.fromUnmangledName(
+ unmangledName, jsFunction, isStatic, isConstructor);
result.add(mirror);
mirror._owner = this;
}
@@ -533,11 +529,12 @@
}
Map<Symbol, Mirror> get __members {
- if (_cachedMembers != null) return _cachedMembers;
+ if (_cachedMembers != null) return _cachedMembers;
Map<Symbol, Mirror> result = new Map.from(__classes);
addToResult(Symbol key, Mirror value) {
result[key] = value;
}
+
__functions.forEach(addToResult);
__getters.forEach(addToResult);
__setters.forEach(addToResult);
@@ -551,6 +548,7 @@
addToResult(Symbol key, Mirror value) {
result[key] = value;
}
+
__members.forEach(addToResult);
return _cachedDeclarations =
new UnmodifiableMapView<Symbol, DeclarationMirror>(result);
@@ -566,8 +564,8 @@
// TODO(ahe): Test this getter.
DeclarationMirror get owner => null;
- List<LibraryDependencyMirror> get libraryDependencies
- => throw new UnimplementedError();
+ List<LibraryDependencyMirror> get libraryDependencies =>
+ throw new UnimplementedError();
}
String n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol);
@@ -589,8 +587,19 @@
}
}
-TypeMirror reflectType(Type key) {
- return reflectClassByMangledName(getMangledTypeName(key));
+TypeMirror reflectType(Type key, [List<Type> typeArguments]) {
+ String mangledName = getMangledTypeName(key);
+ if (typeArguments != null) {
+ if (typeArguments.isEmpty || !typeArguments.every((_) => _ is TypeImpl)) {
+ var message = typeArguments.isEmpty
+ ? 'Type arguments list can not be empty.'
+ : 'Type arguments list must contain only instances of Type.';
+ throw new ArgumentError.value(typeArguments, 'typeArguments', message);
+ }
+ var mangledTypeArguments = typeArguments.map(getMangledTypeName);
+ mangledName = "${mangledName}<${mangledTypeArguments.join(', ')}>";
+ }
+ return reflectClassByMangledName(mangledName);
}
TypeMirror reflectClassByMangledName(String mangledName) {
@@ -612,11 +621,12 @@
if (typeArgIndex != -1) {
TypeMirror originalDeclaration =
reflectClassByMangledName(mangledName.substring(0, typeArgIndex))
- .originalDeclaration;
+ .originalDeclaration;
if (originalDeclaration is JsTypedefMirror) {
throw new UnimplementedError();
}
- mirror = new JsTypeBoundClassMirror(originalDeclaration,
+ mirror = new JsTypeBoundClassMirror(
+ originalDeclaration,
// Remove the angle brackets enclosing the type arguments.
mangledName.substring(typeArgIndex + 1, mangledName.length - 1));
JsCache.update(classMirrors, mangledName, mirror);
@@ -635,8 +645,8 @@
if (descriptor == null) {
// This is a native class, or an intercepted class.
// TODO(ahe): Preserve descriptor for such classes.
- } else if (JS('bool', '# in #',
- TYPEDEF_PREDICATE_PROPERTY_NAME, descriptor)) {
+ } else if (JS(
+ 'bool', '# in #', TYPEDEF_PREDICATE_PROPERTY_NAME, descriptor)) {
// Typedefs are represented as normal classes with two special properties:
// TYPEDEF_PREDICATE_PROPERTY_NAME and TYPEDEF_TYPE_PROPERTY_NAME.
// For example:
@@ -688,6 +698,43 @@
return mirror;
}
+/// Splits input `typeArguments` string into a list of strings for each argument.
+/// Takes into account nested generic types.
+/// For example, `Map<int, String>, String` will become a list of two items:
+/// `Map<int, String>` and `String`.
+List<String> splitTypeArguments(String typeArguments) {
+ if (typeArguments.indexOf('<') == -1) {
+ return typeArguments.split(',');
+ }
+ var argumentList = new List<String>();
+ int level = 0;
+ String currentTypeArgument = '';
+
+ for (int i = 0; i < typeArguments.length; i++) {
+ var character = typeArguments[i];
+ if (character == ' ') {
+ continue;
+ } else if (character == '<') {
+ currentTypeArgument += character;
+ level++;
+ } else if (character == '>') {
+ currentTypeArgument += character;
+ level--;
+ } else if (character == ',') {
+ if (level > 0) {
+ currentTypeArgument += character;
+ } else {
+ argumentList.add(currentTypeArgument);
+ currentTypeArgument = '';
+ }
+ } else {
+ currentTypeArgument += character;
+ }
+ }
+ argumentList.add(currentTypeArgument);
+ return argumentList;
+}
+
Map<Symbol, MethodMirror> filterMethods(List<MethodMirror> methods) {
var result = new Map();
for (JsMethodMirror method in methods) {
@@ -708,12 +755,11 @@
return result;
}
-Map<Symbol, MethodMirror> filterGetters(List<MethodMirror> methods,
- Map<Symbol, VariableMirror> fields) {
+Map<Symbol, MethodMirror> filterGetters(
+ List<MethodMirror> methods, Map<Symbol, VariableMirror> fields) {
var result = new Map();
for (JsMethodMirror method in methods) {
if (method.isGetter) {
-
// TODO(ahe): This is a hack to remove getters corresponding to a field.
if (fields[method.simpleName] != null) continue;
@@ -723,12 +769,11 @@
return result;
}
-Map<Symbol, MethodMirror> filterSetters(List<MethodMirror> methods,
- Map<Symbol, VariableMirror> fields) {
+Map<Symbol, MethodMirror> filterSetters(
+ List<MethodMirror> methods, Map<Symbol, VariableMirror> fields) {
var result = new Map();
for (JsMethodMirror method in methods) {
if (method.isSetter) {
-
// TODO(ahe): This is a hack to remove setters corresponding to a field.
String name = n(method.simpleName);
name = name.substring(0, name.length - 1); // Remove '='.
@@ -740,8 +785,8 @@
return result;
}
-Map<Symbol, Mirror> filterMembers(List<MethodMirror> methods,
- Map<Symbol, VariableMirror> variables) {
+Map<Symbol, Mirror> filterMembers(
+ List<MethodMirror> methods, Map<Symbol, VariableMirror> variables) {
Map<Symbol, Mirror> result = new Map.from(variables);
for (JsMethodMirror method in methods) {
if (method.isSetter) {
@@ -777,15 +822,16 @@
return superclass;
}
-class JsMixinApplication extends JsTypeMirror with JsObjectMirror
+class JsMixinApplication extends JsTypeMirror
+ with JsObjectMirror
implements ClassMirror {
final ClassMirror superclass;
final ClassMirror mixin;
Symbol _cachedSimpleName;
Map<Symbol, MethodMirror> _cachedInstanceMembers;
- JsMixinApplication(ClassMirror superclass, ClassMirror mixin,
- String mangledName)
+ JsMixinApplication(
+ ClassMirror superclass, ClassMirror mixin, String mangledName)
: this.superclass = superclass,
this.mixin = mixin,
super(s(mangledName));
@@ -833,10 +879,8 @@
_asRuntimeType() => null;
- InstanceMirror invoke(
- Symbol memberName,
- List positionalArguments,
- [Map<Symbol,dynamic> namedArguments]) {
+ InstanceMirror invoke(Symbol memberName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
throw new NoSuchStaticMethodError.method(
null, memberName, positionalArguments, namedArguments);
}
@@ -858,10 +902,8 @@
Map<Symbol, MethodMirror> get __constructors => _mixin.__constructors;
- InstanceMirror newInstance(
- Symbol constructorName,
- List positionalArguments,
- [Map<Symbol,dynamic> namedArguments]) {
+ InstanceMirror newInstance(Symbol constructorName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
throw new UnsupportedError(
"Can't instantiate mixin application '${n(qualifiedName)}'");
}
@@ -890,8 +932,7 @@
bool isAssignableTo(TypeMirror other) => throw new UnimplementedError();
}
-abstract class JsObjectMirror implements ObjectMirror {
-}
+abstract class JsObjectMirror implements ObjectMirror {}
class JsInstanceMirror extends JsObjectMirror implements InstanceMirror {
final reflectee;
@@ -907,19 +948,17 @@
return reflectType(getRuntimeType(reflectee));
}
- InstanceMirror invoke(Symbol memberName,
- List positionalArguments,
- [Map<Symbol,dynamic> namedArguments]) {
+ InstanceMirror invoke(Symbol memberName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
if (namedArguments == null) namedArguments = const {};
// We can safely pass positionalArguments to _invoke as it will wrap it in
// a JSArray if needed.
- return _invoke(memberName, JSInvocationMirror.METHOD,
- positionalArguments, namedArguments);
+ return _invoke(memberName, JSInvocationMirror.METHOD, positionalArguments,
+ namedArguments);
}
- InstanceMirror _invokeMethodWithNamedArguments(
- String reflectiveName,
- List positionalArguments, Map<Symbol,dynamic> namedArguments) {
+ InstanceMirror _invokeMethodWithNamedArguments(String reflectiveName,
+ List positionalArguments, Map<Symbol, dynamic> namedArguments) {
assert(namedArguments.isNotEmpty);
var interceptor = getInterceptor(reflectee);
@@ -983,12 +1022,13 @@
}
String _computeReflectiveName(Symbol symbolName, int type,
- List positionalArguments,
- Map<Symbol, dynamic> namedArguments) {
+ List positionalArguments, Map<Symbol, dynamic> namedArguments) {
String name = n(symbolName);
switch (type) {
- case JSInvocationMirror.GETTER: return name;
- case JSInvocationMirror.SETTER: return '$name=';
+ case JSInvocationMirror.GETTER:
+ return name;
+ case JSInvocationMirror.SETTER:
+ return '$name=';
case JSInvocationMirror.METHOD:
if (namedArguments.isNotEmpty) return '$name*';
int nbArgs = positionalArguments.length as int;
@@ -1004,8 +1044,7 @@
* Caches the result.
*/
_getCachedInvocation(Symbol name, int type, String reflectiveName,
- List positionalArguments, Map<Symbol,dynamic> namedArguments) {
-
+ List positionalArguments, Map<Symbol, dynamic> namedArguments) {
var cache = _classInvocationCache;
var cacheEntry = JsCache.fetch(cache, reflectiveName);
var result;
@@ -1037,10 +1076,8 @@
/// Invoke the member specified through name and type on the reflectee.
/// As a side-effect, this populates the class-specific invocation cache
/// for the reflectee.
- InstanceMirror _invoke(Symbol name,
- int type,
- List positionalArguments,
- Map<Symbol,dynamic> namedArguments) {
+ InstanceMirror _invoke(Symbol name, int type, List positionalArguments,
+ Map<Symbol, dynamic> namedArguments) {
String reflectiveName =
_computeReflectiveName(name, type, positionalArguments, namedArguments);
@@ -1055,8 +1092,8 @@
if (cacheEntry.isNoSuchMethod || !_isReflectable(cacheEntry)) {
// Could be that we want to invoke a getter, or get a method.
if (type == JSInvocationMirror.METHOD && _instanceFieldExists(name)) {
- return getField(name).invoke(
- #call, positionalArguments, namedArguments);
+ return getField(name)
+ .invoke(#call, positionalArguments, namedArguments);
}
if (type == JSInvocationMirror.SETTER) {
@@ -1086,15 +1123,11 @@
}
// JS helpers for getField optimizations.
- static bool isUndefined(x)
- => JS('bool', 'typeof # == "undefined"', x);
- static bool isMissingCache(x)
- => JS('bool', 'typeof # == "number"', x);
- static bool isMissingProbe(Symbol symbol)
- => JS('bool', 'typeof #.\$p == "undefined"', symbol);
- static bool isEvalAllowed()
- => !JS_GET_FLAG("USE_CONTENT_SECURITY_POLICY");
-
+ static bool isUndefined(x) => JS('bool', 'typeof # == "undefined"', x);
+ static bool isMissingCache(x) => JS('bool', 'typeof # == "number"', x);
+ static bool isMissingProbe(Symbol symbol) =>
+ JS('bool', 'typeof #.\$p == "undefined"', symbol);
+ static bool isEvalAllowed() => !JS_GET_FLAG("USE_CONTENT_SECURITY_POLICY");
/// The getter cache is lazily allocated after a couple
/// of invocations of [InstanceMirror.getField]. The delay is
@@ -1113,13 +1146,14 @@
int getterType = JSInvocationMirror.GETTER;
String getterName =
_computeReflectiveName(name, getterType, const [], const {});
- var getterCacheEntry = _getCachedInvocation(
- name, getterType, getterName, const [], const {});
+ var getterCacheEntry =
+ _getCachedInvocation(name, getterType, getterName, const [], const {});
return !getterCacheEntry.isNoSuchMethod && !getterCacheEntry.isGetterStub;
}
InstanceMirror getField(Symbol fieldName) {
- FASTPATH: {
+ FASTPATH:
+ {
var cache = _getterCache;
if (isMissingCache(cache) || isMissingProbe(fieldName)) break FASTPATH;
// If the [fieldName] has an associated probe function, we can use
@@ -1207,8 +1241,8 @@
return JS('', 'new Function("o", #)', body);
}
- _newGetterNoEvalFn(n) => JS('',
- '(function(n){return(function(o){return o[n]()})})(#)', n);
+ _newGetterNoEvalFn(n) =>
+ JS('', '(function(n){return(function(o){return o[n]()})})(#)', n);
_newInterceptedGetterFn(String name, bool useEval) {
var object = reflectee;
@@ -1219,22 +1253,20 @@
if (!useEval) return _newInterceptGetterNoEvalFn(name, interceptor);
String className = JS('String', '#.constructor.name', interceptor);
String functionName = '$className\$$name';
- String body =
- ' function $functionName(o){return i.$name(o)}'
+ String body = ' function $functionName(o){return i.$name(o)}'
' return $functionName;';
return JS('', '(new Function("i", #))(#)', body, interceptor);
}
- _newInterceptGetterNoEvalFn(n, i) => JS('',
- '(function(n,i){return(function(o){return i[n](o)})})(#,#)', n, i);
+ _newInterceptGetterNoEvalFn(n, i) =>
+ JS('', '(function(n,i){return(function(o){return i[n](o)})})(#,#)', n, i);
delegate(Invocation invocation) {
return JSInvocationMirror.invokeFromMirror(invocation, reflectee);
}
operator ==(other) {
- return other is JsInstanceMirror &&
- identical(reflectee, other.reflectee);
+ return other is JsInstanceMirror && identical(reflectee, other.reflectee);
}
int get hashCode {
@@ -1332,54 +1364,25 @@
}
}
- if (_typeArguments.indexOf('<') == -1) {
- _typeArguments.split(',').forEach((t) => addTypeArgument(t));
- } else {
- int level = 0;
- String currentTypeArgument = '';
-
- for (int i = 0; i < _typeArguments.length; i++) {
- var character = _typeArguments[i];
- if (character == ' ') {
- continue;
- } else if (character == '<') {
- currentTypeArgument += character;
- level++;
- } else if (character == '>') {
- currentTypeArgument += character;
- level--;
- } else if (character == ',') {
- if (level > 0) {
- currentTypeArgument += character;
- } else {
- addTypeArgument(currentTypeArgument);
- currentTypeArgument = '';
- }
- } else {
- currentTypeArgument += character;
- }
- }
- addTypeArgument(currentTypeArgument);
- }
+ splitTypeArguments(_typeArguments).forEach(addTypeArgument);
return _cachedTypeArguments = new UnmodifiableListView(result);
}
List<JsMethodMirror> get _methods {
if (_cachedMethods != null) return _cachedMethods;
- return _cachedMethods =_class._getMethodsWithOwner(this);
+ return _cachedMethods = _class._getMethodsWithOwner(this);
}
Map<Symbol, MethodMirror> get __methods {
if (_cachedMethodsMap != null) return _cachedMethodsMap;
- return _cachedMethodsMap = new UnmodifiableMapView<Symbol, MethodMirror>(
- filterMethods(_methods));
+ return _cachedMethodsMap =
+ new UnmodifiableMapView<Symbol, MethodMirror>(filterMethods(_methods));
}
Map<Symbol, MethodMirror> get __constructors {
if (_cachedConstructors != null) return _cachedConstructors;
- return _cachedConstructors =
- new UnmodifiableMapView<Symbol, MethodMirror>(
- filterConstructors(_methods));
+ return _cachedConstructors = new UnmodifiableMapView<Symbol, MethodMirror>(
+ filterConstructors(_methods));
}
Map<Symbol, MethodMirror> get __getters {
@@ -1397,7 +1400,7 @@
Map<Symbol, VariableMirror> get __variables {
if (_cachedVariables != null) return _cachedVariables;
var result = new Map();
- for (JsVariableMirror mirror in _class._getFieldsWithOwner(this)) {
+ for (JsVariableMirror mirror in _class._getFieldsWithOwner(this)) {
result[mirror.simpleName] = mirror;
}
return _cachedVariables =
@@ -1451,8 +1454,10 @@
result.addAll(superclass.instanceMembers);
}
declarations.values.forEach((decl) {
- if (decl is MethodMirror && !decl.isStatic &&
- !decl.isConstructor && !decl.isAbstract) {
+ if (decl is MethodMirror &&
+ !decl.isStatic &&
+ !decl.isConstructor &&
+ !decl.isAbstract) {
result[decl.simpleName] = decl;
}
if (decl is VariableMirror && !decl.isStatic) {
@@ -1477,19 +1482,17 @@
InstanceMirror getField(Symbol fieldName) => _class.getField(fieldName);
- InstanceMirror newInstance(Symbol constructorName,
- List positionalArguments,
- [Map<Symbol, dynamic> namedArguments]) {
- var instance = _class._getInvokedInstance(constructorName,
- positionalArguments,
- namedArguments);
+ InstanceMirror newInstance(Symbol constructorName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
+ var instance = _class._getInvokedInstance(
+ constructorName, positionalArguments, namedArguments);
return reflect(setRuntimeTypeInfo(
instance, typeArguments.map((t) => t._asRuntimeType()).toList()));
}
_asRuntimeType() {
- return [_class._jsConstructor].addAll(
- typeArguments.map((t) => t._asRuntimeType()));
+ return [_class._jsConstructor]
+ .addAll(typeArguments.map((t) => t._asRuntimeType()));
}
JsLibraryMirror get owner => _class.owner;
@@ -1507,9 +1510,8 @@
return _superclass = typeMirrorFromRuntimeTypeRepresentation(this, type);
}
- InstanceMirror invoke(Symbol memberName,
- List positionalArguments,
- [Map<Symbol,dynamic> namedArguments]) {
+ InstanceMirror invoke(Symbol memberName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
return _class.invoke(memberName, positionalArguments, namedArguments);
}
@@ -1562,14 +1564,12 @@
final bool isGetter;
final bool isStatic;
final bool isTopLevel;
- final _target; /// The field or type that introduces the synthetic accessor.
- JsSyntheticAccessor(this.owner,
- this.simpleName,
- this.isGetter,
- this.isStatic,
- this.isTopLevel,
- this._target);
+ /// The field or type that introduces the synthetic accessor.
+ final _target;
+
+ JsSyntheticAccessor(this.owner, this.simpleName, this.isGetter, this.isStatic,
+ this.isTopLevel, this._target);
bool get isSynthetic => true;
bool get isRegularMethod => false;
@@ -1622,7 +1622,8 @@
SourceLocation get location => throw new UnimplementedError();
}
-class JsClassMirror extends JsTypeMirror with JsObjectMirror
+class JsClassMirror extends JsTypeMirror
+ with JsObjectMirror
implements ClassMirror {
final String _mangledName;
final _jsConstructor;
@@ -1649,26 +1650,22 @@
// Set as side-effect of accessing JsLibraryMirror.classes.
JsLibraryMirror _owner;
- JsClassMirror(Symbol simpleName,
- this._mangledName,
- this._jsConstructor,
- this._fieldsDescriptor,
- this._fieldsMetadata)
+ JsClassMirror(Symbol simpleName, this._mangledName, this._jsConstructor,
+ this._fieldsDescriptor, this._fieldsMetadata)
: super(simpleName);
String get _prettyName => 'ClassMirror';
Map<Symbol, MethodMirror> get __constructors {
if (_cachedConstructors != null) return _cachedConstructors;
- return _cachedConstructors =
- new UnmodifiableMapView<Symbol, MethodMirror>(
- filterConstructors(_methods));
+ return _cachedConstructors = new UnmodifiableMapView<Symbol, MethodMirror>(
+ filterConstructors(_methods));
}
_asRuntimeType() {
- if (typeVariables.isEmpty) return _jsConstructor;
+ if (typeVariables.isEmpty) return _jsConstructor;
var type = [_jsConstructor];
- for (int i = 0; i < typeVariables.length; i ++) {
+ for (int i = 0; i < typeVariables.length; i++) {
type.add(JsMirrorSystem._dynamicType._asRuntimeType);
}
return type;
@@ -1678,7 +1675,7 @@
var prototype = JS('', '#.prototype', _jsConstructor);
// The prototype might not have been processed yet, so do that now.
JS('', '#[#]()', prototype,
- JS_GET_NAME(JsGetName.DEFERRED_ACTION_PROPERTY));
+ JS_GET_NAME(JsGetName.DEFERRED_ACTION_PROPERTY));
List<String> keys = extractKeys(prototype);
var result = <JsMethodMirror>[];
for (String key in keys) {
@@ -1692,9 +1689,8 @@
var function = JS('', '#[#]', prototype, key);
if (!isOrdinaryReflectableMethod(function)) continue;
if (isAliasedSuperMethod(function, key)) continue;
- var mirror =
- new JsMethodMirror.fromUnmangledName(
- simpleName, function, false, false);
+ var mirror = new JsMethodMirror.fromUnmangledName(
+ simpleName, function, false, false);
result.add(mirror);
mirror._owner = methodOwner;
}
@@ -1720,9 +1716,8 @@
continue;
}
bool isStatic = !isConstructor; // Constructors are not static.
- JsMethodMirror mirror =
- new JsMethodMirror.fromUnmangledName(
- unmangledName, jsFunction, isStatic, isConstructor);
+ JsMethodMirror mirror = new JsMethodMirror.fromUnmangledName(
+ unmangledName, jsFunction, isStatic, isConstructor);
result.add(mirror);
mirror._owner = methodOwner;
}
@@ -1740,8 +1735,8 @@
var instanceFieldSpecfication = _fieldsDescriptor.split(';')[1];
if (_fieldsMetadata != null) {
- instanceFieldSpecfication =
- [instanceFieldSpecfication]..addAll(_fieldsMetadata);
+ instanceFieldSpecfication = [instanceFieldSpecfication]
+ ..addAll(_fieldsMetadata);
}
parseCompactFieldSpecification(
fieldOwner, instanceFieldSpecfication, false, result);
@@ -1751,10 +1746,10 @@
if (staticDescriptor != null) {
parseCompactFieldSpecification(
fieldOwner,
- JS('', '#[#]',
- staticDescriptor,
+ JS('', '#[#]', staticDescriptor,
JS_GET_NAME(JsGetName.CLASS_DESCRIPTOR_PROPERTY)),
- true, result);
+ true,
+ result);
}
return result;
}
@@ -1804,6 +1799,7 @@
addToResult(Symbol key, Mirror value) {
result[key] = value;
}
+
__members.forEach(addToResult);
__constructors.forEach(addToResult);
typeVariables.forEach((tv) => result[tv.simpleName] = tv);
@@ -1841,8 +1837,10 @@
result.addAll(superclass.instanceMembers);
}
declarations.values.forEach((decl) {
- if (decl is MethodMirror && !decl.isStatic &&
- !decl.isConstructor && !decl.isAbstract) {
+ if (decl is MethodMirror &&
+ !decl.isStatic &&
+ !decl.isConstructor &&
+ !decl.isAbstract) {
result[decl.simpleName] = decl;
}
if (decl is VariableMirror && !decl.isStatic) {
@@ -1926,32 +1924,28 @@
throw new NoSuchStaticMethodError.method(null, fieldName, null, null);
}
- _getInvokedInstance(Symbol constructorName,
- List positionalArguments,
- [Map<Symbol, dynamic> namedArguments]) {
- if (namedArguments != null && !namedArguments.isEmpty) {
- throw new UnsupportedError('Named arguments are not implemented.');
- }
- JsMethodMirror mirror =
- JsCache.fetch(_jsConstructorCache, n(constructorName));
- if (mirror == null) {
- mirror = __constructors.values.firstWhere(
- (m) => m.constructorName == constructorName,
- orElse: () {
- throw new NoSuchStaticMethodError.method(
- null, constructorName, positionalArguments, namedArguments);
- });
- JsCache.update(_jsConstructorCache, n(constructorName), mirror);
- }
- return mirror._invoke(positionalArguments, namedArguments);
- }
+ _getInvokedInstance(Symbol constructorName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
+ if (namedArguments != null && !namedArguments.isEmpty) {
+ throw new UnsupportedError('Named arguments are not implemented.');
+ }
+ JsMethodMirror mirror =
+ JsCache.fetch(_jsConstructorCache, n(constructorName));
+ if (mirror == null) {
+ mirror = __constructors.values
+ .firstWhere((m) => m.constructorName == constructorName, orElse: () {
+ throw new NoSuchStaticMethodError.method(
+ null, constructorName, positionalArguments, namedArguments);
+ });
+ JsCache.update(_jsConstructorCache, n(constructorName), mirror);
+ }
+ return mirror._invoke(positionalArguments, namedArguments);
+ }
- InstanceMirror newInstance(Symbol constructorName,
- List positionalArguments,
- [Map<Symbol, dynamic> namedArguments]) {
- return reflect(_getInvokedInstance(constructorName,
- positionalArguments,
- namedArguments));
+ InstanceMirror newInstance(Symbol constructorName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
+ return reflect(_getInvokedInstance(
+ constructorName, positionalArguments, namedArguments));
}
JsLibraryMirror get owner {
@@ -2001,16 +1995,16 @@
// Use _superclass == this to represent class with no superclass
// (Object).
_superclass = (superclassName == '')
- ? this : reflectClassByMangledName(superclassName);
- }
+ ? this
+ : reflectClassByMangledName(superclassName);
}
}
+ }
return _superclass == this ? null : _superclass;
}
- InstanceMirror invoke(Symbol memberName,
- List positionalArguments,
- [Map<Symbol,dynamic> namedArguments]) {
+ InstanceMirror invoke(Symbol memberName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
// Mirror API gotcha: Calling [invoke] on a ClassMirror means invoke a
// static method.
@@ -2065,15 +2059,15 @@
}
List<TypeVariableMirror> get typeVariables {
- if (_cachedTypeVariables != null) return _cachedTypeVariables;
- List result = new List();
- List typeVariables =
+ if (_cachedTypeVariables != null) return _cachedTypeVariables;
+ List result = new List();
+ List typeVariables =
JS('JSExtendableArray|Null', '#.prototype["<>"]', _jsConstructor);
if (typeVariables == null) return result;
for (int i = 0; i < typeVariables.length; i++) {
TypeVariable typeVariable = getMetadata(typeVariables[i]);
- result.add(new JsTypeVariableMirror(typeVariable, this,
- typeVariables[i]));
+ result
+ .add(new JsTypeVariableMirror(typeVariable, this, typeVariables[i]));
}
return _cachedTypeVariables = new UnmodifiableListView(result);
}
@@ -2103,8 +2097,9 @@
}
if (other is JsFunctionTypeMirror) {
return false;
- } if (other is JsClassMirror &&
- JS('bool', '# == #', other._jsConstructor, _jsConstructor)) {
+ }
+ if (other is JsClassMirror &&
+ JS('bool', '# == #', other._jsConstructor, _jsConstructor)) {
return true;
} else if (superclass == null) {
return false;
@@ -2115,7 +2110,6 @@
}
class JsVariableMirror extends JsDeclarationMirror implements VariableMirror {
-
// TODO(ahe): The values in these fields are virtually untested.
final String _jsName;
final bool isFinal;
@@ -2125,19 +2119,12 @@
final int _type;
List _metadata;
- JsVariableMirror(Symbol simpleName,
- this._jsName,
- this._type,
- this.isFinal,
- this.isStatic,
- this._metadataFunction,
- this._owner)
+ JsVariableMirror(Symbol simpleName, this._jsName, this._type, this.isFinal,
+ this.isStatic, this._metadataFunction, this._owner)
: super(simpleName);
- factory JsVariableMirror.from(String descriptor,
- metadataFunction,
- JsDeclarationMirror owner,
- bool isStatic) {
+ factory JsVariableMirror.from(String descriptor, metadataFunction,
+ JsDeclarationMirror owner, bool isStatic) {
List<String> fieldInformation = descriptor.split('-');
if (fieldInformation.length == 1) {
// The field is not available for reflection.
@@ -2180,13 +2167,8 @@
}
}
int type = int.parse(fieldInformation[1], onError: (_) => null);
- return new JsVariableMirror(s(unmangledName),
- jsName,
- type,
- isFinal,
- isStatic,
- metadataFunction,
- owner);
+ return new JsVariableMirror(s(unmangledName), jsName, type, isFinal,
+ isStatic, metadataFunction, owner);
}
String get _prettyName => 'VariableMirror';
@@ -2201,7 +2183,8 @@
preserveMetadata();
if (_metadata == null) {
_metadata = (_metadataFunction == null)
- ? const [] : JS('', '#()', _metadataFunction);
+ ? const []
+ : JS('', '#()', _metadataFunction);
}
return _metadata.map(reflect).toList();
}
@@ -2233,8 +2216,7 @@
}
class JsClosureMirror extends JsInstanceMirror implements ClosureMirror {
- JsClosureMirror(reflectee)
- : super(reflectee);
+ JsClosureMirror(reflectee) : super(reflectee);
MethodMirror get function {
String cacheName = Primitives.mirrorFunctionCacheName;
@@ -2262,7 +2244,8 @@
}
return null;
})(#, #)''',
- reflectee, callPrefix);
+ reflectee,
+ callPrefix);
if (callName == null) {
throw new RuntimeError('Cannot find callName on "$reflectee"');
@@ -2276,22 +2259,29 @@
if (name == null) {
throwInvalidReflectionError(name);
}
- cachedFunction = new JsMethodMirror.fromUnmangledName(
- name, target, false, false);
+ cachedFunction =
+ new JsMethodMirror.fromUnmangledName(name, target, false, false);
} else {
bool isStatic = true; // TODO(ahe): Compute isStatic correctly.
var jsFunction = JS('', '#[#]', reflectee, callName);
var dummyOptionalParameterCount = 0;
cachedFunction = new JsMethodMirror(
- s(callName), jsFunction, parameterCount, dummyOptionalParameterCount,
- false, false, isStatic, false, false);
+ s(callName),
+ jsFunction,
+ parameterCount,
+ dummyOptionalParameterCount,
+ false,
+ false,
+ isStatic,
+ false,
+ false);
}
JS('void', r'#.constructor[#] = #', reflectee, cacheName, cachedFunction);
return cachedFunction;
}
InstanceMirror apply(List positionalArguments,
- [Map<Symbol, dynamic> namedArguments]) {
+ [Map<Symbol, dynamic> namedArguments]) {
return reflect(
Function.apply(reflectee, positionalArguments, namedArguments));
}
@@ -2316,21 +2306,20 @@
TypeMirror _returnType;
UnmodifiableListView<ParameterMirror> _parameters;
- JsMethodMirror(Symbol simpleName,
- this._jsFunction,
- this._requiredParameterCount,
- this._optionalParameterCount,
- this.isGetter,
- this.isSetter,
- this.isStatic,
- this.isConstructor,
- this.isOperator)
+ JsMethodMirror(
+ Symbol simpleName,
+ this._jsFunction,
+ this._requiredParameterCount,
+ this._optionalParameterCount,
+ this.isGetter,
+ this.isSetter,
+ this.isStatic,
+ this.isConstructor,
+ this.isOperator)
: super(simpleName);
- factory JsMethodMirror.fromUnmangledName(String name,
- jsFunction,
- bool isStatic,
- bool isConstructor) {
+ factory JsMethodMirror.fromUnmangledName(
+ String name, jsFunction, bool isStatic, bool isConstructor) {
List<String> info = name.split(':');
name = info[0];
bool isOperator = isOperatorName(name);
@@ -2349,12 +2338,19 @@
ReflectionInfo reflectionInfo = new ReflectionInfo(jsFunction);
requiredParameterCount = reflectionInfo.requiredParameterCount;
optionalParameterCount = reflectionInfo.optionalParameterCount;
- assert(int.parse(info[1]) == requiredParameterCount
- + optionalParameterCount);
+ assert(int.parse(info[1]) ==
+ requiredParameterCount + optionalParameterCount);
}
return new JsMethodMirror(
- s(name), jsFunction, requiredParameterCount, optionalParameterCount,
- isGetter, isSetter, isStatic, isConstructor, isOperator);
+ s(name),
+ jsFunction,
+ requiredParameterCount,
+ optionalParameterCount,
+ isGetter,
+ isSetter,
+ isStatic,
+ isConstructor,
+ isOperator);
}
String get _prettyName => 'MethodMirror';
@@ -2384,8 +2380,8 @@
var formals = new List(_parameterCount);
ReflectionInfo info = new ReflectionInfo(_jsFunction);
if (info != null) {
- assert(_parameterCount
- == info.requiredParameterCount + info.optionalParameterCount);
+ assert(_parameterCount ==
+ info.requiredParameterCount + info.optionalParameterCount);
var functionType = info.functionType;
var type;
if (functionType is int) {
@@ -2397,8 +2393,7 @@
TypeMirror ownerType = owner;
JsClassMirror ownerClass = ownerType.originalDeclaration;
type = new JsFunctionTypeMirror(
- info.computeFunctionRti(ownerClass._jsConstructor),
- owner);
+ info.computeFunctionRti(ownerClass._jsConstructor), owner);
}
// Constructors aren't reified with their return type.
if (isConstructor) {
@@ -2417,9 +2412,11 @@
metadataList: annotations);
} else {
var defaultValue = info.defaultValue(i);
- p = new JsParameterMirror(
- name, this, parameter._type, metadataList: annotations,
- isOptional: true, isNamed: isNamed, defaultValue: defaultValue);
+ p = new JsParameterMirror(name, this, parameter._type,
+ metadataList: annotations,
+ isOptional: true,
+ isNamed: isNamed,
+ defaultValue: defaultValue);
}
formals[i++] = p;
}
@@ -2449,7 +2446,7 @@
}
int positionalLength = positionalArguments.length;
if (positionalLength < _requiredParameterCount ||
- positionalLength > _parameterCount ||
+ positionalLength > _parameterCount ||
_jsFunction == null) {
// TODO(ahe): What receiver to use?
throw new NoSuchMethodError(
@@ -2469,7 +2466,7 @@
// care who their receiver is. But to lazy getters, it is important that
// 'this' is '$'.
return JS('', r'#.apply(#, #)', _jsFunction, JS_GET_STATIC_STATE(),
- new List.from(positionalArguments));
+ new List.from(positionalArguments));
}
_getField(JsMirror receiver) {
@@ -2527,13 +2524,11 @@
final List<int> metadataList;
- JsParameterMirror(String unmangledName,
- this.owner,
- this._type,
- {this.metadataList: const <int>[],
- this.isOptional: false,
- this.isNamed: false,
- defaultValue})
+ JsParameterMirror(String unmangledName, this.owner, this._type,
+ {this.metadataList: const <int>[],
+ this.isOptional: false,
+ this.isNamed: false,
+ defaultValue})
: _defaultValue = defaultValue,
super(s(unmangledName));
@@ -2568,7 +2563,7 @@
final String _mangledName;
JsFunctionTypeMirror referent;
- JsTypedefMirror(Symbol simpleName, this._mangledName, _typeData)
+ JsTypedefMirror(Symbol simpleName, this._mangledName, _typeData)
: super(simpleName) {
referent = new JsFunctionTypeMirror(_typeData, this);
}
@@ -2607,23 +2602,21 @@
Type get reflectedType => throw new UnimplementedError();
ClassMirror get superclass => throw new UnimplementedError();
List<ClassMirror> get superinterfaces => throw new UnimplementedError();
- Map<Symbol, DeclarationMirror> get declarations
- => throw new UnimplementedError();
- Map<Symbol, MethodMirror> get instanceMembers
- => throw new UnimplementedError();
+ Map<Symbol, DeclarationMirror> get declarations =>
+ throw new UnimplementedError();
+ Map<Symbol, MethodMirror> get instanceMembers =>
+ throw new UnimplementedError();
Map<Symbol, MethodMirror> get staticMembers => throw new UnimplementedError();
ClassMirror get mixin => throw new UnimplementedError();
- InstanceMirror newInstance(
- Symbol constructorName,
- List positionalArguments,
- [Map<Symbol, dynamic> namedArguments]) => throw new UnimplementedError();
- InstanceMirror invoke(Symbol memberName,
- List positionalArguments,
- [Map<Symbol, dynamic> namedArguments])
- => throw new UnimplementedError();
+ InstanceMirror newInstance(Symbol constructorName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) =>
+ throw new UnimplementedError();
+ InstanceMirror invoke(Symbol memberName, List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) =>
+ throw new UnimplementedError();
InstanceMirror getField(Symbol fieldName) => throw new UnimplementedError();
- InstanceMirror setField(Symbol fieldName, Object value)
- => throw new UnimplementedError();
+ InstanceMirror setField(Symbol fieldName, Object value) =>
+ throw new UnimplementedError();
delegate(Invocation invocation) => throw new UnimplementedError();
List<TypeVariableMirror> get typeVariables => throw new UnimplementedError();
List<TypeMirror> get typeArguments => throw new UnimplementedError();
@@ -2662,36 +2655,39 @@
}
bool get _hasArguments {
- return JS('bool', '# in #',
- JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG),
- _typeData);
+ return JS(
+ 'bool',
+ '# in #',
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG),
+ _typeData);
}
+
List get _arguments {
- return JS('JSExtendableArray', '#[#]',
- _typeData,
- JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG));
+ return JS('JSExtendableArray', '#[#]', _typeData,
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG));
}
bool get _hasOptionalArguments {
- return JS('bool', '# in #',
- JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG),
- _typeData);
+ return JS(
+ 'bool',
+ '# in #',
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG),
+ _typeData);
}
+
List get _optionalArguments {
- return JS('JSExtendableArray', '#[#]',
- _typeData,
- JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG));
+ return JS('JSExtendableArray', '#[#]', _typeData,
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG));
}
bool get _hasNamedArguments {
return JS('bool', '# in #',
- JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAMETERS_TAG),
- _typeData);
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAMETERS_TAG), _typeData);
}
+
get _namedArguments {
- return JS('=Object', '#[#]',
- _typeData,
- JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAMETERS_TAG));
+ return JS('=Object', '#[#]', _typeData,
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAMETERS_TAG));
}
bool get isOriginalDeclaration => true;
@@ -2730,8 +2726,8 @@
result.add(new JsParameterMirror(name, this, type));
}
}
- return _cachedParameters = new UnmodifiableListView<ParameterMirror>(
- result);
+ return _cachedParameters =
+ new UnmodifiableListView<ParameterMirror>(result);
}
String _unmangleIfPreserved(String mangled) {
@@ -2804,8 +2800,7 @@
}
TypeMirror typeMirrorFromRuntimeTypeRepresentation(
- DeclarationMirror owner,
- var /*int|List|JsFunction|TypeImpl*/ type) {
+ DeclarationMirror owner, var /*int|List|JsFunction|TypeImpl*/ type) {
// TODO(ahe): This method might benefit from using convertRtiToRuntimeType
// instead of working on strings.
ClassMirror ownerClass;
@@ -2852,8 +2847,7 @@
// [type] represents a type variable used as type argument for example
// the type argument of Bar: class Foo<T> extends Bar<T> {}
TypeMirror typeArgument = getTypeArgument(type);
- if (typeArgument is JsTypeVariableMirror)
- return typeArgument;
+ if (typeArgument is JsTypeVariableMirror) return typeArgument;
}
String substituteTypeVariable(int index) {
var typeArgument = getTypeArgument(index);
@@ -2873,6 +2867,7 @@
}
return typeArgument._mangledName;
}
+
representation =
runtimeTypeToString(type, onTypeVariable: substituteTypeVariable);
}
@@ -2905,19 +2900,17 @@
if (metadataFunction != null) return JS('', '#()', metadataFunction);
if (JS('bool', 'typeof # != "function"', victim)) return const [];
if (JS('bool', '# in #', r'$metadataIndex', victim)) {
- return JSArray.markFixedList(
- JS('JSExtendableArray',
- r'#.$reflectionInfo.splice(#.$metadataIndex)', victim, victim))
- .map((int i) => getMetadata(i)).toList();
+ return JSArray
+ .markFixedList(JS('JSExtendableArray',
+ r'#.$reflectionInfo.splice(#.$metadataIndex)', victim, victim))
+ .map((int i) => getMetadata(i))
+ .toList();
}
return const [];
}
-void parseCompactFieldSpecification(
- JsDeclarationMirror owner,
- fieldSpecification,
- bool isStatic,
- List<Mirror> result) {
+void parseCompactFieldSpecification(JsDeclarationMirror owner,
+ fieldSpecification, bool isStatic, List<Mirror> result) {
List fieldsMetadata = null;
List<String> fields;
if (fieldSpecification is List) {
@@ -2930,7 +2923,7 @@
}
int fieldNumber = 0;
for (String field in fields) {
- if (r'$ti' == field) continue; // Strip type info pseudofield.
+ if (r'$ti' == field) continue; // Strip type info pseudofield.
var metadata;
if (fieldsMetadata != null) {
metadata = fieldsMetadata[fieldNumber++];
@@ -2950,29 +2943,29 @@
bool isOperatorName(String name) {
switch (name) {
- case '==':
- case '[]':
- case '*':
- case '/':
- case '%':
- case '~/':
- case '+':
- case '<<':
- case '>>':
- case '>=':
- case '>':
- case '<=':
- case '<':
- case '&':
- case '^':
- case '|':
- case '-':
- case 'unary-':
- case '[]=':
- case '~':
- return true;
- default:
- return false;
+ case '==':
+ case '[]':
+ case '*':
+ case '/':
+ case '%':
+ case '~/':
+ case '+':
+ case '<<':
+ case '>>':
+ case '>=':
+ case '>':
+ case '<=':
+ case '<':
+ case '&':
+ case '^':
+ case '|':
+ case '-':
+ case 'unary-':
+ case '[]=':
+ case '~':
+ return true;
+ default:
+ return false;
}
}
@@ -3010,35 +3003,28 @@
final int _kind;
NoSuchStaticMethodError.missingConstructor(
- this._cls,
- this._name,
- this._positionalArguments,
- this._namedArguments)
+ this._cls, this._name, this._positionalArguments, this._namedArguments)
: _kind = MISSING_CONSTRUCTOR;
/// If the given class is `null` the static method/getter/setter is top-level.
NoSuchStaticMethodError.method(
- this._cls,
- this._name,
- this._positionalArguments,
- this._namedArguments)
+ this._cls, this._name, this._positionalArguments, this._namedArguments)
: _kind = MISSING_METHOD;
String toString() {
// TODO(floitsch): show arguments.
- switch(_kind) {
- case MISSING_CONSTRUCTOR:
- return
- "NoSuchMethodError: No constructor named '${n(_name)}' in class"
- " '${n(_cls.qualifiedName)}'.";
- case MISSING_METHOD:
- if (_cls == null) {
- return "NoSuchMethodError: No top-level method named '${n(_name)}'.";
- }
- return "NoSuchMethodError: No static method named '${n(_name)}' in"
- " class '${n(_cls.qualifiedName)}'";
- default:
- return 'NoSuchMethodError';
+ switch (_kind) {
+ case MISSING_CONSTRUCTOR:
+ return "NoSuchMethodError: No constructor named '${n(_name)}' in class"
+ " '${n(_cls.qualifiedName)}'.";
+ case MISSING_METHOD:
+ if (_cls == null) {
+ return "NoSuchMethodError: No top-level method named '${n(_name)}'.";
+ }
+ return "NoSuchMethodError: No static method named '${n(_name)}' in"
+ " class '${n(_cls.qualifiedName)}'";
+ default:
+ return 'NoSuchMethodError';
}
}
}
@@ -3048,8 +3034,7 @@
return new _symbol_dev.Symbol.validated(name);
}
if (library == null) {
- throw new ArgumentError(
- "Library required for private symbol name: $name");
+ throw new ArgumentError("Library required for private symbol name: $name");
}
if (!_symbol_dev.Symbol.isValidSymbol(name)) {
throw new ArgumentError("Not a valid symbol name: $name");
diff --git a/sdk/lib/_internal/js_runtime/lib/mirrors_patch.dart b/sdk/lib/_internal/js_runtime/lib/mirrors_patch.dart
index eb6319c..c370043 100644
--- a/sdk/lib/_internal/js_runtime/lib/mirrors_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/mirrors_patch.dart
@@ -43,9 +43,9 @@
}
@patch
-TypeMirror reflectType(Type key) {
+TypeMirror reflectType(Type key, [List<Type> typeArguments]) {
if (key == dynamic) {
return currentMirrorSystem().dynamicType;
}
- return js.reflectType(key);
+ return js.reflectType(key, typeArguments);
}
diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart
index 40d87bf..78818b7 100644
--- a/sdk/lib/core/string.dart
+++ b/sdk/lib/core/string.dart
@@ -360,7 +360,7 @@
String operator *(int times);
/**
- * Pads this string on the left if it is shorther than [width].
+ * Pads this string on the left if it is shorter than [width].
*
* Return a new string that prepends [padding] onto this string
* one time for each position the length is less than [width].
@@ -378,7 +378,7 @@
String padLeft(int width, [String padding = ' ']);
/**
- * Pads this string on the right if it is shorther than [width].
+ * Pads this string on the right if it is shorter than [width].
*
* Return a new string that appends [padding] after this string
* one time for each position the length is less than [width].
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 39f4dc3..afa40c5 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -37662,10 +37662,10 @@
if ((blob_OR_source_OR_stream is Blob || blob_OR_source_OR_stream == null)) {
return _blink.BlinkURL.instance.createObjectURL_Callback_1_(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is MediaSource)) {
+ if ((blob_OR_source_OR_stream is MediaStream)) {
return _blink.BlinkURL.instance.createObjectURL_Callback_1_(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is MediaStream)) {
+ if ((blob_OR_source_OR_stream is MediaSource)) {
return _blink.BlinkURL.instance.createObjectURL_Callback_1_(blob_OR_source_OR_stream);
}
throw new ArgumentError("Incorrect number or type of arguments");
diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart
index 637b021..5ab7d4c 100644
--- a/sdk/lib/internal/iterable.dart
+++ b/sdk/lib/internal/iterable.dart
@@ -402,8 +402,7 @@
*
* Expects efficient `length` and `elementAt` on the source iterable.
*/
-class MappedListIterable<S, T> extends ListIterable<T>
- implements EfficientLengthIterable<T> {
+class MappedListIterable<S, T> extends ListIterable<T> {
final Iterable<S> _source;
final _Transformation<S, T> _f;
diff --git a/sdk/lib/mirrors/mirrors.dart b/sdk/lib/mirrors/mirrors.dart
index 3aa88f4..4cfbf19 100644
--- a/sdk/lib/mirrors/mirrors.dart
+++ b/sdk/lib/mirrors/mirrors.dart
@@ -171,11 +171,16 @@
* If [key] is not an instance of [Type], then this function throws an
* [ArgumentError].
*
+ * Optionally takes a list of [typeArguments] for generic classes. If the list
+ * is provided, then the [key] must be a generic class type, and the number of
+ * the provided type arguments must be equal to the number of type variables
+ * declared by the class.
+ *
* Note that since one cannot obtain a [Type] object from another isolate, this
* function can only be used to obtain type mirrors on types of the current
* isolate.
*/
-external TypeMirror reflectType(Type key);
+external TypeMirror reflectType(Type key, [List<Type> typeArguments]);
/**
* A [Mirror] reflects some Dart language entity.
@@ -1229,7 +1234,7 @@
* see the comments for [symbols], [targets], [metaTargets] and [override].
*
* An import of `dart:mirrors` may have multiple [MirrorsUsed] annotations. This
- * is particularly helpful to specify overrides for specific libraries. For
+ * is particularly helpful to specify overrides for specific libraries. For
* example:
*
* @MirrorsUsed(targets: 'foo.Bar', override: 'foo')
@@ -1241,7 +1246,7 @@
*/
class MirrorsUsed {
// Note: the fields of this class are untyped. This is because the most
- // convenient way to specify symbols today is using a single string. In
+ // convenient way to specify symbols today is using a single string. In
// some cases, a const list of classes might be convenient. Some
// might prefer to use a const list of symbols.
@@ -1258,7 +1263,7 @@
*
* Dart2js currently supports the following formats to specify symbols:
*
- * * A constant [List] of [String] constants representing symbol names,
+ * * A constant [List] of [String] constants representing symbol names,
* e.g., `const ['foo', 'bar']`.
* * A single [String] constant whose value is a comma-separated list of
* symbol names, e.g., `"foo, bar"`.
@@ -1306,14 +1311,14 @@
* 1. If the qualified name matches a library name, the matching library is
* the target.
* 2. Else, find the longest prefix of the name such that the prefix ends
- * just before a `.` and is a library name.
+ * just before a `.` and is a library name.
* 3. Use that library as current scope. If no matching prefix was found, use
- * the current library, i.e., the library where the [MirrorsUsed]
+ * the current library, i.e., the library where the [MirrorsUsed]
* annotation was placed.
* 4. Split the remaining suffix (the entire name if no library name was
- * found in step 3) into a list of [String] using `.` as a
+ * found in step 3) into a list of [String] using `.` as a
* separator.
- * 5. Select all targets in the current scope whose name matches a [String]
+ * 5. Select all targets in the current scope whose name matches a [String]
* from the list.
*
* For example:
@@ -1329,11 +1334,11 @@
* @MirrorsUsed(targets: "my.library.one.A.aField")
* import "dart:mirrors";
*
- * The [MirrorsUsed] annotation specifies `A` and `aField` from library
+ * The [MirrorsUsed] annotation specifies `A` and `aField` from library
* `my.library.one` as targets. This will mark the class `A` as a reflective
* target. The target specification for `aField` has no effect, as there is
- * no target in `my.library.one` with that name.
- *
+ * no target in `my.library.one` with that name.
+ *
* Note that everything within a target also is available for reflection.
* So, if a library is specified as target, all classes in that library
* become targets for reflection. Likewise, if a class is a target, all
@@ -1355,9 +1360,9 @@
* effect. In particular, adding a library to [metaTargets] does not make
* the library's classes valid metadata annotations to enable reflection.
*
- * If an instance of a class specified in [metaTargets] is used as
+ * If an instance of a class specified in [metaTargets] is used as
* metadata annotation on a library, class, field or method, that library,
- * class, field or method is added to the set of targets for reflection.
+ * class, field or method is added to the set of targets for reflection.
*
* Example usage:
*
@@ -1377,10 +1382,10 @@
* }
*
* In the above example. `reflectableMethod` is marked as reflectable by
- * using the `Reflectable` class, which in turn is specified in the
+ * using the `Reflectable` class, which in turn is specified in the
* [metaTargets] annotation.
*
- * The method `nonReflectableMethod` lacks a metadata annotation and thus
+ * The method `nonReflectableMethod` lacks a metadata annotation and thus
* will not be reflectable at runtime.
*/
final metaTargets;
@@ -1390,7 +1395,7 @@
*
* When used as metadata on an import of "dart:mirrors", this metadata does
* not apply to the library in which the annotation is used, but instead
- * applies to the other libraries (all libraries if "*" is used).
+ * applies to the other libraries (all libraries if "*" is used).
*
* The following text is non-normative:
*
@@ -1400,31 +1405,31 @@
* libraries.
* * A single [String] constant whose value is a comma-separated list of
* library names.
- *
- * Conceptually, a [MirrorsUsed] annotation with [override] has the same
+ *
+ * Conceptually, a [MirrorsUsed] annotation with [override] has the same
* effect as placing the annotation directly on the import of `dart:mirrors`
- * in each of the referenced libraries. Thus, if the library had no
- * [MirrorsUsed] annotation before, its unconditional import of
+ * in each of the referenced libraries. Thus, if the library had no
+ * [MirrorsUsed] annotation before, its unconditional import of
* `dart:mirrors` is overridden by an annotated import.
- *
+ *
* Note that, like multiple explicit [MirrorsUsed] annotations, using
* override on a library with an existing [MirrorsUsed] annotation is
* additive. That is, the overall set of reflective targets is the union
* of the reflective targets that arise from the original and the
- * overriding [MirrorsUsed] annotations.
+ * overriding [MirrorsUsed] annotations.
*
- * The use of [override] is only meaningful for libraries that have an
+ * The use of [override] is only meaningful for libraries that have an
* import of `dart:mirrors` without annotation because otherwise it would
* work exactly the same way without the [override] parameter.
*
* While the annotation will apply to the given target libraries, the
- * [symbols], [targets] and [metaTargets] are still evaluated in the
+ * [symbols], [targets] and [metaTargets] are still evaluated in the
* scope of the annotation. Thus, to select a target from library `foo`,
* a qualified name has to be used or, if the target is visible in the
* current scope, its type may be referenced.
- *
+ *
* For example, the following code marks all targets in the library `foo`
- * as reflectable that have a metadata annotation using the `Reflectable`
+ * as reflectable that have a metadata annotation using the `Reflectable`
* class from the same library.
*
* @MirrorsUsed(metaTargets: "foo.Reflectable", override: "foo")
@@ -1438,8 +1443,8 @@
final override;
/**
- * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets],
- * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation
+ * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets],
+ * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation
* of the parameters.
*/
const MirrorsUsed(
diff --git a/tests/benchmark_smoke/benchmark_smoke.status b/tests/benchmark_smoke/benchmark_smoke.status
index 69c792c..de17765 100644
--- a/tests/benchmark_smoke/benchmark_smoke.status
+++ b/tests/benchmark_smoke/benchmark_smoke.status
@@ -10,7 +10,3 @@
[ $compiler == dart2js && $cps_ir && $checked ]
*: Skip # Issue 25761
-
-[ $compiler == dart2analyzer ]
-# Issue #28236
-benchmark_smoke_test: StaticWarning
diff --git a/tests/co19/co19-kernel.status b/tests/co19/co19-kernel.status
index f51c40d..953714c 100644
--- a/tests/co19/co19-kernel.status
+++ b/tests/co19/co19-kernel.status
@@ -122,27 +122,18 @@
# dartk: Shared JIT & Precompiled failures
[ ($compiler == dartk && $runtime == vm) || ($compiler == dartkp && $runtime == dart_precompiled) ]
-Language/Classes/Constructors/Generative_Constructors/execution_of_a_superinitializer_t01: RuntimeError
Language/Classes/Constructors/Generative_Constructors/execution_of_an_initializer_t02: RuntimeError
Language/Classes/Constructors/Generative_Constructors/initializing_formals_execution_t02: RuntimeError
Language/Classes/definition_t23: CompileTimeError
-Language/Enums/declaration_equivalent_t01: RuntimeError
-Language/Expressions/Constants/string_length_t01: Crash
Language/Expressions/Function_Invocation/Function_Expression_Invocation/not_a_function_expression_t01: RuntimeError
Language/Expressions/Function_Invocation/Unqualified_Invocation/function_expr_invocation_t03: RuntimeError
Language/Expressions/Function_Invocation/Unqualified_Invocation/function_expr_invocation_t04: RuntimeError
Language/Expressions/Function_Invocation/Unqualified_Invocation/static_method_invocation_t02: RuntimeError
-Language/Expressions/Function_Invocation/async_cleanup_t07: Fail
-Language/Expressions/Function_Invocation/async_cleanup_t08: Fail
-Language/Expressions/Function_Invocation/async_generator_invokation_t05: RuntimeError
-Language/Expressions/Function_Invocation/async_generator_invokation_t06: RuntimeError
-Language/Expressions/Function_Invocation/async_generator_invokation_t09: RuntimeError
Language/Expressions/Identifier_Reference/built_in_identifier_t35: Pass
Language/Expressions/Identifier_Reference/built_in_identifier_t36: Pass
Language/Expressions/Identifier_Reference/built_in_identifier_t37: Pass
Language/Expressions/Identifier_Reference/built_in_not_dynamic_t14: Pass
Language/Expressions/Identifier_Reference/evaluation_property_extraction_t03: RuntimeError
-Language/Expressions/Identifier_Reference/evaluation_type_parameter_t01: RuntimeError
Language/Expressions/Instance_Creation/New/evaluation_t12: RuntimeError
Language/Expressions/Instance_Creation/New/evaluation_t19: RuntimeError
Language/Expressions/Instance_Creation/New/evaluation_t20: RuntimeError
@@ -166,14 +157,8 @@
Language/Libraries_and_Scripts/Imports/invalid_uri_t02: Pass
Language/Libraries_and_Scripts/Parts/syntax_t06: Pass
Language/Statements/Labels/syntax_t03: Pass
-Language/Statements/Rethrow/execution_t04: RuntimeError
Language/Statements/Switch/syntax_t02: Pass
Language/Statements/Try/catch_scope_t01: RuntimeError
-Language/Statements/Yield_and_Yield_Each/Yield/execution_async_t04: Fail
-Language/Statements/Yield_and_Yield_Each/Yield/execution_async_t05: Fail
-Language/Statements/Yield_and_Yield_Each/Yield/execution_async_t06: Fail
-Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t01: RuntimeError
-Language/Types/Interface_Types/subtype_t44: RuntimeError
Language/Types/Static_Types/deferred_type_t01: RuntimeError
Language/Variables/final_t01/01: MissingRuntimeError
Language/Variables/final_t02/01: MissingRuntimeError
@@ -197,7 +182,6 @@
# dartk: JIT failures (debug)
[ $compiler == dartk && $runtime == vm && $mode == debug ]
Language/Expressions/Shift/syntax_t15: Crash # Invalid class id during isolate shutdown Heap::VerifyGC
-Language/Expressions/Spawning_an_Isolate/new_isolate_t01: Crash # Class finalization issue
Language/Libraries_and_Scripts/Scripts/top_level_main_t05: Crash # !main_obj.IsNull()
# dartk: precompilation failures
diff --git a/tests/co19/co19-runtime.status b/tests/co19/co19-runtime.status
index b4e205c..fcf344b 100644
--- a/tests/co19/co19-runtime.status
+++ b/tests/co19/co19-runtime.status
@@ -189,12 +189,6 @@
[ ($runtime == vm || $runtime == dart_precompiled ) && $mode == debug ]
LibTest/core/List/List_class_A01_t02: Pass, Slow
LibTest/isolate/Isolate/spawn_A04_t01: Pass, Fail # Issue 28269
-Language/Types/Interface_Types/subtype_t28: Pass, Slow
-Language/Types/Interface_Types/subtype_t27: Pass, Slow
-LibTest/collection/ListMixin/ListMixin_class_A01_t02: Pass, Slow
-
-[ ($runtime == dart_precompiled || $runtime == dart_app) && $mode == debug ]
-Language/Libraries_and_Scripts/Imports/deferred_import_t02: Crash # Issue 27201
[ ($runtime == vm || $runtime == dart_precompiled) && ($arch != x64 && $arch != simarm64 && $arch != arm64 && $arch != simdbc64 && $arch != simdbc) ]
LibTest/core/int/operator_left_shift_A01_t02: Fail # co19 issue 129
diff --git a/tests/corelib/corelib.status b/tests/corelib/corelib.status
index 2dfdb3b..c730f6e 100644
--- a/tests/corelib/corelib.status
+++ b/tests/corelib/corelib.status
@@ -160,6 +160,7 @@
[ $runtime == vm || $runtime == dart_precompiled ]
regexp/global_test: Skip # Timeout. Issue 21709 and 21708
+regexp/pcre_test: Pass, Slow, Timeout # Issues 21593 and 22008
[ $runtime != vm && $runtime != dart_precompiled && $compiler != dart2analyzer]
data_resource_test: RuntimeError # Issue 23825 (not implemented yet).
diff --git a/tests/corelib_strong/corelib_strong_kernel.status b/tests/corelib_strong/corelib_strong_kernel.status
index 945b79f..8b36750 100644
--- a/tests/corelib_strong/corelib_strong_kernel.status
+++ b/tests/corelib_strong/corelib_strong_kernel.status
@@ -8,6 +8,7 @@
compare_to2_test: RuntimeError
const_list_remove_range_test: DartkCompileTimeError
const_list_set_range_test: DartkCompileTimeError
+hash_map2_test: Crash # VM does not support BottomType
int_from_environment_test: RuntimeError
iterable_return_type_test/01: RuntimeError
iterable_return_type_test/02: RuntimeError
@@ -33,4 +34,4 @@
string_case_test/01: RuntimeError
string_from_environment2_test: RuntimeError
string_from_environment_test: RuntimeError
-unicode_test: RuntimeError
\ No newline at end of file
+unicode_test: RuntimeError
diff --git a/tests/html/html.status b/tests/html/html.status
index 14ab0bd..0bf4421 100644
--- a/tests/html/html.status
+++ b/tests/html/html.status
@@ -422,163 +422,6 @@
window_nosuchmethod_test: StaticWarning
js_typed_interop_default_arg_test/default_value: MissingCompileTimeError # Issue #25759
-# Issue #28236
-async_spawnuri_test: StaticWarning
-async_test: StaticWarning
-audiobuffersourcenode_test: StaticWarning
-audiocontext_test: StaticWarning
-audioelement_test: StaticWarning
-b_element_test: StaticWarning
-blob_constructor_test: StaticWarning
-cache_test: StaticWarning
-callbacks_test: StaticWarning
-canvas_pixel_array_type_alias_test: StaticWarning
-canvas_test: StaticWarning
-canvasrenderingcontext2d_test: StaticWarning
-cdata_test: StaticWarning
-client_rect_test: StaticWarning
-cross_domain_iframe_test: StaticWarning
-crypto_test: StaticWarning
-css_rule_list_test: StaticWarning
-css_test: StaticWarning
-cssstyledeclaration_test: StaticWarning
-custom/attribute_changed_callback_test: StaticWarning
-custom/constructor_calls_created_synchronously_test: StaticWarning
-custom/created_callback_test: StaticWarning
-custom/document_register_template_test: StaticWarning
-custom/document_register_type_extensions_test: StaticWarning
-custom/entered_left_view_test: StaticWarning
-custom/js_custom_test: StaticWarning
-custom/mirrors_test: StaticWarning
-custom/regress_194523002_test: StaticWarning
-custom_element_method_clash_test: StaticWarning
-custom_element_name_clash_test: StaticWarning
-custom_elements_23127_test: StaticWarning
-custom_elements_test: StaticWarning
-custom_tags_test: StaticWarning
-dart_object_local_storage_test: StaticWarning
-document_test: StaticWarning
-dom_constructors_test: StaticWarning
-domparser_test: StaticWarning
-element_animate_test: StaticWarning
-element_classes_svg_test: StaticWarning
-element_classes_test: StaticWarning
-element_constructor_1_test: StaticWarning
-element_dimensions_test: StaticWarning
-element_offset_test: StaticWarning
-element_types_constructors1_test: StaticWarning
-element_types_constructors2_test: StaticWarning
-element_types_constructors3_test: StaticWarning
-element_types_constructors4_test: StaticWarning
-element_types_constructors5_test: StaticWarning
-element_types_constructors6_test: StaticWarning
-element_types_test: StaticWarning
-event_customevent_test: StaticWarning
-event_test: StaticWarning
-exceptions_test: StaticWarning
-fileapi_test: StaticWarning
-filereader_test: StaticWarning
-filteredelementlist_test: StaticWarning
-fontface_loaded_test: StaticWarning
-fontface_test: StaticWarning
-form_data_test: StaticWarning
-form_element_test: StaticWarning
-gamepad_test: StaticWarning
-geolocation_test: StaticWarning
-hidden_dom_1_test: StaticWarning
-hidden_dom_2_test: StaticWarning
-history_test: StaticWarning
-htmlcollection_test: StaticWarning
-htmloptionscollection_test: StaticWarning
-indexeddb_1_test: StaticWarning
-indexeddb_2_test: StaticWarning
-indexeddb_3_test: StaticWarning
-indexeddb_4_test: StaticWarning
-indexeddb_5_test: StaticWarning
-input_element_test: StaticWarning
-instance_of_test: StaticWarning
-isolates_test: StaticWarning
-js_array_test: StaticWarning
-js_dart_to_string_test: StaticWarning
-js_dispatch_property_test: StaticWarning
-js_function_getter_test: StaticWarning
-js_interop_1_test: StaticWarning
-js_interop_constructor_name_test: StaticWarning
-js_test: StaticWarning
-js_type_test: StaticWarning
-js_typed_interop_anonymous2_exp_test: StaticWarning
-js_typed_interop_anonymous2_test: StaticWarning
-js_typed_interop_anonymous_exp_test: StaticWarning
-js_typed_interop_anonymous_test: StaticWarning
-js_typed_interop_anonymous_unreachable_exp_test: StaticWarning
-js_typed_interop_anonymous_unreachable_test: StaticWarning
-js_typed_interop_bind_this_test: StaticWarning
-js_typed_interop_callable_object_test: StaticWarning
-js_typed_interop_default_arg_test/explicit_argument: StaticWarning
-js_typed_interop_default_arg_test/none: StaticWarning
-js_typed_interop_side_cast_exp_test: StaticWarning
-js_typed_interop_side_cast_test: StaticWarning
-js_typed_interop_test: StaticWarning
-js_typed_interop_window_property_test: StaticWarning
-js_util_test: StaticWarning
-keyboard_event_test: StaticWarning
-location_test: StaticWarning
-media_stream_test: StaticWarning
-mediasource_test: StaticWarning
-messageevent_test: StaticWarning
-mirrors_js_typed_interop_test: StaticWarning
-mouse_event_test: StaticWarning
-native_gc_test: StaticWarning
-navigator_test: StaticWarning
-node_test: StaticWarning
-node_validator_important_if_you_suppress_make_the_bug_critical_test: StaticWarning
-non_instantiated_is_test: StaticWarning
-notification_test: StaticWarning
-performance_api_test: StaticWarning
-postmessage_structured_test: StaticWarning
-query_test: StaticWarning
-range_test: StaticWarning
-request_animation_frame_test: StaticWarning
-rtc_test: StaticWarning
-selectelement_test: StaticWarning
-serialized_script_value_test: StaticWarning
-shadow_dom_test: StaticWarning
-shadowroot_test: StaticWarning
-speechrecognition_test: StaticWarning
-storage_test: StaticWarning
-streams_test: StaticWarning
-svg_test: StaticWarning
-svgelement_test: StaticWarning
-table_test: StaticWarning
-text_event_test: StaticWarning
-touchevent_test: StaticWarning
-transition_event_test: StaticWarning
-trusted_html_tree_sanitizer_test: StaticWarning
-typed_arrays_1_test: StaticWarning
-typed_arrays_2_test: StaticWarning
-typed_arrays_3_test: StaticWarning
-typed_arrays_4_test: StaticWarning
-typed_arrays_5_test: StaticWarning
-typed_arrays_arraybuffer_test: StaticWarning
-typed_arrays_dataview_test: StaticWarning
-typed_arrays_simd_test: StaticWarning
-unknownelement_test: StaticWarning
-uri_test: StaticWarning
-url_test: StaticWarning
-webgl_extensions_test: StaticWarning
-websocket_test: StaticWarning
-websql_test: StaticWarning
-wheelevent_test: StaticWarning
-window_eq_test: StaticWarning
-window_mangling_test: StaticWarning
-window_test: StaticWarning
-worker_api_test: StaticWarning
-worker_test: StaticWarning
-wrapping_collections_test: StaticWarning
-xhr_cross_origin_test: StaticWarning
-xhr_test: StaticWarning
-xsltprocessor_test: StaticWarning
-
[ $compiler == dart2js && $fast_startup ]
custom/constructor_calls_created_synchronously_test: Fail # mirrors not supported
custom/js_custom_test: Fail # mirrors not supported
diff --git a/tests/isolate/isolate.status b/tests/isolate/isolate.status
index 7a921a0..02c7df0 100644
--- a/tests/isolate/isolate.status
+++ b/tests/isolate/isolate.status
@@ -154,43 +154,12 @@
simple_message_test/none: RuntimeError, OK # Uses Isolate.spawn.
start_paused_test: RuntimeError, OK # Uses Isolate.spawn.
message3_test/int32x4: RuntimeError, OK # Uses Isolate.spawn.
-browser/package_*: Skip # Issue 25594 (missing implementation in Dartium).
+browser/package_resolve_browser_hook*: Skip # Tests that use defaultPackagesBase (not supported in Dartium).
[ $compiler == dart2analyzer ]
browser/typed_data_message_test: StaticWarning
mint_maker_test: StaticWarning
-# Issue #28236
-browser/compute_this_script_browser_test: StaticWarning
-browser/package_resolve_browser_hook2_test: StaticWarning
-browser/package_resolve_browser_hook_test: StaticWarning
-browser/package_resolve_browser_test: StaticWarning
-count_test: StaticWarning
-cross_isolate_message_test: StaticWarning
-deferred_in_isolate2_test: StaticWarning
-illegal_msg_function_test: StaticWarning
-illegal_msg_mirror_test: StaticWarning
-isolate_complex_messages_test: StaticWarning
-mandel_isolate_test: StaticWarning
-message2_test: StaticWarning
-message_test: StaticWarning
-nested_spawn2_test: StaticWarning
-nested_spawn_test: StaticWarning
-raw_port_test: StaticWarning
-request_reply_test: StaticWarning
-spawn_function_custom_class_test: StaticWarning
-spawn_function_test: StaticWarning
-spawn_uri_multi_test/01: StaticWarning
-spawn_uri_multi_test/none: StaticWarning
-spawn_uri_nested_vm_test: StaticWarning
-spawn_uri_test: StaticWarning
-spawn_uri_vm_test: StaticWarning
-stacktrace_message_test: StaticWarning
-static_function_test: StaticWarning
-timer_isolate_test: StaticWarning
-unresolved_ports_test: StaticWarning
-
-
[ $compiler == none && $runtime == vm ]
scenarios/short_package/short_package_test: Fail, OK # We do not plan to support the tested behavior anyway.
@@ -268,3 +237,8 @@
deferred_in_isolate2_test: Crash # Requires deferred libraries
issue_21398_parent_isolate2_test: Crash # Requires deferred libraries
spawn_uri_nested_vm_test: Pass, Crash # Issue 28192
+
+[ $builder_tag == asan && $arch == x64 ]
+function_send_test: Fail # Issue 28351
+function_send1_test: Fail # Issue 28351
+issue_21398_parent_isolate_test: Fail # Issue 28351
diff --git a/tests/language/covariant_override_test.dart b/tests/language/covariant_override_test.dart
new file mode 100644
index 0000000..7a91126
--- /dev/null
+++ b/tests/language/covariant_override_test.dart
@@ -0,0 +1,92 @@
+
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library covariant_override_test;
+
+// This test contains cases where `covariant` is used as intended.
+
+abstract class A {
+ A(this.f1, this.f2, this.f3);
+
+ // Normal usage, "by design": superclass requests covariance.
+ void m1(covariant Object o);
+
+ // Normal usage, "ad hoc": subclass requests covariance.
+ void m2(Object o);
+
+ // Syntactic special case: omit the type in subclass.
+ void m3(Object o);
+
+ // Positional optional arguments.
+ void m4([covariant Object o]);
+ void m5([Object o]);
+ void m6([Object o]);
+
+ // Named arguments.
+ void m7({covariant Object arg});
+ void m8({Object arg});
+ void m9({Object arg});
+
+ // Normal usage on field, "by design": superclass requests covariance.
+ covariant Object f1;
+
+ // Normal usage on field, "ad hoc": subclass requests covariance.
+ Object f2;
+
+ // Syntactic special case.
+ Object f3;
+}
+
+abstract class B extends A {
+ B(num f1, num f2, num f3): super(f1, f2, f3);
+
+ void m1(num n);
+ void m2(covariant num n);
+ void m3(covariant n);
+ void m4([num n]);
+ void m5([covariant num n]);
+ void m6([covariant n]);
+ void m7({num arg});
+ void m8({covariant num arg});
+ void m9({covariant arg});
+ void set f1(num n);
+ void set f2(covariant num n);
+ void set f3(covariant n);
+}
+
+class C extends B {
+ C(int f1, int f2, int f3): super(f1, f2, f3);
+
+ void m1(int i) {}
+ void m2(int i) {}
+ void m3(int i) {}
+ void m4([int i]) {}
+ void m5([int i]) {}
+ void m6([int i]) {}
+ void m7({int arg}) {}
+ void m8({int arg}) {}
+ void m9({int arg}) {}
+ void set f1(int i) {}
+ void set f2(int i) {}
+ void set f3(int i) {}
+}
+
+main() {
+ // For Dart 1.x, `covariant` has no runtime semantics; we just ensure
+ // that the code is not unused, such that we know it will be parsed.
+ A a = new C(39, 40, 41);
+ a.m1(42);
+ a.m2(42);
+ a.m3(42);
+ a.m4(42);
+ a.m5(42);
+ a.m6(42);
+ a.m7(arg: 42);
+ a.m8(arg: 42);
+ a.m9(arg: 42);
+ a.f1 = 42;
+ a.f2 = 42;
+ a.f3 = 42;
+}
diff --git a/tests/language/covariant_test.dart b/tests/language/covariant_test.dart
new file mode 100644
index 0000000..b93c901
--- /dev/null
+++ b/tests/language/covariant_test.dart
@@ -0,0 +1,378 @@
+// Copyright (c) 2017, 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.
+
+// Test that `covariant` can be parsed (and ignored) by
+// dart2js and the VM.
+// This test only checks for non-strong mode behavior.
+//
+// Generally, `covariant` should be ignored, when it is used in the right
+// places.
+
+import 'package:expect/expect.dart';
+
+// Top level field may not have a covariant.
+// Would be considered a minor (acceptable) bug, if it was accepted here too.
+covariant /// 00: compile-time error
+int x0;
+
+// Getters may never have `covariant`. (Neither on the top-level nor as members)
+covariant /// 01: compile-time error
+int get x1 => 499;
+
+// Top level setters may not have a covariant.
+// Would be considered a minor (acceptable) bug, if it was accepted here too.
+void set x2(
+ covariant /// 02: compile-time error
+ int val) {}
+
+// Same as above, but with `covariant` in different positions.
+// The `covariant` is just wrong there.
+
+int
+covariant /// 03: compile-time error
+x3;
+
+int
+covariant /// 04: compile-time error
+get x4 => 499;
+
+void set x5(
+ int
+ covariant /// 05: compile-time error
+ val) {}
+
+
+// Same without types.
+
+// Since `covariant` is a built-in identifier, it is not allowed here.
+covariant x6; /// 06: compile-time error
+
+// Getters may never have `covariant`.
+covariant /// 07: compile-time error
+get x7 => 499;
+
+// Top level setters may not have a covariant.
+// Would be considered a minor (acceptable) bug, if it was accepted here too.
+void set x8(
+ covariant /// 08: compile-time error
+ val) {}
+
+// If there is no type, then `covariant` is simply the parameter name:
+void set x9(covariant) {}
+
+// Covariant won't work on return types.
+covariant /// 10: compile-time error
+int f10() => 499;
+
+// Covariant won't work as a return type.
+covariant /// 11: compile-time error
+f11() => 499;
+
+// Covariant should not work on top-level methods.
+// It's a minor (acceptable) bug to not error out here.
+int f12(
+ covariant /// 12: compile-time error
+ int x) => 499;
+
+// `Covariant` must be in front of the types.
+int f13(
+ int
+ covariant /// 13: compile-time error
+ x) => 499;
+
+// Covariant should not work on top-level methods.
+// It's a minor (acceptable) bug to not error out here.
+int f14(
+ covariant /// 14: compile-time error
+ final
+ x) => 499;
+
+// `Covariant` must be in front of modifiers.
+int f15(
+ final
+ covariant /// 15: compile-time error
+ x) => 499;
+
+// Covariant should not work on top-level methods.
+// It's a minor (acceptable) bug to not error out here.
+int f16(
+ covariant /// 16: compile-time error
+ final
+ int
+ x) => 499;
+
+// `Covariant` must be in front of modifiers.
+int f17(
+ final
+ covariant /// 17: compile-time error
+ int
+ x) => 499;
+
+// On its own, `covariant` is just a parameter name.
+int f18(covariant) => covariant;
+
+// All of the above as statics in a class.
+class A {
+ // Static fields may not have a covariant.
+ // Would be considered a minor (acceptable) bug, if it was accepted here too.
+ static
+ covariant /// 20: compile-time error
+ int x20;
+
+ // Getters may never have `covariant`.
+ static
+ covariant /// 21: compile-time error
+ int get x21 => 499;
+
+ // Getters may never have `covariant`.
+ covariant /// 21b: compile-time error
+ static
+ int get x21b => 499;
+
+ // Static setters may not have a covariant.
+ // Would be considered a minor (acceptable) bug, if it was accepted here too.
+ static void set x22(
+ covariant /// 22: compile-time error
+ int val) {}
+
+ // Same as above, but with `covariant` in different positions.
+ // The `covariant` is just wrong there.
+
+ static int
+ covariant /// 23: compile-time error
+ x23;
+
+ static int
+ covariant /// 24: compile-time error
+ get x24 => 499;
+
+ static void set x25(
+ int
+ covariant /// 25: compile-time error
+ val) {}
+
+ // Since `covariant` is a built-in identifier, it is not allowed here.
+ static covariant x26; /// 26: compile-time error
+
+ // Getters may never have `covariant`.
+ static
+ covariant /// 27: compile-time error
+ get x27 => 499;
+
+ covariant /// 27b: compile-time error
+ static
+ get x27b => 499;
+
+ // Static setters may not have a covariant.
+ // Would be considered a minor (acceptable) bug, if it was accepted here too.
+ static void set x28(
+ covariant /// 28: compile-time error
+ val) {}
+
+ // If there is no type, then `covariant` is simply the parameter name:
+ static void set x29(covariant) {}
+
+ // Covariant won't work on return types.
+ static
+ covariant /// 30: compile-time error
+ int f30() => 499;
+
+ covariant /// 30b: compile-time error
+ static
+ int f30b() => 499;
+
+ // Covariant won't work as a return type.
+ static
+ covariant /// 31: compile-time error
+ f31() => 499;
+
+ covariant /// 31b: compile-time error
+ static
+ f31b() => 499;
+
+ // Covariant should not work on static methods.
+ // It's a minor (acceptable) bug to not error out here.
+ static int f32(
+ covariant /// 32: compile-time error
+ int x) => 499;
+
+ // `Covariant` must be in front of the types.
+ static int f33(
+ int
+ covariant /// 33: compile-time error
+ x) => 499;
+
+ // Covariant should not work on top-level methods.
+ // It's a minor (acceptable) bug to not error out here.
+ static int f34(
+ covariant /// 34: compile-time error
+ final
+ x) => 499;
+
+ // `Covariant` must be in front of modifiers.
+ static int f35(
+ final
+ covariant /// 35: compile-time error
+ x) => 499;
+
+ // Covariant should not work on top-level methods.
+ // It's a minor (acceptable) bug to not error out here.
+ static int f36(
+ covariant /// 36: compile-time error
+ final
+ int
+ x) => 499;
+
+ // `Covariant` must be in front of modifiers.
+ static int f37(
+ final
+ covariant /// 37: compile-time error
+ int
+ x) => 499;
+
+ // `Covariant` on its own is just a parameter name.
+ static int f38(covariant) => covariant;
+}
+
+// All of the above as instance members in a class.
+class B {
+ covariant int x40;
+
+ // Getters may never have `covariant`.
+ covariant /// 41: compile-time error
+ int get x41 => 499;
+
+ void set x42(covariant int val) {}
+
+ // `covariant` in the wrong position.
+ int
+ covariant /// 43: compile-time error
+ x43;
+
+ // `covariant` in the wrong position.
+ int
+ covariant /// 44: compile-time error
+ get x44 => 499;
+
+ void set x45(
+ int
+ covariant /// 45: compile-time error
+ val) {}
+
+ // Since `covariant` is a built-in identifier, it is not allowed here.
+ covariant x46; /// 46: compile-time error
+
+ // Getters may never have `covariant`.
+ covariant /// 47: compile-time error
+ get x47 => 499;
+
+ void set x48(covariant val) {}
+
+ // If there is no type, then `covariant` is simply the parameter name:
+ void set x49(covariant) {}
+
+ // Covariant won't work on return types.
+ covariant /// 50: compile-time error
+ int f50() => 499;
+
+ // Covariant won't work as a return type.
+ covariant /// 51: compile-time error
+ f51() => 499;
+
+ int f52(covariant int x) => 499;
+
+ // `Covariant` must be in front of the types.
+ int f53(
+ int
+ covariant /// 53: compile-time error
+ x) => 499;
+
+ int f54(covariant final x) => 499;
+
+ // `Covariant` must be in front of modifiers.
+ int f55(
+ final
+ covariant /// 55: compile-time error
+ x) => 499;
+
+ int f56(covariant final int x) => 499;
+
+ // `Covariant` must be in front of modifiers.
+ int f57(
+ final
+ covariant /// 57: compile-time error
+ int
+ x) => 499;
+
+ // `Covariant` on its own is just a parameter name.
+ int f58(covariant) => covariant;
+}
+
+void use(x) {}
+
+main() {
+ x0 = 0;
+ use(x1);
+ x2 = 499;
+ use(x3);
+ use(x4);
+ x5 = 42;
+ x6 = 0; /// 06: continued
+ use(x7);
+ x8 = 11;
+ x9 = 12;
+ use(f10());
+ use(f11());
+ use(f12(2));
+ use(f13(3));
+ use(f14(3));
+ use(f15(3));
+ use(f16(3));
+ use(f17(3));
+ Expect.equals(123, f18(123));
+
+ A.x20 = 0;
+ use(A.x21);
+ use(A.x21b);
+ A.x22 = 499;
+ use(A.x23);
+ use(A.x24);
+ A.x25 = 42;
+ A.x26 = 0; /// 26: continued
+ use(A.x27);
+ use(A.x27b);
+ A.x28 = 11;
+ A.x29 = 12;
+ use(A.f30());
+ use(A.f31());
+ use(A.f31b());
+ use(A.f32(2));
+ use(A.f33(3));
+ use(A.f34(3));
+ use(A.f35(3));
+ use(A.f36(3));
+ use(A.f37(3));
+ Expect.equals(1234, A.f38(1234));
+
+ var b = new B();
+ b.x40 = 0;
+ use(b.x41);
+ b.x42 = 499;
+ use(b.x43);
+ use(b.x44);
+ b.x45 = 42;
+ b.x46 = 0; /// 46: continued
+ use(b.x47);
+ b.x48 = 11;
+ b.x49 = 12;
+ use(b.f50());
+ use(b.f51());
+ use(b.f52(2));
+ use(b.f53(2));
+ use(b.f54(3));
+ use(b.f55(3));
+ use(b.f56(3));
+ use(b.f57(3));
+ Expect.equals(12345, b.f58(12345));
+}
\ No newline at end of file
diff --git a/tests/language/enum_test.dart b/tests/language/enum_test.dart
index a3b4586..7cdcee4 100644
--- a/tests/language/enum_test.dart
+++ b/tests/language/enum_test.dart
@@ -20,7 +20,7 @@
Expect.equals('Enum2.A', Enum2.A.toString());
Expect.equals(0, Enum2.A.index);
Expect.listEquals([Enum2.A], Enum2.values);
- Expect.identical(const [Enum2.A], Enum2.values);
+ Expect.identical(const <Enum2>[Enum2.A], Enum2.values);
Enum2.values.forEach(test2);
Expect.equals('Enum3.B', Enum3.B.toString());
diff --git a/tests/language/language.status b/tests/language/language.status
index ed6179e..83da9ad 100644
--- a/tests/language/language.status
+++ b/tests/language/language.status
@@ -5,10 +5,9 @@
# This directory contains tests that are intended to show the
# current state of the language.
-[ $compiler == none || $compiler == precompiler || $compiler == app_jit ]
-# Other issues:
-generic_methods_type_expression_test: RuntimeError # Issue 25869
-
+# These test entries will be valid for vm/dartium (with and without kernel).
+[ $compiler == none || $compiler == app_jit || $compiler == dartk || $runtime == dart_precompiled ]
+async_star_cancel_while_paused_test: RuntimeError
# This is OK for now, but we may want to change the semantics to match the test.
async_star_pause_test: Fail, OK
@@ -22,6 +21,8 @@
constructor5_test: Fail # Issue 6422
constructor6_test: Fail # Issue 6422
+generic_methods_type_expression_test: RuntimeError # Issue 25869 / 27460
+
# Failures related to super call in ctor initializer list
super_test: Fail, OK
final_field_initialization_order_test: Fail, OK
@@ -30,26 +31,31 @@
constructor3_test: Fail, OK
constructor2_test: Fail, OK
-dynamic_prefix_core_test/01: RuntimeError # Issue 12478
-multiline_strings_test: Fail # Issue 23020
-
# Regular bugs which should be fixed.
duplicate_export_negative_test: Fail # Issue 6134
-deferred_redirecting_factory_test: Fail # Issue 23408
-redirecting_constructor_initializer_test: RuntimeError # Issue 23488
-
# Non-contractive types are not supported in the vm.
cyclic_type_test/02: Fail, OK
cyclic_type_test/04: Fail, OK
cyclic_type2_test: Fail, OK
least_upper_bound_expansive_test/*: Fail, OK
-async_star_regression_2238_test: CompileTimeError, RuntimeError # drt only runtime-errs.
-async_star_cancel_while_paused_test: RuntimeError
-# Fails because `as T` is an error rather than being treated like `as dynamic`.
-generic_methods_type_expression_test: RuntimeError # Issue 27460
+[ $compiler == none || $compiler == precompiler || $compiler == app_jit ]
+
+enum_test: RuntimeError # Issue 28341
+
+dynamic_prefix_core_test/01: RuntimeError # Issue 12478
+multiline_strings_test: Fail # Issue 23020
+
+deferred_redirecting_factory_test: Fail # Issue 23408
+redirecting_constructor_initializer_test: RuntimeError # Issue 23488
+
+async_star_regression_2238_test: CompileTimeError, RuntimeError # drt only runtime-errs.
+
+# Doesn't yet implement `covariant` keyword.
+covariant_test/none: Fail # Issue 28166
+covariant_override_test: Fail # Issue 28166
[ ($compiler == none || $compiler == precompiler || $compiler == app_jit) && $checked ]
# These generic functions tests pass for the wrong reason in checked mode,
@@ -65,7 +71,6 @@
class_keyword_test/02: MissingCompileTimeError # Issue 13627
unicode_bom_test: Fail # Issue 16067
vm/debug_break_enabled_vm_test/01: Crash, OK # Expected to hit breakpoint.
-try_catch_optimized1_test: Skip # Srdjan investigating
[ ($compiler == none || $compiler == precompiler || $compiler == app_jit) && $checked ]
type_variable_bounds4_test/01: Fail # Issue 14006
@@ -100,6 +105,7 @@
main_test/42: Fail # Issue 20028
mirror_in_static_init_test: Fail # Issue 22071
vm/debug_break_enabled_vm_test/*: Skip # Issue 14651.
+vm/regress_28325_test: SkipByDesign # Requires dart:io
# These tests need the flag --initializing-formal-access to pass:
initializing_formal_access_test: Skip
@@ -163,7 +169,8 @@
stacktrace_rethrow_error_test: Pass, RuntimeError
stacktrace_rethrow_nonerror_test: Pass, RuntimeError
stacktrace_test: Pass, RuntimeError
-regress_26948_test: Skip # Crashes, regis investigating
+vm/regress_28325_test: RuntimeError # Missing source position in AOT.
+
[ $noopt || $runtime == dart_precompiled || $mode == product ]
# Imports dart:mirrors
@@ -330,10 +337,3 @@
null_bottom_test/01: Pass, CompileTimeError # Issue 28025
null_bottom_test/02: Pass, CompileTimeError # Issue 28025
null_bottom_test/03: Pass, CompileTimeError # Issue 28025
-
-# Issue #28236
-async_await_test: StaticWarning
-async_star_pause_test: StaticWarning
-async_star_test: StaticWarning
-regress_18535_test: StaticWarning
-
diff --git a/tests/language/language_analyzer2.status b/tests/language/language_analyzer2.status
index 272af1c..bb12210 100644
--- a/tests/language/language_analyzer2.status
+++ b/tests/language/language_analyzer2.status
@@ -7,6 +7,10 @@
regress_26668_test: Fail # Issue 26678
regress_27617_test/1: MissingCompileTimeError
+# Doesn't yet implement `covariant` keyword.
+covariant_test/none: CompileTimeError # Issue 28167
+covariant_override_test: CompileTimeError # Issue 28167
+
# Runtime negative test. No static errors or warnings.
closure_call_wrong_argument_count_negative_test: skip
diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status
index fc253a47..f97480a 100644
--- a/tests/language/language_dart2js.status
+++ b/tests/language/language_dart2js.status
@@ -3,6 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
[ $compiler == dart2js ]
+enum_test: Fail # Issue 28340
deferred_not_loaded_check_test: Fail # Issue 27577
getter_setter_in_lib_test: Fail # Issue 23288
method_name_test: Fail # issue 25574
@@ -39,6 +40,17 @@
bad_typedef_test/00: Crash # Issue 28214
+covariant_test/02: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/08: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/12: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/14: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/16: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/22: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/28: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/32: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/34: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+covariant_test/36: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
+
[ $compiler == dart2js && $fast_startup ]
const_evaluation_test/*: Fail # mirrors not supported
deferred_constraints_constants_test/none: Fail # mirrors not supported
diff --git a/tests/language/language_kernel.status b/tests/language/language_kernel.status
index 3ea014e..144c004 100644
--- a/tests/language/language_kernel.status
+++ b/tests/language/language_kernel.status
@@ -3,10 +3,8 @@
# BSD-style license that can be found in the LICENSE file.
# These tests currently take too long. Remove when they are fixed.
-[ $compiler == dartk ]
-large_class_declaration_test: Skip
-large_implicit_getter_test: Skip
-larger_implicit_getter_test: Skip
+[ $compiler == dartk || $compiler == dartkp ]
+large_class_declaration_test: SkipSlow # KernelVM Issue 28312
###############################################################################
# Dartk Entries
@@ -34,47 +32,6 @@
final_syntax_test/04: MissingCompileTimeError
main_not_a_function_test/01: DartkCrash
metadata_test: DartkCompileTimeError
-mixin_illegal_super_use_test/01: MissingCompileTimeError
-mixin_illegal_super_use_test/02: MissingCompileTimeError
-mixin_illegal_super_use_test/03: MissingCompileTimeError
-mixin_illegal_super_use_test/04: MissingCompileTimeError
-mixin_illegal_super_use_test/05: MissingCompileTimeError
-mixin_illegal_super_use_test/06: MissingCompileTimeError
-mixin_illegal_super_use_test/07: MissingCompileTimeError
-mixin_illegal_super_use_test/08: MissingCompileTimeError
-mixin_illegal_super_use_test/09: MissingCompileTimeError
-mixin_illegal_super_use_test/10: MissingCompileTimeError
-mixin_illegal_super_use_test/11: MissingCompileTimeError
-mixin_illegal_superclass_test/01: MissingCompileTimeError
-mixin_illegal_superclass_test/02: MissingCompileTimeError
-mixin_illegal_superclass_test/03: MissingCompileTimeError
-mixin_illegal_superclass_test/04: MissingCompileTimeError
-mixin_illegal_superclass_test/05: MissingCompileTimeError
-mixin_illegal_superclass_test/06: MissingCompileTimeError
-mixin_illegal_superclass_test/07: MissingCompileTimeError
-mixin_illegal_superclass_test/08: MissingCompileTimeError
-mixin_illegal_superclass_test/09: MissingCompileTimeError
-mixin_illegal_superclass_test/10: MissingCompileTimeError
-mixin_illegal_superclass_test/11: MissingCompileTimeError
-mixin_illegal_superclass_test/12: MissingCompileTimeError
-mixin_illegal_superclass_test/13: MissingCompileTimeError
-mixin_illegal_superclass_test/14: MissingCompileTimeError
-mixin_illegal_superclass_test/15: MissingCompileTimeError
-mixin_illegal_superclass_test/16: MissingCompileTimeError
-mixin_illegal_superclass_test/17: MissingCompileTimeError
-mixin_illegal_superclass_test/18: MissingCompileTimeError
-mixin_illegal_superclass_test/19: MissingCompileTimeError
-mixin_illegal_superclass_test/20: MissingCompileTimeError
-mixin_illegal_superclass_test/21: MissingCompileTimeError
-mixin_illegal_superclass_test/22: MissingCompileTimeError
-mixin_illegal_superclass_test/23: MissingCompileTimeError
-mixin_illegal_superclass_test/24: MissingCompileTimeError
-mixin_illegal_superclass_test/25: MissingCompileTimeError
-mixin_illegal_superclass_test/26: MissingCompileTimeError
-mixin_illegal_superclass_test/27: MissingCompileTimeError
-mixin_illegal_superclass_test/28: MissingCompileTimeError
-mixin_illegal_superclass_test/29: MissingCompileTimeError
-mixin_illegal_superclass_test/30: MissingCompileTimeError
multiline_newline_test/01: DartkCompileTimeError
multiline_newline_test/02: DartkCompileTimeError
multiline_newline_test/03: DartkCompileTimeError
@@ -90,6 +47,9 @@
vm/debug_break_enabled_vm_test/none: DartkCompileTimeError
vm/reflect_core_vm_test: DartkCompileTimeError
vm/regress_27201_test: DartkCompileTimeError
+vm/regress_28325_test: RuntimeError # Issue 28055.
+covariant_test/none: CompileTimeError # Issue 28166
+covariant_override_test: DartkCrash # Issue 28166
# dartk: JIT failures
[ $compiler == dartk && $runtime == vm ]
@@ -118,24 +78,10 @@
accessor_conflict_import_prefixed_test: RuntimeError
accessor_conflict_import_test: RuntimeError
assertion_test: RuntimeError
-async_await_test: Crash, RuntimeError
-async_star_cancel_and_throw_in_finally_test: RuntimeError
-async_star_cancel_while_paused_test: RuntimeError
-async_star_pause_test: Crash, RuntimeError
-async_star_regression_fisk_test: Timeout
-async_star_stream_take_test: Timeout
-async_star_take_reyield_test: Timeout
-async_star_test: Crash, Timeout
-asyncstar_throw_in_catch_test: Timeout
-asyncstar_yield_test: Timeout
-asyncstar_yieldstar_test: Timeout
bad_raw_string_negative_test: Fail
-cha_deopt1_test: RuntimeError
-cha_deopt2_test: RuntimeError
-cha_deopt3_test: RuntimeError
-closure_type_variable_test: RuntimeError
-closures_initializer_test: RuntimeError
-compile_time_constant12_test: Crash
+cha_deopt1_test: RuntimeError # Deferred Loading Issue 28335
+cha_deopt2_test: RuntimeError # Deferred Loading Issue 28335
+cha_deopt3_test: RuntimeError # Deferred Loading Issue 28335
compile_time_constant_k_test/01: RuntimeError
compile_time_constant_k_test/02: RuntimeError
compile_time_constant_k_test/03: RuntimeError
@@ -146,19 +92,12 @@
const_error_multiply_initialized_test/02: RuntimeError
const_error_multiply_initialized_test/04: RuntimeError
const_nested_test: RuntimeError
-constructor2_test: RuntimeError
-constructor3_test: RuntimeError
-constructor5_test: RuntimeError
-constructor6_test: RuntimeError
constructor_duplicate_final_test/01: MissingRuntimeError
constructor_duplicate_final_test/02: MissingRuntimeError
custom_await_stack_trace_test: RuntimeError
-cyclic_type2_test: CompileTimeError
cyclic_type_test/00: RuntimeError
cyclic_type_test/01: RuntimeError
-cyclic_type_test/02: CompileTimeError
cyclic_type_test/03: RuntimeError
-cyclic_type_test/04: CompileTimeError
cyclic_type_variable_test/01: Crash
cyclic_type_variable_test/02: Crash
cyclic_type_variable_test/03: Crash
@@ -209,32 +148,10 @@
deferred_type_dependency_test/is: RuntimeError
deferred_type_dependency_test/none: RuntimeError
deferred_type_dependency_test/type_annotation: RuntimeError
-duplicate_export_negative_test: Fail
-enum_duplicate_test/01: RuntimeError
-enum_duplicate_test/02: RuntimeError
-enum_duplicate_test/none: RuntimeError
-enum_mirror_test: RuntimeError
-enum_private_test/01: RuntimeError
-enum_private_test/02: RuntimeError
-enum_private_test/none: RuntimeError
-enum_test: RuntimeError
evaluation_redirecting_constructor_test: RuntimeError
-example_constructor_test: RuntimeError
external_test/10: MissingRuntimeError
external_test/13: MissingRuntimeError
external_test/20: MissingRuntimeError
-f_bounded_equality_test: RuntimeError
-field_initialization_order_test: RuntimeError
-final_field_initialization_order_test: RuntimeError
-fixed_type_variable2_test/02: RuntimeError
-fixed_type_variable2_test/04: RuntimeError
-fixed_type_variable2_test/06: RuntimeError
-fixed_type_variable_test/01: RuntimeError
-fixed_type_variable_test/02: RuntimeError
-fixed_type_variable_test/03: RuntimeError
-fixed_type_variable_test/04: RuntimeError
-fixed_type_variable_test/05: RuntimeError
-fixed_type_variable_test/06: RuntimeError
for2_test: RuntimeError
for_variable_capture_test: RuntimeError
function_subtype2_test: RuntimeError
@@ -248,15 +165,9 @@
function_type_alias2_test: RuntimeError
function_type_alias3_test: RuntimeError
function_type_alias4_test: RuntimeError
-generic2_test: RuntimeError
generic_closure_test: RuntimeError
-generic_creation_test: RuntimeError
-generic_field_mixin2_test: RuntimeError
generic_field_mixin4_test: RuntimeError
-generic_field_mixin5_test: RuntimeError
-generic_inheritance_test: RuntimeError
generic_method_types_test: Pass, RuntimeError
-generic_methods_type_expression_test: RuntimeError
generic_test: RuntimeError
getter_closure_execution_order_test: RuntimeError
getter_setter_in_lib_test: RuntimeError
@@ -265,72 +176,41 @@
is_not_class2_test: RuntimeError
issue13474_test: RuntimeError
issue_1751477_test: RuntimeError
-least_upper_bound_expansive_test/01: CompileTimeError
-least_upper_bound_expansive_test/02: CompileTimeError
-least_upper_bound_expansive_test/03: CompileTimeError
-least_upper_bound_expansive_test/04: CompileTimeError
-least_upper_bound_expansive_test/05: CompileTimeError
-least_upper_bound_expansive_test/06: CompileTimeError
-least_upper_bound_expansive_test/07: CompileTimeError
-least_upper_bound_expansive_test/08: CompileTimeError
-least_upper_bound_expansive_test/09: CompileTimeError
-least_upper_bound_expansive_test/10: CompileTimeError
-least_upper_bound_expansive_test/11: CompileTimeError
-least_upper_bound_expansive_test/12: CompileTimeError
-least_upper_bound_expansive_test/none: CompileTimeError
library_env_test/has_html_support: RuntimeError
library_env_test/has_no_io_support: RuntimeError
list_literal4_test: RuntimeError
malformed_test/none: RuntimeError
map_literal3_test: RuntimeError
-map_literal4_test: RuntimeError
+map_literal4_test: RuntimeError # Checked Mode Issue
map_literal6_test: RuntimeError
method_override_test: RuntimeError
-mixin_generic_test: RuntimeError
-mixin_mixin2_test: RuntimeError
-mixin_mixin3_test: RuntimeError
-mixin_mixin4_test: RuntimeError
-mixin_mixin5_test: RuntimeError
-mixin_mixin_bound2_test: RuntimeError
-mixin_mixin_bound_test: RuntimeError
-mixin_super_test: RuntimeError
-mixin_type_parameters_simple_test: RuntimeError
mixin_type_parameters_super_extends_test: RuntimeError
mixin_type_parameters_super_test: RuntimeError
multiline_newline_test/none: RuntimeError
named_parameters_type_test/01: MissingRuntimeError
named_parameters_type_test/02: MissingRuntimeError
named_parameters_type_test/03: MissingRuntimeError
-not_enough_positional_arguments_test/02: MissingRuntimeError
-not_enough_positional_arguments_test/05: MissingRuntimeError
-null_test/none: RuntimeError
+not_enough_positional_arguments_test/02: MissingRuntimeError # Dartk Issue 28301
+not_enough_positional_arguments_test/05: MissingRuntimeError # Dartk Issue 28301
number_identifier_test/05: RuntimeError
positional_parameters_type_test/01: MissingRuntimeError
positional_parameters_type_test/02: MissingRuntimeError
prefix10_negative_test: Fail
prefix21_test: RuntimeError
redirecting_constructor_initializer_test: RuntimeError
-regress_18713_test: RuntimeError
-regress_22443_test: RuntimeError
-regress_22700_test: RuntimeError
-regress_23408_test: RuntimeError
-regress_27164_test: CompileTimeError
-regress_r24720_test: RuntimeError
-regress_28278_test: RuntimeError
-reify_typevar_test: RuntimeError
+regress_22443_test: RuntimeError # Deferred Loading Issue 28335
+regress_23408_test: RuntimeError # Deferred Loading Issue 28335
+regress_28278_test: RuntimeError # Mirrors Issue
script1_negative_test: Fail
script2_negative_test: Fail
setter_no_getter_call_test/none: RuntimeError
static_setter_get_test/01: RuntimeError
-super_test: RuntimeError
switch7_negative_test: Fail
switch_try_catch_test: RuntimeError
-sync_generator3_test/test2: RuntimeError
try_catch_on_syntax_test/10: MissingRuntimeError
try_catch_on_syntax_test/11: MissingRuntimeError
try_finally_regress_25654_test: RuntimeError
type_checks_in_factory_method_test: RuntimeError
-type_parameter_literal_test: RuntimeError
type_variable_function_type_test: RuntimeError
vm/type_cast_vm_test: RuntimeError
vm/type_vm_test: RuntimeError
@@ -339,28 +219,23 @@
[ $compiler == dartk && $runtime == vm ]
const_evaluation_test/01: RuntimeError
const_locals_test: RuntimeError
-constructor_named_arguments_test/01: Crash
-const_string_test: RuntimeError
+constructor_named_arguments_test/01: Crash # Dartk Issue 28301
+const_string_test: RuntimeError # Dartk Issue 28306
instance_creation_in_function_annotation_test: RuntimeError
library_env_test/has_no_mirror_support: RuntimeError
redirecting_factory_reflection_test: RuntimeError
# dartk: JIT failures (debug)
[ $compiler == dartk && $runtime == vm && $mode == debug ]
-async_star_regression_fisk_test: Crash # Stack mismatch during expression translation.
-async_star_test: Crash # Stack mismatch during expression translation.
-issue23244_test: Crash # Class finalization issue
-not_enough_positional_arguments_test/02: Crash
-not_enough_positional_arguments_test/05: Crash
-vm/optimized_guarded_field_isolates_test: Crash # Class finalization issue
+not_enough_positional_arguments_test/02: Crash # Dartk Issue 28301
+not_enough_positional_arguments_test/05: Crash # Dartk Issue 28301
# dartk: precompilation failures
[ $compiler == dartkp && $runtime == dart_precompiled ]
-if_null_assignment_static_test/35: Crash
-large_class_declaration_test: Pass, Timeout
-string_interpolation7_test: RuntimeError
+if_null_assignment_static_test/35: Crash # Dartk Issue 28302
+string_interpolation7_test: RuntimeError # Dartk Issue 28306
# dartk: precompilation failures (debug)
[ $compiler == dartkp && $runtime == dart_precompiled && $mode == debug ]
-constructor_named_arguments_test/01: Crash
-not_enough_positional_arguments_test/05: Crash
+constructor_named_arguments_test/01: Crash # Dartk Issue 28301
+not_enough_positional_arguments_test/05: Crash # Dartk Issue 28301
diff --git a/tests/language/lazy_static8_test.dart b/tests/language/lazy_static8_test.dart
new file mode 100644
index 0000000..812219f
--- /dev/null
+++ b/tests/language/lazy_static8_test.dart
@@ -0,0 +1,73 @@
+// Copyright (c) 2017, 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:expect/expect.dart";
+
+// Test re-entrant initializer - calls throw CyclicInitializationError.
+
+var trace;
+
+final foo = bar;
+
+get bar {
+ trace.add('bar');
+ try {
+ return foo ?? 1;
+ } catch (e) {
+ trace.add(e is CyclicInitializationError);
+ }
+ try {
+ return foo ?? 2;
+ } catch (e) {
+ trace.add(e is CyclicInitializationError);
+ }
+ return 42;
+}
+
+void testTopLevel() {
+ trace = [];
+ var result = foo;
+ Expect.equals(42, result);
+ Expect.equals('bar,true,true', trace.join(','));
+ trace = [];
+ result = foo;
+ Expect.equals(42, result);
+ Expect.equals('', trace.join(','));
+
+}
+
+class X {
+ static final foo = X.bar;
+
+ static get bar {
+ trace.add('X.bar');
+ try {
+ return foo ?? 1;
+ } catch (e) {
+ trace.add(e is CyclicInitializationError);
+ }
+ try {
+ return foo ?? 2;
+ } catch (e) {
+ trace.add(e is CyclicInitializationError);
+ }
+ return 49;
+ }
+}
+
+void testClassStatic() {
+ trace = [];
+ var result = X.foo;
+ Expect.equals(49, result);
+ Expect.equals('X.bar,true,true', trace.join(','));
+ trace = [];
+ result = X.foo;
+ Expect.equals(49, result);
+ Expect.equals('', trace.join(','));
+}
+
+main() {
+ testTopLevel();
+ testClassStatic();
+}
diff --git a/tests/language/vm/regress_28325_test.dart b/tests/language/vm/regress_28325_test.dart
new file mode 100644
index 0000000..5276381
--- /dev/null
+++ b/tests/language/vm/regress_28325_test.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2017, 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.
+
+// Test source positions in async errors.
+
+import "package:expect/expect.dart";
+import "dart:io";
+
+main() async {
+ try {
+ await Socket.connect("localhost", 0);
+ Expect.isTrue(false); // Unreachable.
+ } catch (e, s) {
+ Expect.isTrue(e is SocketException);
+ Expect.isTrue(s.toString().contains("regress_28325_test.dart"));
+ print(s);
+ Expect.isTrue(s.toString().contains(":12")); // Line number of "await".
+ }
+}
diff --git a/tests/language_strong/await_in_cascade_test.dart b/tests/language_strong/await_in_cascade_test.dart
index e9fbcf9..7049e73 100644
--- a/tests/language_strong/await_in_cascade_test.dart
+++ b/tests/language_strong/await_in_cascade_test.dart
@@ -11,5 +11,5 @@
}
main() async {
- Expect.equals(await new C().m(), 42);
+ Expect.equals((await new C().m()).first, 42);
}
diff --git a/tests/language_strong/language_strong_kernel.status b/tests/language_strong/language_strong_kernel.status
index 30aff8b..7858270 100644
--- a/tests/language_strong/language_strong_kernel.status
+++ b/tests/language_strong/language_strong_kernel.status
@@ -3,6 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
[ $compiler == dartk && $runtime == vm ]
+arithmetic2_test: RuntimeError # Throws CastError instead of TypeError
assertion_test: RuntimeError
async_await_test/02: DartkCompileTimeError
async_await_test/03: DartkCompileTimeError
@@ -23,6 +24,7 @@
asyncstar_yieldstar_test: Timeout
await_in_cascade_test: RuntimeError
bad_raw_string_negative_test: Fail
+bool_test: RuntimeError # Throws CastError instead of TypeError
cha_deopt1_test: RuntimeError
cha_deopt2_test: RuntimeError
cha_deopt3_test: RuntimeError
@@ -127,6 +129,7 @@
generic_inheritance_test: RuntimeError
generic_tearoff_test: Crash
getter_closure_execution_order_test: RuntimeError
+if_null_evaluation_order_test: Crash # VM does not support BottomType
inferrer_closure_test: RuntimeError
initializing_formal_final_test: RuntimeError
instance_creation_in_function_annotation_test: RuntimeError
@@ -146,6 +149,7 @@
mixin_mixin_bound2_test: RuntimeError
mixin_mixin_bound_test: RuntimeError
no_main_test/01: DartkCrash
+operator4_test: RuntimeError # Throws CastError instead of TypeError
prefix10_negative_test: Fail
prefix21_test: RuntimeError
recursive_generic_test: RuntimeError
@@ -155,7 +159,9 @@
regress_r24720_test: RuntimeError
reify_typevar_static_test/00: MissingCompileTimeError
reify_typevar_test: RuntimeError
+setter_no_getter_test/01: Crash # VM does not support BottomType
switch_try_catch_test: RuntimeError
sync_generator3_test/test2: RuntimeError
+type_error_test: RuntimeError # Throws CastError instead of TypeError
type_literal_test: RuntimeError
-type_parameter_literal_test: RuntimeError
\ No newline at end of file
+type_parameter_literal_test: RuntimeError
diff --git a/tests/language_strong/recursive_mixin_test.dart b/tests/language_strong/recursive_mixin_test.dart
new file mode 100644
index 0000000..b2c1e3c
--- /dev/null
+++ b/tests/language_strong/recursive_mixin_test.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2016, 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:expect/expect.dart";
+
+class A<T> {
+ bool foo(T x) => true;
+}
+
+class B extends Object with A<B> {}
+
+main() {
+ var b = new B();
+ Expect.isTrue(b is B);
+ Expect.isTrue(b is A);
+
+ // Verify that runtime checking enforces A<B> instead of A
+ dynamic d = b;
+ Expect.isTrue(d.foo(b));
+ Expect.throws(() => d.foo(42));
+}
diff --git a/tests/lib/lib.status b/tests/lib/lib.status
index 34a3a77..9598983 100644
--- a/tests/lib/lib.status
+++ b/tests/lib/lib.status
@@ -105,6 +105,18 @@
mirrors/raw_type_test/01: RuntimeError # Issue 6490
mirrors/mirrors_reader_test: Slow, RuntimeError # Issue 16589
mirrors/regress_26187_test: RuntimeError # Issue 6490
+mirrors/reflected_type_generics_test/01: Fail # Issues in reflecting generic typedefs.
+mirrors/reflected_type_generics_test/02: Fail # Issues in reflecting bounded type variables.
+# The following tests fail because we have disabled a test in
+# `reflectClassByName`. `MirrorsUsed` leads to classes not having the
+# information necessary to correctly handle these checks.
+mirrors/reflected_type_generics_test/03: Fail # Issues in reflecting generic typedefs.
+mirrors/reflected_type_generics_test/04: Fail # Issues in reflecting bounded type variables.
+mirrors/reflected_type_generics_test/05: Fail # Issues in reflecting generic typedefs.
+mirrors/reflected_type_generics_test/06: Fail # Issues in reflecting bounded type variables.
+
+[ $compiler == none && $unchecked ]
+mirrors/reflected_type_generics_test/02: Fail, Ok # Type check for a bounded type argument.
[ $compiler == dart2js && $fast_startup ]
mirrors/*: Fail # mirrors not supported
@@ -333,47 +345,6 @@
profiler/metrics_test: Fail # Issue 20309
profiler/metrics_num_test: Fail # Issue 20309
-# Issue #28236
-async/first_regression_test: StaticWarning
-async/future_timeout_test: StaticWarning
-async/multiple_timer_test: StaticWarning
-async/schedule_microtask2_test: StaticWarning
-async/schedule_microtask3_test: StaticWarning
-async/schedule_microtask5_test: StaticWarning
-async/stream_controller_async_test: StaticWarning
-async/stream_first_where_test: StaticWarning
-async/stream_from_iterable_test: StaticWarning
-async/stream_iterator_test: StaticWarning
-async/stream_join_test: StaticWarning
-async/stream_last_where_test: StaticWarning
-async/stream_periodic2_test: StaticWarning
-async/stream_periodic3_test: StaticWarning
-async/stream_periodic4_test: StaticWarning
-async/stream_periodic5_test: StaticWarning
-async/stream_periodic6_test: StaticWarning
-async/stream_periodic_test: StaticWarning
-async/stream_single_test: StaticWarning
-async/stream_single_to_multi_subscriber_test: StaticWarning
-async/stream_state_nonzero_timer_test: StaticWarning
-async/stream_state_test: StaticWarning
-async/stream_subscription_as_future_test: StaticWarning
-async/stream_subscription_cancel_test: StaticWarning
-async/stream_timeout_test: StaticWarning
-async/stream_transform_test: StaticWarning
-async/stream_transformation_broadcast_test: StaticWarning
-async/timer_cancel1_test: StaticWarning
-async/timer_cancel2_test: StaticWarning
-async/timer_cancel_test: StaticWarning
-async/timer_isActive_test: StaticWarning
-async/timer_repeat_test: StaticWarning
-async/timer_test: StaticWarning
-convert/json_lib_test: StaticWarning
-js/null_test: StaticWarning
-math/point_test: StaticWarning
-math/rectangle_test: StaticWarning
-mirrors/library_uri_io_test: StaticWarning
-mirrors/library_uri_package_test: StaticWarning
-
[ ($compiler == dartanalyzer || $compiler == dart2analyzer) && $checked ]
mirrors/regress_16321_test/01: MissingCompileTimeError # Issue 16391
diff --git a/tests/lib/mirrors/mirrors_used_generic_types_test.dart b/tests/lib/mirrors/mirrors_used_generic_types_test.dart
new file mode 100644
index 0000000..5962214
--- /dev/null
+++ b/tests/lib/mirrors/mirrors_used_generic_types_test.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library Test;
+
+@MirrorsUsed(targets: const ["Test"])
+import 'dart:mirrors';
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+
+class A {
+ // Because of the `mirrors-used` annotation, the types `List` and `Future`
+ // are not reflectable.
+ // However, we still need to be able to create a Mirror for them, when we
+ // create a mirror for `foo`. In particular, it must be able to create a
+ // mirror, even though there are generic types.
+ List<int> foo(Future<int> x) {
+ return null;
+ }
+}
+
+void main() {
+ var m = reflect(new A()).type.instanceMembers[#foo];
+ Expect.equals(#List, m.returnType.simpleName);
+ Expect.equals(#Future, m.parameters[0].type.simpleName);
+}
diff --git a/tests/lib/mirrors/reflected_type_generics_test.dart b/tests/lib/mirrors/reflected_type_generics_test.dart
new file mode 100644
index 0000000..f10425c
--- /dev/null
+++ b/tests/lib/mirrors/reflected_type_generics_test.dart
@@ -0,0 +1,99 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.reflected_type_generics_test;
+
+@MirrorsUsed(targets: "test.reflected_type_generics_test")
+import 'dart:mirrors';
+
+import 'package:expect/expect.dart';
+
+import 'reflected_type_helper.dart';
+
+class A<T> {}
+
+class P {}
+
+class B extends A<P> {}
+
+class C<K, V> {}
+
+class D<T> extends A<T> {}
+
+class E<K> extends C<K, int> {}
+
+class F<G> {}
+
+typedef bool Predicate<T>(T arg);
+
+class FBounded<S extends FBounded> {}
+
+class Helper<T> {
+ Type get param => T;
+}
+
+class Mixin<T extends P> {}
+
+class Composite<K extends P, V> extends Object with Mixin<K> {}
+
+main() {
+ // "Happy" paths:
+ expectReflectedType(reflectType(A, [P]), new A<P>().runtimeType);
+ expectReflectedType(reflectType(C, [B, P]), new C<B, P>().runtimeType);
+ expectReflectedType(reflectType(D, [P]), new D<P>().runtimeType);
+ expectReflectedType(reflectType(E, [P]), new E<P>().runtimeType);
+ expectReflectedType(
+ reflectType(FBounded, [FBounded]), new FBounded<FBounded>().runtimeType);
+
+ var predicateHelper = new Helper<Predicate<P>>();
+ expectReflectedType(reflectType(Predicate, [P]), predicateHelper.param); /// 01: ok
+ var composite = new Composite<P, int>();
+ expectReflectedType(reflectType(Composite, [P, int]), composite.runtimeType);
+
+ // Edge cases:
+ Expect.throws(
+ () => reflectType(P, []),
+ (e) => e is ArgumentError && e.invalidValue is List,
+ "Should throw an ArgumentError if reflecting not a generic class with "
+ "empty list of type arguments");
+ Expect.throws( /// 03: ok
+ () => reflectType(P, [B]), /// 03: continued
+ (e) => e is Error, /// 03: continued
+ "Should throw an ArgumentError if reflecting not a generic class with " /// 03: continued
+ "some type arguments"); /// 03: continued
+ Expect.throws(
+ () => reflectType(A, []),
+ (e) => e is ArgumentError && e.invalidValue is List,
+ "Should throw an ArgumentError if type argument list is empty for a "
+ "generic class");
+ Expect.throws( /// 04: ok
+ () => reflectType(A, [P, B]), /// 04: continued
+ (e) => e is ArgumentError && e.invalidValue is List, /// 04: continued
+ "Should throw an ArgumentError if number of type arguments is not " /// 04: continued
+ "correct"); /// 04: continued
+ Expect.throws(() => reflectType(B, [P]), (e) => e is Error, /// 05: ok
+ "Should throw an ArgumentError for non-generic class extending " /// 05: continued
+ "generic one"); /// 05: continued
+ Expect.throws(
+ () => reflectType(A, ["non-type"]),
+ (e) => e is ArgumentError && e.invalidValue is List,
+ "Should throw an ArgumentError when any of type arguments is not a Type");
+ Expect.throws( /// 06: ok
+ () => reflectType(A, [P, B]), /// 06: continued
+ (e) => e is ArgumentError && e.invalidValue is List, /// 06: continued
+ "Should throw an ArgumentError if number of type arguments is not correct " /// 06: continued
+ "for generic extending another generic"); /// 06: continued
+ Expect.throws(
+ () => reflectType(reflectType(F).typeVariables[0].reflectedType, [int]));
+ Expect.throws(() => reflectType(FBounded, [int])); /// 02: ok
+ var boundedType =
+ reflectType(FBounded).typeVariables[0].upperBound.reflectedType;
+ Expect.throws(() => reflectType(boundedType, [int])); /// 02: ok
+ Expect.throws(() => reflectType(Composite, [int, int])); /// 02: ok
+
+ // Instantiation of a generic class preserves type information:
+ ClassMirror m = reflectType(A, [P]) as ClassMirror;
+ var instance = m.newInstance(const Symbol(""), []).reflectee;
+ Expect.equals(new A<P>().runtimeType, instance.runtimeType);
+}
diff --git a/tests/lib/mirrors/reflected_type_helper.dart b/tests/lib/mirrors/reflected_type_helper.dart
index e973854..bc47152 100644
--- a/tests/lib/mirrors/reflected_type_helper.dart
+++ b/tests/lib/mirrors/reflected_type_helper.dart
@@ -4,6 +4,7 @@
library test.reflected_type_helper;
+@MirrorsUsed(targets: "test.reflected_type_helper")
import 'dart:mirrors';
import 'package:expect/expect.dart';
diff --git a/tests/lib_strong/lib_strong_kernel.status b/tests/lib_strong/lib_strong_kernel.status
index dc71cf7..ccbc515 100644
--- a/tests/lib_strong/lib_strong_kernel.status
+++ b/tests/lib_strong/lib_strong_kernel.status
@@ -9,6 +9,7 @@
convert/chunked_conversion_utf83_test: DartkCompileTimeError
convert/chunked_conversion_utf85_test: DartkCompileTimeError
convert/encoding_test: DartkCompileTimeError
+convert/json_toEncodable_reviver_test: Crash # Type error in constant
convert/json_utf8_chunk_test: DartkCompileTimeError
convert/latin1_test: DartkCompileTimeError
convert/streamed_conversion_json_encode1_test: RuntimeError
@@ -171,7 +172,7 @@
html/xhr_test: DartkCompileTimeError
html/xsltprocessor_test: DartkCompileTimeError
mirrors/basic_types_in_dart_core_test: RuntimeError
-mirrors/class_mirror_location_test: Crash
+mirrors/class_mirror_location_test: RuntimeError
mirrors/constructor_kinds_test/01: RuntimeError
mirrors/constructor_kinds_test/none: RuntimeError
mirrors/constructor_optional_args_test: CompileTimeError
@@ -216,6 +217,8 @@
mirrors/library_metadata_test: RuntimeError
mirrors/library_uri_io_test: DartkCompileTimeError
mirrors/library_uri_package_test: DartkCompileTimeError
+mirrors/list_constructor_test/01: RuntimeError
+mirrors/list_constructor_test/none: RuntimeError
mirrors/metadata_constructed_constant_test: RuntimeError
mirrors/metadata_test: RuntimeError
mirrors/method_mirror_location_test: RuntimeError
@@ -253,4 +256,4 @@
mirrors/typedef_library_test: RuntimeError
mirrors/typedef_metadata_test: RuntimeError
mirrors/typedef_test: RuntimeError
-mirrors/typevariable_mirror_metadata_test: RuntimeError
\ No newline at end of file
+mirrors/typevariable_mirror_metadata_test: RuntimeError
diff --git a/tests/standalone/standalone.status b/tests/standalone/standalone.status
index 6fb01d9..76e42fb 100644
--- a/tests/standalone/standalone.status
+++ b/tests/standalone/standalone.status
@@ -88,19 +88,6 @@
# This is runtime test.
io/process_exit_negative_test: Skip
-# Issue #28236
-io/addlatexhash_test: StaticWarning
-io/http_auth_digest_test: StaticWarning
-io/http_auth_test: StaticWarning
-io/http_proxy_advanced_test: StaticWarning
-io/http_proxy_test: StaticWarning
-io/skipping_dart2js_compilations_test: StaticWarning
-io/sleep_test: StaticWarning
-io/test_harness_analyzer_test: StaticWarning
-io/test_runner_test: StaticWarning
-io/web_socket_compression_test: StaticWarning
-io/web_socket_test: StaticWarning
-
[ $compiler == dart2js ]
number_identity_test: Skip # Bigints and int/double diff. not supported.
typed_data_test: Skip # dart:typed_data support needed.
@@ -162,6 +149,9 @@
out_of_memory_test: Skip # passes on Mac, crashes on Linux
oom_error_stacktrace_test: Skip # Fails on Linux
+[ $arch == simmips ]
+io/socket_bind_test: Pass, Fail # Issue 28315
+
[ ($arch == simarm || $arch == simdbc || $arch == simdbc64) && $mode == debug && $checked ]
io/web_socket_test: Pass, Fail # Issue 26814
@@ -384,3 +374,8 @@
io/http_ipv6_test: SkipByDesign
io/socket_ipv6_test: SkipByDesign
io/socket_info_ipv6_test: SkipByDesign
+
+[ $builder_tag == asan && $arch == x64 ]
+io/directory_error_test: Fail # Issue 28350
+io/directory_fuzz_test: Fail # Issue 28350
+io/directory_list_nonexistent_test: Fail # Issue 28350
diff --git a/tests/utils/utils.status b/tests/utils/utils.status
index 1af3a26..fde7eba 100644
--- a/tests/utils/utils.status
+++ b/tests/utils/utils.status
@@ -31,9 +31,3 @@
[ $builder_tag == asan ]
recursive_import_test: Skip # Issue 27441
-
-[ $compiler == dart2analyzer ]
-# Issue #28236
-dart2js_test: StaticWarning
-dummy_compiler_test: StaticWarning
-recursive_import_test: StaticWarning
diff --git a/tools/VERSION b/tools/VERSION
index d077412..9b9676a 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 1
MINOR 22
PATCH 0
-PRERELEASE 6
+PRERELEASE 7
PRERELEASE_PATCH 0
diff --git a/tools/bots/cross-vm.py b/tools/bots/cross-vm.py
index 9865547..461123b 100644
--- a/tools/bots/cross-vm.py
+++ b/tools/bots/cross-vm.py
@@ -68,8 +68,7 @@
test_py = os.path.join('tools', 'test.py')
test_args = [sys.executable, test_py, '--progress=line', '--report',
'--time', '--compiler=none', '--runtime=vm', '--write-debug-log',
- '--write-test-outcome-log', '--mode=' + mode, '--arch=' + arch,
- '--exclude-suite=pkg']
+ '--write-test-outcome-log', '--mode=' + mode, '--arch=' + arch]
if total_shards and shard_index:
test_args.append('--shards=%s' % total_shards)
test_args.append('--shard=%s' % shard_index)
diff --git a/tools/bots/gn_tests.py b/tools/bots/gn_tests.py
index 1f44d69..2c4b428 100755
--- a/tools/bots/gn_tests.py
+++ b/tools/bots/gn_tests.py
@@ -16,7 +16,7 @@
def main(argv):
test_py = os.path.join(DART_ROOT, 'tools', 'test.py')
build_result = subprocess.call(
- ['python', test_py, '--builder-tag=no_ipv6', '--exclude-suite=pkg']
+ ['python', test_py, '--builder-tag=no_ipv6']
+ argv[1:])
if build_result != 0:
return build_result
diff --git a/tools/build.py b/tools/build.py
index 2645ef5..48062b3 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -427,6 +427,38 @@
return 'use_goma = true' in open(args_gn, 'r').read()
+# Try to start goma, but don't bail out if we can't. Instead print an error
+# message, and let the build fail with its own error messages as well.
+def EnsureGomaStarted(out_dir):
+ args_gn_path = os.path.join(out_dir, 'args.gn')
+ goma_dir = None
+ with open(args_gn_path, 'r') as fp:
+ for line in fp:
+ if 'goma_dir' in line:
+ words = line.split()
+ goma_dir = words[2][1:-1] # goma_dir = "/path/to/goma"
+ if not goma_dir:
+ print 'Could not find goma for ' + out_dir
+ return False
+ if not os.path.exists(goma_dir) or not os.path.isdir(goma_dir):
+ print 'Could not find goma at ' + goma_dir
+ return False
+ goma_ctl = os.path.join(goma_dir, 'goma_ctl.py')
+ goma_ctl_command = [
+ 'python',
+ goma_ctl,
+ 'ensure_start',
+ ]
+ process = subprocess.Popen(goma_ctl_command)
+ process.wait()
+ if process.returncode != 0:
+ print ("Tried to run goma_ctl.py, but it failed. Try running it manually: "
+ + "\n\t" + ' '.join(goma_ctl_command))
+ return False
+ return True
+
+
+
def BuildNinjaCommand(options, target, target_os, mode, arch):
out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
if ShouldRunGN(out_dir):
@@ -435,7 +467,12 @@
if options.verbose:
command += ['-v']
if UseGoma(out_dir):
- command += ['-j1000']
+ if EnsureGomaStarted(out_dir):
+ command += ['-j1000']
+ else:
+ # If we couldn't ensure that goma is started, let the build start, but
+ # slowly so we can see any helpful error messages that pop out.
+ command += ['-j1']
command += [target]
return command
diff --git a/tools/create_pkg_manifest.py b/tools/create_pkg_manifest.py
index 932f263..f9e4c3a 100755
--- a/tools/create_pkg_manifest.py
+++ b/tools/create_pkg_manifest.py
@@ -70,7 +70,7 @@
manifest.write('<?xml version="1.0" encoding="UTF-8"?>\n')
manifest.write('<manifest>\n')
manifest.write(' <projects>\n')
- for path, remote in deps.iteritems():
+ for path, remote in sorted(deps.iteritems()):
remote_components = remote.split('@')
remote_url = remote_components[0]
remote_version = remote_components[1]
diff --git a/tools/deps/dartium.deps/DEPS b/tools/deps/dartium.deps/DEPS
index 6b2e0f6..24fd5be 100644
--- a/tools/deps/dartium.deps/DEPS
+++ b/tools/deps/dartium.deps/DEPS
@@ -9,7 +9,7 @@
vars.update({
"dartium_chromium_commit": "7558afb6379171d7f96b2db68ae9d2b64b2c5544",
- "dartium_webkit_commit": "e46ac6cf905ae6be30852fbee231cfd385c24420",
+ "dartium_webkit_commit": "cdb44f3ddd32f2594e77ef26cd806891597cc1d9",
"chromium_base_revision": "338390",
# We use mirrors of all github repos to guarantee reproducibility and
diff --git a/tools/dom/scripts/generate_blink_file.py b/tools/dom/scripts/generate_blink_file.py
index dee266c..2b119ed 100644
--- a/tools/dom/scripts/generate_blink_file.py
+++ b/tools/dom/scripts/generate_blink_file.py
@@ -96,8 +96,10 @@
*/
library dart.dom._blink;
+import 'dart:async';
import 'dart:js' as js;
import 'dart:html' show DomException;
+import 'dart:_internal' as internal;
// This is a place to put custom renames if we need them.
final resolverMap = {
};
@@ -127,6 +129,15 @@
static register(document, tag, customType, extendsTagName) native "Utils_register";
+ // Below code sets up VMLibraryHooks for resolvePackageUri.
+ static Uri resolvePackageUri(Uri packageUri) native "Utils_resolvePackageUri";
+ static Future<Uri> _resolvePackageUriFuture(Uri packageUri) async {
+ return resolvePackageUri(packageUri);
+ }
+ static void _setupHooks() {
+ internal.VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
+ }
+
// Defines an interceptor if there is an appropriate JavaScript prototype to define it on.
// In any case, returns a typed JS wrapper compatibile with dart:html and the new
// typed JS Interop.
diff --git a/tools/gn.py b/tools/gn.py
index 24e9380..1e5120b 100755
--- a/tools/gn.py
+++ b/tools/gn.py
@@ -16,6 +16,41 @@
SCRIPT_DIR = os.path.dirname(sys.argv[0])
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
+# Environment variables for default settings.
+DART_USE_ASAN = "DART_USE_ASAN" # Use instead of --asan
+DART_USE_MSAN = "DART_USE_MSAN" # Use instead of --msan
+DART_USE_TSAN = "DART_USE_TSAN" # Use instead of --tsan
+DART_USE_WHEEZY = "DART_USE_WHEEZY" # Use instread of --wheezy
+DART_USE_TOOLCHAIN = "DART_USE_TOOLCHAIN" # Use instread of --toolchain-prefix
+DART_USE_SYSROOT = "DART_USE_SYSROOT" # Use instead of --target-sysroot
+
+def use_asan():
+ return DART_USE_ASAN in os.environ
+
+
+def use_msan():
+ return DART_USE_MSAN in os.environ
+
+
+def use_tsan():
+ return DART_USE_TSAN in os.environ
+
+
+def use_wheezy():
+ return DART_USE_WHEEZY in os.environ
+
+
+def toolchain_prefix(args):
+ if args.toolchain_prefix:
+ return args.toolchain_prefix
+ return os.environ.get(DART_USE_TOOLCHAIN)
+
+
+def target_sysroot(args):
+ if args.target_sysroot:
+ return args.target_sysroot
+ return os.environ.get(DART_USE_SYSROOT)
+
def get_out_dir(mode, arch, target_os):
return utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
@@ -64,6 +99,16 @@
return host_os
+# Where string_map is formatted as X1=Y1,X2=Y2 etc.
+# If key is X1, returns Y1.
+def parse_string_map(key, string_map):
+ for m in string_map.split(','):
+ l = m.split('=')
+ if l[0] == key:
+ return l[1]
+ return None
+
+
def to_gn_args(args, mode, arch, target_os):
gn_args = {}
@@ -137,11 +182,13 @@
if gn_args['target_os'] == 'linux' and args.wheezy:
gn_args['dart_use_wheezy_sysroot'] = True
else:
- if args.target_sysroot:
- gn_args['target_sysroot'] = args.target_sysroot
+ sysroot = target_sysroot(args)
+ if sysroot:
+ gn_args['target_sysroot'] = parse_string_map(arch, sysroot)
- if args.toolchain_prefix:
- gn_args['toolchain_prefix'] = args.toolchain_prefix
+ toolchain = toolchain_prefix(args)
+ if toolchain:
+ gn_args['toolchain_prefix'] = parse_string_map(arch, toolchain)
goma_dir = os.environ.get('GOMA_DIR')
goma_home_dir = os.path.join(os.getenv('HOME', ''), 'goma')
@@ -219,25 +266,6 @@
return '--ide=json'
-# Environment variables for default settings.
-DART_USE_ASAN = "DART_USE_ASAN"
-DART_USE_MSAN = "DART_USE_MSAN"
-DART_USE_TSAN = "DART_USE_TSAN"
-DART_USE_WHEEZY = "DART_USE_WHEEZY"
-
-def use_asan():
- return DART_USE_ASAN in os.environ
-
-def use_msan():
- return DART_USE_MSAN in os.environ
-
-def use_tsan():
- return DART_USE_TSAN in os.environ
-
-def use_wheezy():
- return DART_USE_WHEEZY in os.environ
-
-
def parse_args(args):
args = args[1:]
parser = argparse.ArgumentParser(
@@ -304,10 +332,10 @@
action='store_false')
other_group.add_argument('--target-sysroot', '-s',
type=str,
- help='Path to the toolchain sysroot')
+ help='Comma-separated list of arch=/path/to/sysroot mappings')
other_group.add_argument('--toolchain-prefix', '-t',
type=str,
- help='Path to the toolchain prefix')
+ help='Comma-separated list of arch=/path/to/toolchain-prefix mappings')
other_group.add_argument('--tsan',
help='Build with TSAN',
default=use_tsan(),
diff --git a/tools/testing/dart/test_options.dart b/tools/testing/dart/test_options.dart
index ed54fc1..b9ad0f4 100644
--- a/tools/testing/dart/test_options.dart
+++ b/tools/testing/dart/test_options.dart
@@ -23,7 +23,6 @@
'benchmark_smoke',
'utils',
'lib',
- 'pkg',
'analyze_library',
'service',
'kernel',
@@ -485,7 +484,7 @@
'Exclude suites from default selector, only works when no'
' selector has been specified on the command line',
['--exclude-suite'],
- defaultTestSelectors,
+ [],
null),
new _TestOptionSpecification(
'skip-compilation',
@@ -742,7 +741,7 @@
}
if (config['ie'] && Platform.operatingSystem != 'windows') {
isValid = false;
- print("Warning cannot run Internet Explorer on non-Windows operating"
+ print("Warning: cannot run Internet Explorer on non-Windows operating"
" system.");
}
if (config['shard'] < 1 || config['shard'] > config['shards']) {
@@ -836,8 +835,7 @@
if (selectors.contains(exclude)) {
selectors.remove(exclude);
} else {
- print("Error: default selectors does not contain $exclude");
- exit(1);
+ print("Warning: default selectors does not contain $exclude");
}
}
}