Version 2.0.0-dev.25.0
Merge commit '392062c617a3f7b72ded5f78b3254fb52eb16cb9' into dev
diff --git a/DEPS b/DEPS
index 9b0a5cc..94c6c45 100644
--- a/DEPS
+++ b/DEPS
@@ -119,7 +119,7 @@
"pub_semver_tag": "@1.3.2",
"quiver_tag": "@0.28.0",
"resource_rev":"@af5a5bf65511943398146cf146e466e5f0b95cb9",
- "root_certificates_rev": "@a4c7c6f23a664a37bc1b6f15a819e3f2a292791a",
+ "root_certificates_rev": "@16ef64be64c7dfdff2b9f4b910726e635ccc519e",
"shelf_static_rev": "@3558aa35a0d2f0f35868c3fd64b258e140db0122",
"shelf_packages_handler_tag": "@1.0.3",
"shelf_tag": "@0.7.1",
diff --git a/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart b/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart
index f4d1e62..1265b6b 100644
--- a/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart
+++ b/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart
@@ -24,10 +24,14 @@
/**
* A comparator that can be used to sort assists by their relevance. The most
* relevant assists will be sorted before assists with a lower relevance.
+ * Assists with the same relevance are sorted alphabetically.
*/
- static final Comparator<Assist> SORT_BY_RELEVANCE =
- (Assist firstAssist, Assist secondAssist) =>
- firstAssist.kind.priority - secondAssist.kind.priority;
+ static final Comparator<Assist> SORT_BY_RELEVANCE = (Assist a, Assist b) {
+ if (a.kind.priority != b.kind.priority) {
+ return a.kind.priority - b.kind.priority;
+ }
+ return a.change.message.compareTo(b.change.message);
+ };
/**
* A description of the assist being proposed.
diff --git a/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart b/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart
index 91a813f..e0af23c 100644
--- a/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart
+++ b/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart
@@ -24,11 +24,15 @@
/**
* A comparator that can be used to sort fixes by their relevance. The most
- * relevant fixes will be sorted before fixes with a lower relevance.
+ * relevant fixes will be sorted before fixes with a lower relevance. Fixes
+ * with the same relevance are sorted alphabetically.
*/
- static final Comparator<Fix> SORT_BY_RELEVANCE =
- (Fix firstFix, Fix secondFix) =>
- firstFix.kind.priority - secondFix.kind.priority;
+ static final Comparator<Fix> SORT_BY_RELEVANCE = (Fix a, Fix b) {
+ if (a.kind.priority != b.kind.priority) {
+ return a.kind.priority - b.kind.priority;
+ }
+ return a.change.message.compareTo(b.change.message);
+ };
/**
* A description of the fix being proposed.
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 43aab94..8174780 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -1295,7 +1295,7 @@
FlutterService.OUTLINE, path)) {
_runDelayed(() {
sendFlutterNotificationOutline(
- analysisServer, path, result.lineInfo, unit);
+ analysisServer, path, result.content, result.lineInfo, unit);
});
}
// TODO(scheglov) Implement notifications for AnalysisService.IMPLEMENTED.
diff --git a/pkg/analysis_server/lib/src/flutter/flutter_notifications.dart b/pkg/analysis_server/lib/src/flutter/flutter_notifications.dart
index 2b6dd30..f526036 100644
--- a/pkg/analysis_server/lib/src/flutter/flutter_notifications.dart
+++ b/pkg/analysis_server/lib/src/flutter/flutter_notifications.dart
@@ -9,9 +9,10 @@
import 'package:analyzer/src/generated/source.dart';
void sendFlutterNotificationOutline(AnalysisServer server, String file,
- LineInfo lineInfo, CompilationUnit dartUnit) {
+ String content, LineInfo lineInfo, CompilationUnit dartUnit) {
_sendNotification(server, () {
- var computer = new FlutterOutlineComputer(file, lineInfo, dartUnit);
+ var computer =
+ new FlutterOutlineComputer(file, content, lineInfo, dartUnit);
protocol.FlutterOutline outline = computer.compute();
// send notification
var params = new protocol.FlutterOutlineParams(file, outline);
diff --git a/pkg/analysis_server/lib/src/flutter/flutter_outline_computer.dart b/pkg/analysis_server/lib/src/flutter/flutter_outline_computer.dart
index 937fee9..89561f7 100644
--- a/pkg/analysis_server/lib/src/flutter/flutter_outline_computer.dart
+++ b/pkg/analysis_server/lib/src/flutter/flutter_outline_computer.dart
@@ -15,13 +15,14 @@
/// Computer for Flutter specific outlines.
class FlutterOutlineComputer {
final String file;
+ final String content;
final LineInfo lineInfo;
final CompilationUnit unit;
final TypeProvider typeProvider;
final List<protocol.FlutterOutline> _depthFirstOrder = [];
- FlutterOutlineComputer(this.file, this.lineInfo, this.unit)
+ FlutterOutlineComputer(this.file, this.content, this.lineInfo, this.unit)
: typeProvider = unit.element.context.typeProvider;
protocol.FlutterOutline compute() {
@@ -44,22 +45,38 @@
if (argument is NamedExpression) {
argument = (argument as NamedExpression).expression;
}
- String label = argument.toString();
+
+ String name = parameter.displayName;
+
+ String label = content.substring(argument.offset, argument.end);
+ if (label.contains('\n')) {
+ label = '…';
+ }
+
if (argument is BooleanLiteral) {
- attributes.add(new protocol.FlutterOutlineAttribute(
- parameter.displayName, label,
+ attributes.add(new protocol.FlutterOutlineAttribute(name, label,
literalValueBoolean: argument.value));
} else if (argument is IntegerLiteral) {
- attributes.add(new protocol.FlutterOutlineAttribute(
- parameter.displayName, label,
+ attributes.add(new protocol.FlutterOutlineAttribute(name, label,
literalValueInteger: argument.value));
} else if (argument is StringLiteral) {
- attributes.add(new protocol.FlutterOutlineAttribute(
- parameter.displayName, label,
+ attributes.add(new protocol.FlutterOutlineAttribute(name, label,
literalValueString: argument.stringValue));
} else {
- attributes.add(
- new protocol.FlutterOutlineAttribute(parameter.displayName, label));
+ if (argument is FunctionExpression) {
+ bool hasParameters = argument.parameters != null &&
+ argument.parameters.parameters.isNotEmpty;
+ if (argument.body is ExpressionFunctionBody) {
+ label = hasParameters ? '(…) => …' : '() => …';
+ } else {
+ label = hasParameters ? '(…) { … }' : '() { … }';
+ }
+ } else if (argument is ListLiteral) {
+ label = '[…]';
+ } else if (argument is MapLiteral) {
+ label = '{…}';
+ }
+ attributes.add(new protocol.FlutterOutlineAttribute(name, label));
}
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
index 4f58799..d8523a7 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
@@ -14,6 +14,7 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/resolver/inheritance_manager.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
import 'package:analyzer_plugin/utilities/range_factory.dart';
@@ -91,14 +92,16 @@
if (completion == null || completion.length == 0) {
return null;
}
+
+ SourceRange selectionRange = _computeSelectionRange(completion);
String displayText =
displayTextBuffer.isNotEmpty ? displayTextBuffer.toString() : null;
CompletionSuggestion suggestion = new CompletionSuggestion(
CompletionSuggestionKind.OVERRIDE,
DART_RELEVANCE_HIGH,
completion,
- targetId.offset,
- 0,
+ selectionRange.offset,
+ selectionRange.length,
element.isDeprecated,
false,
displayText: displayText);
@@ -123,6 +126,26 @@
}
/**
+ * Compute a selection range for the given completion.
+ */
+ SourceRange _computeSelectionRange(String completion) {
+ // TODO(pq): consider moving this into ChangeBuilder.
+ // { return null; } or => null;
+ int offset = completion.indexOf('null;');
+ if (offset != -1) {
+ return new SourceRange(offset, 4);
+ }
+ // { }
+ offset = completion.indexOf('{');
+ if (offset != -1) {
+ return new SourceRange(offset + 2, 0);
+ }
+
+ // Default.
+ return new SourceRange(0, 0);
+ }
+
+ /**
* If the target looks like a partial identifier inside a class declaration
* then return that identifier, otherwise return `null`.
*/
diff --git a/pkg/analysis_server/lib/src/services/correction/assist.dart b/pkg/analysis_server/lib/src/services/correction/assist.dart
index accff73..c0bb8b1 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist.dart
@@ -31,110 +31,130 @@
* An enumeration of possible assist kinds.
*/
class DartAssistKind {
- static const ADD_PART_DIRECTIVE =
- const AssistKind('ADD_PART_DIRECTIVE', 30, "Add 'part' directive");
- static const ADD_TYPE_ANNOTATION =
- const AssistKind('ADD_TYPE_ANNOTATION', 30, "Add type annotation");
+ static const ADD_PART_DIRECTIVE = const AssistKind(
+ 'dart.assist.addPartDirective', 30, "Add 'part' directive");
+ static const ADD_TYPE_ANNOTATION = const AssistKind(
+ 'dart.assist.addTypeAnnotation', 30, "Add type annotation");
static const ASSIGN_TO_LOCAL_VARIABLE = const AssistKind(
- 'ASSIGN_TO_LOCAL_VARIABLE', 30, "Assign value to new local variable");
+ 'dart.assist.assignToVariable', 30, "Assign value to new local variable");
static const CONVERT_DOCUMENTATION_INTO_BLOCK = const AssistKind(
- 'CONVERT_DOCUMENTATION_INTO_BLOCK',
+ 'dart.assist.convert.blockComment',
30,
- "Convert into block documentation comment");
+ "Convert to block documentation comment");
static const CONVERT_DOCUMENTATION_INTO_LINE = const AssistKind(
- 'CONVERT_DOCUMENTATION_INTO_LINE',
+ 'dart.assist.convert.lineComment',
30,
- "Convert into line documentation comment");
- static const CONVERT_FLUTTER_CHILD =
- const AssistKind('CONVERT_FLUTTER_CHILD', 30, "Convert to children:");
+ "Convert to line documentation comment");
static const CONVERT_INTO_ASYNC_BODY = const AssistKind(
- 'CONVERT_INTO_ASYNC_BODY', 30, "Convert into async function body");
+ 'dart.assist.convert.bodyToAsync', 30, "Convert to async function body");
static const CONVERT_INTO_BLOCK_BODY = const AssistKind(
- 'CONVERT_INTO_BLOCK_BODY', 30, "Convert into block body");
+ 'dart.assist.convert.bodyToBlock', 30, "Convert to block body");
static const CONVERT_INTO_EXPRESSION_BODY = const AssistKind(
- 'CONVERT_INTO_EXPRESSION_BODY', 30, "Convert into expression body");
+ 'dart.assist.convert.bodyToExpression', 30, "Convert to expression body");
static const CONVERT_INTO_FOR_INDEX = const AssistKind(
- 'CONVERT_INTO_FOR_INDEX', 30, "Convert into for-index loop");
+ 'dart.assist.convert.forEachToForIndex', 30, "Convert to for-index loop");
static const CONVERT_INTO_FINAL_FIELD = const AssistKind(
- 'CONVERT_INTO_FINAL_FIELD', 30, "Convert into final field");
- static const CONVERT_INTO_GETTER =
- const AssistKind('CONVERT_INTO_GETTER', 30, "Convert into getter");
+ 'dart.assist.convert.getterToFinalField', 30, "Convert to final field");
+ static const CONVERT_INTO_GENERIC_FUNCTION_SYNTAX = const AssistKind(
+ 'dart.assist.convert.toGenericFunctionSyntax',
+ 30,
+ "Convert into 'Function' syntax");
+ static const CONVERT_INTO_GETTER = const AssistKind(
+ 'dart.assist.convert.finalFieldToGetter', 30, "Convert to getter");
static const CONVERT_INTO_IS_NOT =
- const AssistKind('CONVERT_INTO_IS_NOT', 30, "Convert into is!");
+ const AssistKind('dart.assist.convert.isNot', 30, "Convert to is!");
static const CONVERT_INTO_IS_NOT_EMPTY = const AssistKind(
- 'CONVERT_INTO_IS_NOT_EMPTY', 30, "Convert into 'isNotEmpty'");
- static const CONVERT_PART_OF_TO_URI =
- const AssistKind('CONVERT_PART_OF_TO_URI', 30, "Convert to use a URI");
+ 'dart.assist.convert.isNotEmpty', 30, "Convert to 'isNotEmpty'");
+ static const CONVERT_PART_OF_TO_URI = const AssistKind(
+ 'dart.assist.convert.partOfToPartUri', 30, "Convert to use a URI");
static const CONVERT_TO_FIELD_PARAMETER = const AssistKind(
- 'CONVERT_TO_FIELD_PARAMETER', 30, "Convert to field formal parameter");
+ 'dart.assist.convert.toConstructorFieldParameter',
+ 30,
+ "Convert to field formal parameter");
static const CONVERT_TO_NORMAL_PARAMETER = const AssistKind(
- 'CONVERT_TO_NORMAL_PARAMETER', 30, "Convert to normal parameter");
+ 'dart.assist.convert.toConstructorNormalParameter',
+ 30,
+ "Convert to normal parameter");
static const ENCAPSULATE_FIELD =
- const AssistKind('ENCAPSULATE_FIELD', 30, "Encapsulate field");
+ const AssistKind('dart.assist.encapsulateField', 30, "Encapsulate field");
static const EXCHANGE_OPERANDS =
- const AssistKind('EXCHANGE_OPERANDS', 30, "Exchange operands");
- static const EXTRACT_CLASS =
- const AssistKind('EXTRACT_CLASS', 30, "Extract class into file '{0}'");
+ const AssistKind('dart.assist.exchangeOperands', 30, "Exchange operands");
+ static const EXTRACT_CLASS = const AssistKind(
+ 'dart.assist.extractClass', 30, "Extract class into file '{0}'");
+ static const FLUTTER_CONVERT_TO_CHILDREN = const AssistKind(
+ 'dart.assist.flutter.convert.childToChildren',
+ 30,
+ "Convert to children:");
static const FLUTTER_CONVERT_TO_STATEFUL_WIDGET = const AssistKind(
- "FLUTTER_CONVERT_TO_STATEFUL_WIDGET", 30, "Convert to StatefulWidget");
- static const FLUTTER_REPLACE_WITH_CHILDREN = const AssistKind(
- "FLUTTER_REPLACE_WITH_CHILDREN", 30, "Replace with children");
- static const IMPORT_ADD_SHOW =
- const AssistKind('IMPORT_ADD_SHOW', 30, "Add explicit 'show' combinator");
+ 'dart.assist.flutter.convert.toStatefulWidget',
+ 30,
+ "Convert to StatefulWidget");
+ static const FLUTTER_MOVE_DOWN =
+ const AssistKind('dart.assist.flutter.move.down', 30, "Move widget down");
+ static const FLUTTER_MOVE_UP =
+ const AssistKind('dart.assist.flutter.move.up', 30, "Move widget up");
+ static const FLUTTER_REMOVE_WIDGET =
+ const AssistKind('dart.assist.flutter.removeWidget', 30, "Remove widget");
+ static const FLUTTER_SWAP_WITH_CHILD = const AssistKind(
+ 'dart.assist.flutter.swap.withChild', 30, "Swap with child");
+ static const FLUTTER_SWAP_WITH_PARENT = const AssistKind(
+ 'dart.assist.flutter.swap.withParent', 30, "Swap with parent");
+ static const FLUTTER_WRAP_CENTER =
+ const AssistKind('dart.assist.flutter.wrap.center', 30, "Center widget");
+ static const FLUTTER_WRAP_COLUMN = const AssistKind(
+ 'dart.assist.flutter.wrap.column', 30, "Wrap with Column");
+ static const FLUTTER_WRAP_GENERIC = const AssistKind(
+ 'dart.assist.flutter.wrap.generic', 30, "Wrap with new widget");
+ static const FLUTTER_WRAP_PADDING = const AssistKind(
+ 'dart.assist.flutter.wrap.padding', 30, "Add widget padding");
+ static const FLUTTER_WRAP_ROW =
+ const AssistKind('dart.assist.flutter.wrap.row', 30, "Wrap with Row");
+ static const IMPORT_ADD_SHOW = const AssistKind(
+ 'dart.assist.addShowCombinator', 30, "Add explicit 'show' combinator");
static const INTRODUCE_LOCAL_CAST_TYPE = const AssistKind(
- 'INTRODUCE_LOCAL_CAST_TYPE', 30, "Introduce new local with tested type");
+ 'dart.assist.introduceLocalCast',
+ 30,
+ "Introduce new local with tested type");
static const INVERT_IF_STATEMENT =
- const AssistKind('INVERT_IF_STATEMENT', 30, "Invert 'if' statement");
- static const JOIN_IF_WITH_INNER = const AssistKind('JOIN_IF_WITH_INNER', 30,
+ const AssistKind('dart.assist.invertIf', 30, "Invert 'if' statement");
+ static const JOIN_IF_WITH_INNER = const AssistKind(
+ 'dart.assist.joinWithInnerIf',
+ 30,
"Join 'if' statement with inner 'if' statement");
- static const JOIN_IF_WITH_OUTER = const AssistKind('JOIN_IF_WITH_OUTER', 30,
+ static const JOIN_IF_WITH_OUTER = const AssistKind(
+ 'dart.assist.joinWithOuterIf',
+ 30,
"Join 'if' statement with outer 'if' statement");
static const JOIN_VARIABLE_DECLARATION = const AssistKind(
- 'JOIN_VARIABLE_DECLARATION', 30, "Join variable declaration");
- static const MOVE_FLUTTER_WIDGET_DOWN =
- const AssistKind("MOVE_FLUTTER_WIDGET_DOWN", 30, "Move widget down");
- static const MOVE_FLUTTER_WIDGET_UP =
- const AssistKind("MOVE_FLUTTER_WIDGET_UP", 30, "Move widget up");
- static const REPARENT_FLUTTER_LIST =
- const AssistKind("REPARENT_FLUTTER_LIST", 30, "Wrap with new widget");
- static const REPARENT_FLUTTER_WIDGET =
- const AssistKind("REPARENT_FLUTTER_WIDGET", 30, "Wrap with new widget");
- static const REPARENT_FLUTTER_WIDGET_CENTER =
- const AssistKind("REPARENT_FLUTTER_WIDGET_CENTER", 29, "Center widget");
- static const REPARENT_FLUTTER_WIDGET_PADDING = const AssistKind(
- "REPARENT_FLUTTER_WIDGET_PADDING", 29, "Add widget padding");
- static const REPARENT_FLUTTER_WIDGETS_COLUMN = const AssistKind(
- "REPARENT_FLUTTER_WIDGETS_COLUMN", 29, "Wrap with Column");
- static const REPARENT_FLUTTER_WIDGETS_ROW =
- const AssistKind("REPARENT_FLUTTER_WIDGETS_ROW", 29, "Wrap with Row");
- static const REMOVE_TYPE_ANNOTATION =
- const AssistKind('REMOVE_TYPE_ANNOTATION', 29, "Remove type annotation");
+ 'dart.assist.joinVariableDeclaration', 30, "Join variable declaration");
+ static const REMOVE_TYPE_ANNOTATION = const AssistKind(
+ 'dart.assist.removeTypeAnnotation', 29, "Remove type annotation");
static const REPLACE_CONDITIONAL_WITH_IF_ELSE = const AssistKind(
- 'REPLACE_CONDITIONAL_WITH_IF_ELSE',
+ 'dart.assist.convert.conditionalToIfElse',
30,
"Replace conditional with 'if-else'");
static const REPLACE_IF_ELSE_WITH_CONDITIONAL = const AssistKind(
- 'REPLACE_IF_ELSE_WITH_CONDITIONAL',
+ 'dart.assist.convert.ifElseToConditional',
30,
"Replace 'if-else' with conditional ('c ? x : y')");
- static const SPLIT_AND_CONDITION =
- const AssistKind('SPLIT_AND_CONDITION', 30, "Split && condition");
+ static const SPLIT_AND_CONDITION = const AssistKind(
+ 'dart.assist.splitIfConjunction', 30, "Split && condition");
static const SPLIT_VARIABLE_DECLARATION = const AssistKind(
- 'SPLIT_VARIABLE_DECLARATION', 30, "Split variable declaration");
+ 'dart.assist.splitVariableDeclaration', 30, "Split variable declaration");
static const SURROUND_WITH_BLOCK =
- const AssistKind('SURROUND_WITH_BLOCK', 30, "Surround with block");
+ const AssistKind('dart.assist.surround.block', 22, "Surround with block");
static const SURROUND_WITH_DO_WHILE = const AssistKind(
- 'SURROUND_WITH_DO_WHILE', 30, "Surround with 'do-while'");
- static const SURROUND_WITH_FOR =
- const AssistKind('SURROUND_WITH_FOR', 30, "Surround with 'for'");
- static const SURROUND_WITH_FOR_IN =
- const AssistKind('SURROUND_WITH_FOR_IN', 30, "Surround with 'for-in'");
+ 'dart.assist.surround.doWhile', 27, "Surround with 'do-while'");
+ static const SURROUND_WITH_FOR = const AssistKind(
+ 'dart.assist.surround.forEach', 26, "Surround with 'for'");
+ static const SURROUND_WITH_FOR_IN = const AssistKind(
+ 'dart.assist.surround.forIn', 25, "Surround with 'for-in'");
static const SURROUND_WITH_IF =
- const AssistKind('SURROUND_WITH_IF', 30, "Surround with 'if'");
+ const AssistKind('dart.assist.surround.if', 23, "Surround with 'if'");
static const SURROUND_WITH_TRY_CATCH = const AssistKind(
- 'SURROUND_WITH_TRY_CATCH', 30, "Surround with 'try-catch'");
+ 'dart.assist.surround.tryCatch', 28, "Surround with 'try-catch'");
static const SURROUND_WITH_TRY_FINALLY = const AssistKind(
- 'SURROUND_WITH_TRY_FINALLY', 30, "Surround with 'try-finally'");
- static const SURROUND_WITH_WHILE =
- const AssistKind('SURROUND_WITH_WHILE', 30, "Surround with 'while'");
+ 'dart.assist.surround.tryFinally', 29, "Surround with 'try-finally'");
+ static const SURROUND_WITH_WHILE = const AssistKind(
+ 'dart.assist.surround.while', 24, "Surround with 'while'");
}
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 3ba249c..44cf710 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -132,19 +132,26 @@
await _addProposal_convertToAsyncFunctionBody();
await _addProposal_convertToBlockFunctionBody();
await _addProposal_convertToExpressionFunctionBody();
- await _addProposal_convertFlutterChild();
await _addProposal_convertPartOfToUri();
await _addProposal_convertToForIndexLoop();
+ await _addProposal_convertToGenericFunctionSyntax();
await _addProposal_convertToIsNot_onIs();
await _addProposal_convertToIsNot_onNot();
await _addProposal_convertToIsNotEmpty();
await _addProposal_convertToFieldParameter();
await _addProposal_convertToNormalParameter();
- await _addProposal_convertToStatefulWidget();
await _addProposal_encapsulateField();
await _addProposal_exchangeOperands();
- await _addProposal_flutterReplaceWithChild();
- await _addProposal_flutterReplaceWithChildren();
+ await _addProposal_flutterConvertToChildren();
+ await _addProposal_flutterConvertToStatefulWidget();
+ await _addProposal_flutterMoveWidgetDown();
+ await _addProposal_flutterMoveWidgetUp();
+ await _addProposal_flutterRemoveWidget_singleChild();
+ await _addProposal_flutterRemoveWidget_multipleChildren();
+ await _addProposal_flutterSwapWithChild();
+ await _addProposal_flutterSwapWithParent();
+ await _addProposal_flutterWrapWidget();
+ await _addProposal_flutterWrapWidgets();
await _addProposal_importAddShow();
await _addProposal_introduceLocalTestedType();
await _addProposal_invertIf();
@@ -152,12 +159,8 @@
await _addProposal_joinIfStatementOuter();
await _addProposal_joinVariableDeclaration_onAssignment();
await _addProposal_joinVariableDeclaration_onDeclaration();
- await _addProposal_moveFlutterWidgetDown();
- await _addProposal_moveFlutterWidgetUp();
await _addProposal_removeTypeAnnotation();
await _addProposal_reparentFlutterList();
- await _addProposal_reparentFlutterWidget();
- await _addProposal_reparentFlutterWidgets();
await _addProposal_replaceConditionalWithIfElse();
await _addProposal_replaceIfElseWithConditional();
await _addProposal_splitAndCondition();
@@ -208,6 +211,7 @@
_coverageMarker();
return;
}
+ change.id = kind.id;
change.message = formatList(kind.message, args);
assists.add(new Assist(kind, change));
}
@@ -505,50 +509,6 @@
changeBuilder, DartAssistKind.CONVERT_DOCUMENTATION_INTO_LINE);
}
- Future<Null> _addProposal_convertFlutterChild() async {
- NamedExpression namedExp;
- // Allow assist to activate from either the new-expr or the child: arg.
- if (node is SimpleIdentifier &&
- node.parent is Label &&
- node.parent.parent is NamedExpression) {
- namedExp = node.parent.parent as NamedExpression;
- if ((node as SimpleIdentifier).name != 'child' ||
- namedExp.expression == null) {
- return;
- }
- if (namedExp.parent?.parent is! InstanceCreationExpression) {
- return;
- }
- InstanceCreationExpression newExpr = namedExp.parent.parent;
- if (newExpr == null || !flutter.isWidgetCreation(newExpr)) {
- return;
- }
- } else {
- InstanceCreationExpression newExpr = flutter.identifyNewExpression(node);
- if (newExpr == null || !flutter.isWidgetCreation(newExpr)) {
- _coverageMarker();
- return;
- }
- namedExp = flutter.findChildArgument(newExpr);
- if (namedExp == null || namedExp.expression == null) {
- _coverageMarker();
- return;
- }
- }
- InstanceCreationExpression childArg =
- flutter.getChildWidget(namedExp, false);
- if (childArg == null) {
- _coverageMarker();
- return;
- }
- DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
- await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
- _convertFlutterChildToChildren(childArg, namedExp, eol, utils.getNodeText,
- utils.getLinePrefix, utils.getIndent, utils.getText, builder);
- });
- _addAssistFromBuilder(changeBuilder, DartAssistKind.CONVERT_FLUTTER_CHILD);
- }
-
Future<Null> _addProposal_convertIntoFinalField() async {
// Find the enclosing getter.
MethodDeclaration getter;
@@ -980,6 +940,24 @@
_addAssistFromBuilder(changeBuilder, DartAssistKind.CONVERT_INTO_FOR_INDEX);
}
+ Future<Null> _addProposal_convertToGenericFunctionSyntax() async {
+ AstNode node = this.node;
+ while (node != null) {
+ if (node is FunctionTypeAlias) {
+ await _convertFunctionTypeAliasToGenericTypeAlias(node);
+ return;
+ } else if (node is FunctionTypedFormalParameter) {
+ await _convertFunctionTypedFormalParameterToSimpleFormalParameter(node);
+ return;
+ } else if (node is FormalParameterList) {
+ // It would be confusing for this assist to alter a surrounding context
+ // when the selection is inside a parameter list.
+ return;
+ }
+ node = node.parent;
+ }
+ }
+
Future<Null> _addProposal_convertToIsNot_onIs() async {
// may be child of "is"
AstNode node = this.node;
@@ -1182,100 +1160,6 @@
}
}
- Future<Null> _addProposal_convertToStatefulWidget() async {
- ClassDeclaration widgetClass =
- node.getAncestor((n) => n is ClassDeclaration);
- TypeName superclass = widgetClass?.extendsClause?.superclass;
- if (widgetClass == null || superclass == null) {
- _coverageMarker();
- return;
- }
-
- // Don't spam, activate only from the `class` keyword to the class body.
- if (selectionOffset < widgetClass.classKeyword.offset ||
- selectionOffset > widgetClass.leftBracket.end) {
- _coverageMarker();
- return;
- }
-
- // Find the build() method.
- MethodDeclaration buildMethod;
- for (var member in widgetClass.members) {
- if (member is MethodDeclaration &&
- member.name.name == 'build' &&
- member.parameters != null &&
- member.parameters.parameters.length == 1) {
- buildMethod = member;
- break;
- }
- }
- if (buildMethod == null) {
- _coverageMarker();
- return;
- }
-
- // Must be a StatelessWidget subclasses.
- ClassElement widgetClassElement = widgetClass.element;
- if (!flutter.isExactlyStatelessWidgetType(widgetClassElement.supertype)) {
- _coverageMarker();
- return;
- }
-
- String widgetName = widgetClassElement.displayName;
- String stateName = widgetName + 'State';
-
- var buildLinesRange = utils.getLinesRange(range.node(buildMethod));
- var buildText = utils.getRangeText(buildLinesRange);
-
- // Update the build() text to insert `widget.` before references to
- // the widget class members.
- final List<SourceEdit> buildTextEdits = [];
- buildMethod.body.accept(new _SimpleIdentifierRecursiveAstVisitor((node) {
- if (node.staticElement?.enclosingElement == widgetClassElement) {
- var offset = node.offset - buildLinesRange.offset;
- AstNode parent = node.parent;
- if (parent is InterpolationExpression &&
- parent.leftBracket.type ==
- TokenType.STRING_INTERPOLATION_IDENTIFIER) {
- buildTextEdits.add(new SourceEdit(offset, 0, '{widget.'));
- buildTextEdits.add(new SourceEdit(offset + node.length, 0, '}'));
- } else {
- buildTextEdits.add(new SourceEdit(offset, 0, 'widget.'));
- }
- }
- }));
- buildText = SourceEdit.applySequence(buildText, buildTextEdits.reversed);
-
- var statefulWidgetClass =
- await _getExportedClass(flutter.WIDGETS_LIBRARY_URI, 'StatefulWidget');
- var stateClass =
- await _getExportedClass(flutter.WIDGETS_LIBRARY_URI, 'State');
- var stateType = stateClass.type.instantiate([widgetClassElement.type]);
-
- DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
- await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) async {
- builder.addReplacement(range.node(superclass), (builder) {
- builder.writeType(statefulWidgetClass.type);
- });
- builder.addReplacement(buildLinesRange, (builder) {
- builder.writeln(' @override');
- builder.writeln(' $stateName createState() {');
- builder.writeln(' return new $stateName();');
- builder.writeln(' }');
- });
- builder.addInsertion(widgetClass.end, (builder) {
- builder.writeln();
- builder.writeln();
- builder.writeClassDeclaration(stateName, superclass: stateType,
- membersWriter: () {
- builder.write(buildText);
- });
- });
- });
- _addAssistFromBuilder(
- changeBuilder, DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
- }
-
Future<Null> _addProposal_encapsulateField() async {
// find FieldDeclaration
FieldDeclaration fieldDeclaration =
@@ -1408,33 +1292,186 @@
_addAssistFromBuilder(changeBuilder, DartAssistKind.EXCHANGE_OPERANDS);
}
- Future<Null> _addProposal_flutterReplaceWithChild() async {
- var widgetCreation = flutter.identifyNewExpression(node);
- if (widgetCreation == null) {
- return;
+ Future<Null> _addProposal_flutterConvertToChildren() async {
+ // Find "child: widget" under selection.
+ NamedExpression namedExp;
+ {
+ AstNode node = this.node;
+ AstNode parent = node?.parent;
+ AstNode parent2 = parent?.parent;
+ if (node is SimpleIdentifier &&
+ parent is Label &&
+ parent2 is NamedExpression &&
+ node.name == 'child' &&
+ node.staticElement != null &&
+ flutter.isWidgetExpression(parent2.expression)) {
+ namedExp = parent2;
+ } else {
+ _coverageMarker();
+ return;
+ }
}
- var childArgument = flutter.findChildArgument(widgetCreation);
- if (childArgument == null) {
- return;
- }
-
- // child: new ThisWidget(child: ourChild)
- // children: [foo, new ThisWidget(child: ourChild), bar]
DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
- var childExpression = childArgument.expression;
- var childText = utils.getNodeText(childExpression);
- var indentOld = utils.getLinePrefix(childExpression.offset);
- var indentNew = utils.getLinePrefix(widgetCreation.offset);
- childText = _replaceSourceIndent(childText, indentOld, indentNew);
- builder.addSimpleReplacement(range.node(widgetCreation), childText);
+ _convertFlutterChildToChildren(namedExp, eol, utils.getNodeText,
+ utils.getLinePrefix, utils.getIndent, utils.getText, builder);
});
_addAssistFromBuilder(
- changeBuilder, DartAssistKind.FLUTTER_REPLACE_WITH_CHILDREN);
+ changeBuilder, DartAssistKind.FLUTTER_CONVERT_TO_CHILDREN);
}
- Future<Null> _addProposal_flutterReplaceWithChildren() async {
+ Future<Null> _addProposal_flutterConvertToStatefulWidget() async {
+ ClassDeclaration widgetClass =
+ node.getAncestor((n) => n is ClassDeclaration);
+ TypeName superclass = widgetClass?.extendsClause?.superclass;
+ if (widgetClass == null || superclass == null) {
+ _coverageMarker();
+ return;
+ }
+
+ // Don't spam, activate only from the `class` keyword to the class body.
+ if (selectionOffset < widgetClass.classKeyword.offset ||
+ selectionOffset > widgetClass.leftBracket.end) {
+ _coverageMarker();
+ return;
+ }
+
+ // Find the build() method.
+ MethodDeclaration buildMethod;
+ for (var member in widgetClass.members) {
+ if (member is MethodDeclaration &&
+ member.name.name == 'build' &&
+ member.parameters != null &&
+ member.parameters.parameters.length == 1) {
+ buildMethod = member;
+ break;
+ }
+ }
+ if (buildMethod == null) {
+ _coverageMarker();
+ return;
+ }
+
+ // Must be a StatelessWidget subclasses.
+ ClassElement widgetClassElement = widgetClass.element;
+ if (!flutter.isExactlyStatelessWidgetType(widgetClassElement.supertype)) {
+ _coverageMarker();
+ return;
+ }
+
+ String widgetName = widgetClassElement.displayName;
+ String stateName = widgetName + 'State';
+
+ var buildLinesRange = utils.getLinesRange(range.node(buildMethod));
+ var buildText = utils.getRangeText(buildLinesRange);
+
+ // Update the build() text to insert `widget.` before references to
+ // the widget class members.
+ final List<SourceEdit> buildTextEdits = [];
+ buildMethod.body.accept(new _SimpleIdentifierRecursiveAstVisitor((node) {
+ if (node.staticElement?.enclosingElement == widgetClassElement) {
+ var offset = node.offset - buildLinesRange.offset;
+ AstNode parent = node.parent;
+ if (parent is InterpolationExpression &&
+ parent.leftBracket.type ==
+ TokenType.STRING_INTERPOLATION_IDENTIFIER) {
+ buildTextEdits.add(new SourceEdit(offset, 0, '{widget.'));
+ buildTextEdits.add(new SourceEdit(offset + node.length, 0, '}'));
+ } else {
+ buildTextEdits.add(new SourceEdit(offset, 0, 'widget.'));
+ }
+ }
+ }));
+ buildText = SourceEdit.applySequence(buildText, buildTextEdits.reversed);
+
+ var statefulWidgetClass =
+ await _getExportedClass(flutter.WIDGETS_LIBRARY_URI, 'StatefulWidget');
+ var stateClass =
+ await _getExportedClass(flutter.WIDGETS_LIBRARY_URI, 'State');
+ var stateType = stateClass.type.instantiate([widgetClassElement.type]);
+
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) async {
+ builder.addReplacement(range.node(superclass), (builder) {
+ builder.writeType(statefulWidgetClass.type);
+ });
+ builder.addReplacement(buildLinesRange, (builder) {
+ builder.writeln(' @override');
+ builder.writeln(' $stateName createState() {');
+ builder.writeln(' return new $stateName();');
+ builder.writeln(' }');
+ });
+ builder.addInsertion(widgetClass.end, (builder) {
+ builder.writeln();
+ builder.writeln();
+ builder.writeClassDeclaration(stateName, superclass: stateType,
+ membersWriter: () {
+ builder.write(buildText);
+ });
+ });
+ });
+ _addAssistFromBuilder(
+ changeBuilder, DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
+ }
+
+ Future<Null> _addProposal_flutterMoveWidgetDown() async {
+ var widget = flutter.identifyWidgetExpression(node);
+ if (widget == null) {
+ return;
+ }
+
+ AstNode parentList = widget.parent;
+ if (parentList is ListLiteral) {
+ List<Expression> parentElements = parentList.elements;
+ int index = parentElements.indexOf(widget);
+ if (index != parentElements.length - 1) {
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ Expression nextWidget = parentElements[index + 1];
+ var nextRange = range.node(nextWidget);
+ var nextText = utils.getRangeText(nextRange);
+
+ var widgetRange = range.node(widget);
+ var widgetText = utils.getRangeText(widgetRange);
+
+ builder.addSimpleReplacement(nextRange, widgetText);
+ builder.addSimpleReplacement(widgetRange, nextText);
+ });
+ _addAssistFromBuilder(changeBuilder, DartAssistKind.FLUTTER_MOVE_DOWN);
+ }
+ }
+ }
+
+ Future<Null> _addProposal_flutterMoveWidgetUp() async {
+ var widget = flutter.identifyWidgetExpression(node);
+ if (widget == null) {
+ return;
+ }
+
+ AstNode parentList = widget.parent;
+ if (parentList is ListLiteral) {
+ List<Expression> parentElements = parentList.elements;
+ int index = parentElements.indexOf(widget);
+ if (index > 0) {
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ Expression previousWidget = parentElements[index - 1];
+ var previousRange = range.node(previousWidget);
+ var previousText = utils.getRangeText(previousRange);
+
+ var widgetRange = range.node(widget);
+ var widgetText = utils.getRangeText(widgetRange);
+
+ builder.addSimpleReplacement(previousRange, widgetText);
+ builder.addSimpleReplacement(widgetRange, previousText);
+ });
+ _addAssistFromBuilder(changeBuilder, DartAssistKind.FLUTTER_MOVE_UP);
+ }
+ }
+ }
+
+ Future<Null> _addProposal_flutterRemoveWidget_multipleChildren() async {
var widgetCreation = flutter.identifyNewExpression(node);
if (widgetCreation == null) {
return;
@@ -1469,8 +1506,262 @@
childText = _replaceSourceIndent(childText, indentOld, indentNew);
builder.addSimpleReplacement(range.node(widgetCreation), childText);
});
- _addAssistFromBuilder(
- changeBuilder, DartAssistKind.FLUTTER_REPLACE_WITH_CHILDREN);
+ _addAssistFromBuilder(changeBuilder, DartAssistKind.FLUTTER_REMOVE_WIDGET);
+ }
+
+ Future<Null> _addProposal_flutterRemoveWidget_singleChild() async {
+ var widgetCreation = flutter.identifyNewExpression(node);
+ if (widgetCreation == null) {
+ return;
+ }
+
+ var childArgument = flutter.findChildArgument(widgetCreation);
+ if (childArgument == null) {
+ return;
+ }
+
+ // child: new ThisWidget(child: ourChild)
+ // children: [foo, new ThisWidget(child: ourChild), bar]
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ var childExpression = childArgument.expression;
+ var childText = utils.getNodeText(childExpression);
+ var indentOld = utils.getLinePrefix(childExpression.offset);
+ var indentNew = utils.getLinePrefix(widgetCreation.offset);
+ childText = _replaceSourceIndent(childText, indentOld, indentNew);
+ builder.addSimpleReplacement(range.node(widgetCreation), childText);
+ });
+ _addAssistFromBuilder(changeBuilder, DartAssistKind.FLUTTER_REMOVE_WIDGET);
+ }
+
+ Future<Null> _addProposal_flutterSwapWithChild() async {
+ InstanceCreationExpression exprGoingDown =
+ flutter.identifyNewExpression(node);
+ if (exprGoingDown == null || !flutter.isWidgetCreation(exprGoingDown)) {
+ _coverageMarker();
+ return;
+ }
+ InstanceCreationExpression exprGoingUp =
+ flutter.findChildWidget(exprGoingDown);
+ if (exprGoingUp == null) {
+ _coverageMarker();
+ return;
+ }
+ NamedExpression stableChild = flutter.findChildArgument(exprGoingUp);
+ if (stableChild == null || stableChild.expression == null) {
+ _coverageMarker();
+ return;
+ }
+ String exprGoingDownSrc = utils.getNodeText(exprGoingDown);
+ int dnNewlineIdx = exprGoingDownSrc.lastIndexOf(eol);
+ if (dnNewlineIdx < 0 || dnNewlineIdx == exprGoingDownSrc.length - 1) {
+ _coverageMarker();
+ return; // Outer new-expr needs to be in multi-line format already.
+ }
+ String exprGoingUpSrc = utils.getNodeText(exprGoingUp);
+ int upNewlineIdx = exprGoingUpSrc.lastIndexOf(eol);
+ if (upNewlineIdx < 0 || upNewlineIdx == exprGoingUpSrc.length - 1) {
+ _coverageMarker();
+ return; // Inner new-expr needs to be in multi-line format already.
+ }
+ await _swapFlutterWidgets(exprGoingDown, exprGoingUp, stableChild,
+ DartAssistKind.FLUTTER_SWAP_WITH_CHILD);
+ }
+
+ Future<Null> _addProposal_flutterSwapWithParent() async {
+ InstanceCreationExpression exprGoingUp =
+ flutter.identifyNewExpression(node);
+ if (exprGoingUp == null || !flutter.isWidgetCreation(exprGoingUp)) {
+ _coverageMarker();
+ return;
+ }
+ AstNode expr = exprGoingUp.parent?.parent?.parent;
+ if (expr == null || expr is! InstanceCreationExpression) {
+ _coverageMarker();
+ return;
+ }
+ InstanceCreationExpression exprGoingDown = expr;
+ NamedExpression stableChild = flutter.findChildArgument(exprGoingUp);
+ if (stableChild == null || stableChild.expression == null) {
+ _coverageMarker();
+ return;
+ }
+ String exprGoingUpSrc = utils.getNodeText(exprGoingUp);
+ int upNewlineIdx = exprGoingUpSrc.lastIndexOf(eol);
+ if (upNewlineIdx < 0 || upNewlineIdx == exprGoingUpSrc.length - 1) {
+ _coverageMarker();
+ return; // Inner new-expr needs to be in multi-line format already.
+ }
+ String exprGoingDownSrc = utils.getNodeText(exprGoingDown);
+ int dnNewlineIdx = exprGoingDownSrc.lastIndexOf(eol);
+ if (dnNewlineIdx < 0 || dnNewlineIdx == exprGoingDownSrc.length - 1) {
+ _coverageMarker();
+ return; // Outer new-expr needs to be in multi-line format already.
+ }
+ await _swapFlutterWidgets(exprGoingDown, exprGoingUp, stableChild,
+ DartAssistKind.FLUTTER_SWAP_WITH_PARENT);
+ }
+
+ Future<Null> _addProposal_flutterWrapWidget() async {
+ await _addProposal_flutterWrapWidgetImpl();
+ await _addProposal_flutterWrapWidgetImpl(
+ kind: DartAssistKind.FLUTTER_WRAP_CENTER,
+ parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
+ parentClassName: 'Center',
+ widgetValidator: (expr) {
+ return !flutter.isExactWidgetTypeCenter(expr.staticType);
+ });
+ await _addProposal_flutterWrapWidgetImpl(
+ kind: DartAssistKind.FLUTTER_WRAP_PADDING,
+ parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
+ parentClassName: 'Padding',
+ leadingLines: ['padding: const EdgeInsets.all(8.0),'],
+ widgetValidator: (expr) {
+ return !flutter.isExactWidgetTypePadding(expr.staticType);
+ });
+ }
+
+ Future<Null> _addProposal_flutterWrapWidgetImpl(
+ {AssistKind kind: DartAssistKind.FLUTTER_WRAP_GENERIC,
+ bool Function(Expression widgetExpr) widgetValidator,
+ String parentLibraryUri,
+ String parentClassName,
+ List<String> leadingLines: const []}) async {
+ Expression widgetExpr = flutter.identifyWidgetExpression(node);
+ if (widgetExpr == null) {
+ _coverageMarker();
+ return;
+ }
+ if (widgetValidator != null && !widgetValidator(widgetExpr)) {
+ _coverageMarker();
+ return;
+ }
+ String widgetSrc = utils.getNodeText(widgetExpr);
+
+ // If the wrapper class is specified, find its element.
+ ClassElement parentClassElement;
+ if (parentLibraryUri != null && parentClassName != null) {
+ parentClassElement =
+ await _getExportedClass(parentLibraryUri, parentClassName);
+ }
+
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ builder.addReplacement(range.node(widgetExpr), (DartEditBuilder builder) {
+ builder.write('new ');
+ if (parentClassElement == null) {
+ builder.addSimpleLinkedEdit('WIDGET', 'widget');
+ } else {
+ builder.writeType(parentClassElement.type);
+ }
+ builder.write('(');
+ if (widgetSrc.contains(eol) || leadingLines.isNotEmpty) {
+ String indentOld = utils.getLinePrefix(widgetExpr.offset);
+ String indentNew = '$indentOld${utils.getIndent(1)}';
+
+ for (var leadingLine in leadingLines) {
+ builder.write(eol);
+ builder.write(indentNew);
+ builder.write(leadingLine);
+ }
+
+ builder.write(eol);
+ builder.write(indentNew);
+ widgetSrc = widgetSrc.replaceAll(
+ new RegExp("^$indentOld", multiLine: true), indentNew);
+ widgetSrc += ",$eol$indentOld";
+ }
+ if (parentClassElement == null) {
+ builder.addSimpleLinkedEdit('CHILD', 'child');
+ } else {
+ builder.write('child');
+ }
+ builder.write(': ');
+ builder.write(widgetSrc);
+ builder.write(')');
+ builder.selectHere();
+ });
+ });
+ _addAssistFromBuilder(changeBuilder, kind);
+ }
+
+ Future<Null> _addProposal_flutterWrapWidgets() async {
+ var selectionRange = new SourceRange(selectionOffset, selectionLength);
+ var analyzer = new SelectionAnalyzer(selectionRange);
+ unit.accept(analyzer);
+
+ List<Expression> widgetExpressions = [];
+ if (analyzer.hasSelectedNodes) {
+ for (var selectedNode in analyzer.selectedNodes) {
+ if (!flutter.isWidgetExpression(selectedNode)) {
+ return;
+ }
+ widgetExpressions.add(selectedNode);
+ }
+ } else {
+ var widget = flutter.identifyWidgetExpression(analyzer.coveringNode);
+ if (widget != null) {
+ widgetExpressions.add(widget);
+ }
+ }
+ if (widgetExpressions.isEmpty) {
+ return;
+ }
+
+ var firstWidget = widgetExpressions.first;
+ var lastWidget = widgetExpressions.last;
+ var selectedRange = range.startEnd(firstWidget, lastWidget);
+ String src = utils.getRangeText(selectedRange);
+
+ Future<Null> addAssist(
+ {@required AssistKind kind,
+ @required String parentLibraryUri,
+ @required String parentClassName}) async {
+ ClassElement parentClassElement =
+ await _getExportedClass(parentLibraryUri, parentClassName);
+
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ builder.addReplacement(selectedRange, (DartEditBuilder builder) {
+ builder.write('new ');
+ builder.writeType(parentClassElement.type);
+ builder.write('(');
+
+ String indentOld = utils.getLinePrefix(firstWidget.offset);
+ String indentNew1 = indentOld + utils.getIndent(1);
+ String indentNew2 = indentOld + utils.getIndent(2);
+
+ builder.write(eol);
+ builder.write(indentNew1);
+ builder.write('children: [');
+ builder.write(eol);
+
+ String newSrc = _replaceSourceIndent(src, indentOld, indentNew2);
+ builder.write(indentNew2);
+ builder.write(newSrc);
+
+ builder.write(',');
+ builder.write(eol);
+
+ builder.write(indentNew1);
+ builder.write('],');
+ builder.write(eol);
+
+ builder.write(indentOld);
+ builder.write(')');
+ });
+ });
+ _addAssistFromBuilder(changeBuilder, kind);
+ }
+
+ await addAssist(
+ kind: DartAssistKind.FLUTTER_WRAP_COLUMN,
+ parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
+ parentClassName: 'Column');
+ await addAssist(
+ kind: DartAssistKind.FLUTTER_WRAP_ROW,
+ parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
+ parentClassName: 'Row');
}
Future<Null> _addProposal_importAddShow() async {
@@ -1871,74 +2162,6 @@
changeBuilder, DartAssistKind.JOIN_VARIABLE_DECLARATION);
}
- Future<Null> _addProposal_moveFlutterWidgetDown() async {
- InstanceCreationExpression exprGoingDown =
- flutter.identifyNewExpression(node);
- if (exprGoingDown == null || !flutter.isWidgetCreation(exprGoingDown)) {
- _coverageMarker();
- return;
- }
- InstanceCreationExpression exprGoingUp =
- flutter.findChildWidget(exprGoingDown);
- if (exprGoingUp == null) {
- _coverageMarker();
- return;
- }
- NamedExpression stableChild = flutter.findChildArgument(exprGoingUp);
- if (stableChild == null || stableChild.expression == null) {
- _coverageMarker();
- return;
- }
- String exprGoingDownSrc = utils.getNodeText(exprGoingDown);
- int dnNewlineIdx = exprGoingDownSrc.lastIndexOf(eol);
- if (dnNewlineIdx < 0 || dnNewlineIdx == exprGoingDownSrc.length - 1) {
- _coverageMarker();
- return; // Outer new-expr needs to be in multi-line format already.
- }
- String exprGoingUpSrc = utils.getNodeText(exprGoingUp);
- int upNewlineIdx = exprGoingUpSrc.lastIndexOf(eol);
- if (upNewlineIdx < 0 || upNewlineIdx == exprGoingUpSrc.length - 1) {
- _coverageMarker();
- return; // Inner new-expr needs to be in multi-line format already.
- }
- await _swapFlutterWidgets(exprGoingDown, exprGoingUp, stableChild,
- DartAssistKind.MOVE_FLUTTER_WIDGET_DOWN);
- }
-
- Future<Null> _addProposal_moveFlutterWidgetUp() async {
- InstanceCreationExpression exprGoingUp =
- flutter.identifyNewExpression(node);
- if (exprGoingUp == null || !flutter.isWidgetCreation(exprGoingUp)) {
- _coverageMarker();
- return;
- }
- AstNode expr = exprGoingUp.parent?.parent?.parent;
- if (expr == null || expr is! InstanceCreationExpression) {
- _coverageMarker();
- return;
- }
- InstanceCreationExpression exprGoingDown = expr;
- NamedExpression stableChild = flutter.findChildArgument(exprGoingUp);
- if (stableChild == null || stableChild.expression == null) {
- _coverageMarker();
- return;
- }
- String exprGoingUpSrc = utils.getNodeText(exprGoingUp);
- int upNewlineIdx = exprGoingUpSrc.lastIndexOf(eol);
- if (upNewlineIdx < 0 || upNewlineIdx == exprGoingUpSrc.length - 1) {
- _coverageMarker();
- return; // Inner new-expr needs to be in multi-line format already.
- }
- String exprGoingDownSrc = utils.getNodeText(exprGoingDown);
- int dnNewlineIdx = exprGoingDownSrc.lastIndexOf(eol);
- if (dnNewlineIdx < 0 || dnNewlineIdx == exprGoingDownSrc.length - 1) {
- _coverageMarker();
- return; // Outer new-expr needs to be in multi-line format already.
- }
- await _swapFlutterWidgets(exprGoingDown, exprGoingUp, stableChild,
- DartAssistKind.MOVE_FLUTTER_WIDGET_UP);
- }
-
Future<Null> _addProposal_removeTypeAnnotation() async {
VariableDeclarationList declarationList =
node.getAncestor((n) => n is VariableDeclarationList);
@@ -2028,158 +2251,7 @@
builder.selectHere();
});
});
- _addAssistFromBuilder(changeBuilder, DartAssistKind.REPARENT_FLUTTER_LIST);
- }
-
- Future<Null> _addProposal_reparentFlutterWidget() async {
- await _addProposal_reparentFlutterWidgetImpl();
- await _addProposal_reparentFlutterWidgetImpl(
- kind: DartAssistKind.REPARENT_FLUTTER_WIDGET_CENTER,
- parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
- parentClassName: 'Center');
- await _addProposal_reparentFlutterWidgetImpl(
- kind: DartAssistKind.REPARENT_FLUTTER_WIDGET_PADDING,
- parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
- parentClassName: 'Padding',
- leadingLines: ['padding: const EdgeInsets.all(8.0),']);
- }
-
- Future<Null> _addProposal_reparentFlutterWidgetImpl(
- {AssistKind kind: DartAssistKind.REPARENT_FLUTTER_WIDGET,
- String parentLibraryUri,
- String parentClassName,
- List<String> leadingLines: const []}) async {
- Expression widgetExpr = flutter.identifyWidgetExpression(node);
- if (widgetExpr == null) {
- _coverageMarker();
- return;
- }
- String widgetSrc = utils.getNodeText(widgetExpr);
-
- // If the wrapper class is specified, find its element.
- ClassElement parentClassElement;
- if (parentLibraryUri != null && parentClassName != null) {
- parentClassElement =
- await _getExportedClass(parentLibraryUri, parentClassName);
- }
-
- DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
- await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
- builder.addReplacement(range.node(widgetExpr), (DartEditBuilder builder) {
- builder.write('new ');
- if (parentClassElement == null) {
- builder.addSimpleLinkedEdit('WIDGET', 'widget');
- } else {
- builder.writeType(parentClassElement.type);
- }
- builder.write('(');
- if (widgetSrc.contains(eol) || leadingLines.isNotEmpty) {
- String indentOld = utils.getLinePrefix(widgetExpr.offset);
- String indentNew = '$indentOld${utils.getIndent(1)}';
-
- for (var leadingLine in leadingLines) {
- builder.write(eol);
- builder.write(indentNew);
- builder.write(leadingLine);
- }
-
- builder.write(eol);
- builder.write(indentNew);
- widgetSrc = widgetSrc.replaceAll(
- new RegExp("^$indentOld", multiLine: true), indentNew);
- widgetSrc += ",$eol$indentOld";
- }
- if (parentClassElement == null) {
- builder.addSimpleLinkedEdit('CHILD', 'child');
- } else {
- builder.write('child');
- }
- builder.write(': ');
- builder.write(widgetSrc);
- builder.write(')');
- builder.selectHere();
- });
- });
- _addAssistFromBuilder(changeBuilder, kind);
- }
-
- Future<Null> _addProposal_reparentFlutterWidgets() async {
- var selectionRange = new SourceRange(selectionOffset, selectionLength);
- var analyzer = new SelectionAnalyzer(selectionRange);
- unit.accept(analyzer);
-
- List<Expression> widgetExpressions = [];
- if (analyzer.hasSelectedNodes) {
- for (var selectedNode in analyzer.selectedNodes) {
- if (!flutter.isWidgetExpression(selectedNode)) {
- return;
- }
- widgetExpressions.add(selectedNode);
- }
- } else {
- var widget = flutter.identifyWidgetExpression(analyzer.coveringNode);
- if (widget != null) {
- widgetExpressions.add(widget);
- }
- }
- if (widgetExpressions.isEmpty) {
- return;
- }
-
- var firstWidget = widgetExpressions.first;
- var lastWidget = widgetExpressions.last;
- var selectedRange = range.startEnd(firstWidget, lastWidget);
- String src = utils.getRangeText(selectedRange);
-
- Future<Null> addAssist(
- {@required AssistKind kind,
- @required String parentLibraryUri,
- @required String parentClassName}) async {
- ClassElement parentClassElement =
- await _getExportedClass(parentLibraryUri, parentClassName);
-
- DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
- await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
- builder.addReplacement(selectedRange, (DartEditBuilder builder) {
- builder.write('new ');
- builder.writeType(parentClassElement.type);
- builder.write('(');
-
- String indentOld = utils.getLinePrefix(firstWidget.offset);
- String indentNew1 = indentOld + utils.getIndent(1);
- String indentNew2 = indentOld + utils.getIndent(2);
-
- builder.write(eol);
- builder.write(indentNew1);
- builder.write('children: [');
- builder.write(eol);
-
- String newSrc = _replaceSourceIndent(src, indentOld, indentNew2);
- builder.write(indentNew2);
- builder.write(newSrc);
-
- builder.write(',');
- builder.write(eol);
-
- builder.write(indentNew1);
- builder.write('],');
- builder.write(eol);
-
- builder.write(indentOld);
- builder.write(')');
- });
- });
- _addAssistFromBuilder(changeBuilder, kind);
- }
-
- await addAssist(
- kind: DartAssistKind.REPARENT_FLUTTER_WIDGETS_COLUMN,
- parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
- parentClassName: 'Column');
- await addAssist(
- kind: DartAssistKind.REPARENT_FLUTTER_WIDGETS_ROW,
- parentLibraryUri: flutter.WIDGETS_LIBRARY_URI,
- parentClassName: 'Row');
+ _addAssistFromBuilder(changeBuilder, DartAssistKind.FLUTTER_WRAP_GENERIC);
}
Future<Null> _addProposal_replaceConditionalWithIfElse() async {
@@ -2690,6 +2762,26 @@
}
/**
+ * Return `true` if all of the parameters in the given list of [parameters]
+ * have an explicit type annotation.
+ */
+ bool _allParametersHaveTypes(FormalParameterList parameters) {
+ for (FormalParameter parameter in parameters.parameters) {
+ if (parameter is DefaultFormalParameter) {
+ parameter = (parameter as DefaultFormalParameter).parameter;
+ }
+ if (parameter is SimpleFormalParameter) {
+ if (parameter.type == null) {
+ return false;
+ }
+ } else if (parameter is! FunctionTypedFormalParameter) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* Configures [utils] using given [target].
*/
void _configureTargetLocation(Object target) {
@@ -2704,7 +2796,6 @@
}
void _convertFlutterChildToChildren(
- InstanceCreationExpression childArg,
NamedExpression namedExp,
String eol,
Function getNodeText,
@@ -2712,6 +2803,7 @@
Function getIndent,
Function getText,
DartFileEditBuilder builder) {
+ Expression childArg = namedExp.expression;
int childLoc = namedExp.offset + 'child'.length;
builder.addSimpleInsertion(childLoc, 'ren');
int listLoc = childArg.offset;
@@ -2739,13 +2831,69 @@
} else {
builder.addSimpleInsertion(listLoc, '<Widget>[');
}
- String newChildArgSrc = childArgSrc.replaceAll(
- new RegExp("^$indentOld", multiLine: true), "$indentNew");
+ String newChildArgSrc =
+ _replaceSourceIndent(childArgSrc, indentOld, indentNew);
newChildArgSrc = "$prefix$newChildArgSrc,$eol$indentOld]";
builder.addSimpleReplacement(range.node(childArg), newChildArgSrc);
}
}
+ Future<Null> _convertFunctionTypeAliasToGenericTypeAlias(
+ FunctionTypeAlias node) async {
+ if (!_allParametersHaveTypes(node.parameters)) {
+ return;
+ }
+ String returnType;
+ if (node.returnType != null) {
+ returnType = utils.getNodeText(node.returnType);
+ }
+ String functionName = utils.getRangeText(
+ range.startEnd(node.name, node.typeParameters ?? node.name));
+ String parameters = utils.getNodeText(node.parameters);
+ String replacement;
+ if (returnType == null) {
+ replacement = '$functionName = Function$parameters';
+ } else {
+ replacement = '$functionName = $returnType Function$parameters';
+ }
+ // add change
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ builder.addSimpleReplacement(
+ range.startStart(node.typedefKeyword.next, node.semicolon),
+ replacement);
+ });
+ _addAssistFromBuilder(
+ changeBuilder, DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX);
+ }
+
+ Future<Null> _convertFunctionTypedFormalParameterToSimpleFormalParameter(
+ FunctionTypedFormalParameter node) async {
+ if (!_allParametersHaveTypes(node.parameters)) {
+ return;
+ }
+ String returnType;
+ if (node.returnType != null) {
+ returnType = utils.getNodeText(node.returnType);
+ }
+ String functionName = utils.getRangeText(range.startEnd(
+ node.identifier, node.typeParameters ?? node.identifier));
+ String parameters = utils.getNodeText(node.parameters);
+ String replacement;
+ if (returnType == null) {
+ replacement = 'Function$parameters $functionName';
+ } else {
+ replacement = '$returnType Function$parameters $functionName';
+ }
+ // add change
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ builder.addSimpleReplacement(range.node(node), replacement);
+ });
+ _addAssistFromBuilder(
+ changeBuilder, DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX);
+ }
+
/// Return the [ClassElement] with the given [className] that is exported
/// from the library with the given [libraryUri], or `null` if the libary
/// does not export a class with such name.
@@ -2862,7 +3010,7 @@
builder.write(utils.getNodePrefix(arg.name));
argSrc = utils.getNodeText(stableChild);
builder.write(argSrc);
- if (assistKind == DartAssistKind.MOVE_FLUTTER_WIDGET_UP) {
+ if (assistKind == DartAssistKind.FLUTTER_SWAP_WITH_PARENT) {
builder.write(',$eol');
}
} else {
@@ -2871,7 +3019,7 @@
builder.write(argSrc);
}
});
- if (assistKind == DartAssistKind.MOVE_FLUTTER_WIDGET_DOWN) {
+ if (assistKind == DartAssistKind.FLUTTER_SWAP_WITH_CHILD) {
builder.write(',$eol');
}
builder.write(innerIndent);
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index ab6d4ac..4bff2be 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -102,6 +102,8 @@
static const ADD_NE_NULL = const FixKind('ADD_NE_NULL', 50, "Add != null");
static const ADD_PACKAGE_DEPENDENCY = const FixKind(
'ADD_PACKAGE_DEPENDENCY', 50, "Add dependency on package '{0}'");
+ static const ADD_STATIC =
+ const FixKind('ADD_STATIC', 50, "Add 'static' modifier");
static const ADD_SUPER_CONSTRUCTOR_INVOCATION = const FixKind(
'ADD_SUPER_CONSTRUCTOR_INVOCATION',
50,
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 b880b53..f62e51a 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -402,6 +402,9 @@
CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD) {
await _addFix_createField_initializingFormal();
}
+ if (errorCode == CompileTimeErrorCode.CONST_INSTANCE_FIELD) {
+ await _addFix_addStatic();
+ }
// lints
if (errorCode is LintCode) {
String name = errorCode.name;
@@ -470,9 +473,6 @@
return fixes;
}
- /**
- * Returns `true` if the `async` proposal was added.
- */
Future<Null> _addFix_addAsync() async {
FunctionBody body = node.getAncestor((n) => n is FunctionBody);
if (body != null && body.keyword == null) {
@@ -701,6 +701,16 @@
_addFixFromBuilder(changeBuilder, DartFixKind.LINT_ADD_REQUIRED);
}
+ Future<Null> _addFix_addStatic() async {
+ FieldDeclaration declaration =
+ node.getAncestor((n) => n is FieldDeclaration);
+ DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ builder.addSimpleInsertion(declaration.offset, 'static ');
+ });
+ _addFixFromBuilder(changeBuilder, DartFixKind.ADD_STATIC);
+ }
+
Future<Null> _addFix_boolInsteadOfBoolean() async {
DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
diff --git a/pkg/analysis_server/lib/src/utilities/flutter.dart b/pkg/analysis_server/lib/src/utilities/flutter.dart
index 2a774f9..e8d9310 100644
--- a/pkg/analysis_server/lib/src/utilities/flutter.dart
+++ b/pkg/analysis_server/lib/src/utilities/flutter.dart
@@ -11,6 +11,9 @@
const WIDGETS_LIBRARY_URI = 'package:flutter/widgets.dart';
+const _BASIC_URI = "package:flutter/src/widgets/basic.dart";
+const _CENTER_NAME = "Center";
+const _PADDING_NAME = "Padding";
const _STATELESS_WIDGET_NAME = "StatelessWidget";
const _WIDGET_NAME = "Widget";
const _WIDGET_URI = "package:flutter/src/widgets/framework.dart";
@@ -265,6 +268,22 @@
}
/**
+ * Return `true` if the given [type] is the Flutter class `Center`.
+ */
+bool isExactWidgetTypeCenter(DartType type) {
+ return type is InterfaceType &&
+ _isExactWidget(type.element, _CENTER_NAME, _BASIC_URI);
+}
+
+/**
+ * Return `true` if the given [type] is the Flutter class `Padding`.
+ */
+bool isExactWidgetTypePadding(DartType type) {
+ return type is InterfaceType &&
+ _isExactWidget(type.element, _PADDING_NAME, _BASIC_URI);
+}
+
+/**
* Return `true` if the given [type] is the Flutter class `Widget`, or its
* subtype.
*/
diff --git a/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
index 28cdcf6..22fa3d4 100644
--- a/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
@@ -30,24 +30,47 @@
class B extends A {
B suggested2(String y) => null;
C suggested3([String z]) => null;
+ void suggested4() { }
+ int get suggested5 => null;
}
class C extends B {
sugg^
}
''');
await computeSuggestions();
- // TODO(pquitslund): test displayText
_assertOverride('''@override
A suggested1(int x) {
// TODO: implement suggested1
return null;
- }''');
+ }''',
+ displayText: 'suggested1(int x) { ... }',
+ selectionOffset: 79,
+ selectionLength: 4);
_assertOverride(
- '''@override\n A suggested1(int x) {\n // TODO: implement suggested1\n return null;\n }''');
+ '''@override\n A suggested1(int x) {\n // TODO: implement suggested1\n return null;\n }''',
+ displayText: 'suggested1(int x) { ... }',
+ selectionOffset: 79,
+ selectionLength: 4);
_assertOverride(
- '''@override\n B suggested2(String y) {\n // TODO: implement suggested2\n return null;\n }''');
+ '''@override\n B suggested2(String y) {\n // TODO: implement suggested2\n return null;\n }''',
+ displayText: 'suggested2(String y) { ... }',
+ selectionOffset: 82,
+ selectionLength: 4);
_assertOverride(
- '''@override\n C suggested3([String z]) {\n // TODO: implement suggested3\n return null;\n }''');
+ '''@override\n C suggested3([String z]) {\n // TODO: implement suggested3\n return null;\n }''',
+ displayText: 'suggested3([String z]) { ... }',
+ selectionOffset: 84,
+ selectionLength: 4);
+ _assertOverride(
+ '''@override\n void suggested4() {\n // TODO: implement suggested4\n }''',
+ displayText: 'suggested4() { ... }',
+ selectionOffset: 32,
+ selectionLength: 0);
+ _assertOverride(
+ '''// TODO: implement suggested5\n @override\n int get suggested5 => null;''',
+ displayText: 'suggested5 => ...',
+ selectionOffset: 66,
+ selectionLength: 4);
}
test_fromPart() async {
@@ -76,22 +99,30 @@
// assume information for context.getLibrariesContaining has been cached
await computeLibrariesContaining();
await computeSuggestions();
- // TODO(pquitslund): test displayText
_assertOverride('''@override
A suggested1(int x) {
// TODO: implement suggested1
return null;
- }''');
+ }''', displayText: 'suggested1(int x) { ... }');
_assertOverride(
- '''@override\n A suggested1(int x) {\n // TODO: implement suggested1\n return null;\n }''');
+ '''@override\n A suggested1(int x) {\n // TODO: implement suggested1\n return null;\n }''',
+ displayText: 'suggested1(int x) { ... }',
+ selectionOffset: 79,
+ selectionLength: 4);
_assertOverride(
- '''@override\n B suggested2(String y) {\n // TODO: implement suggested2\n return null;\n }''');
+ '''@override\n B suggested2(String y) {\n // TODO: implement suggested2\n return null;\n }''',
+ displayText: 'suggested2(String y) { ... }',
+ selectionOffset: 82,
+ selectionLength: 4);
_assertOverride(
- '''@override\n C suggested3([String z]) {\n // TODO: implement suggested3\n return null;\n }''');
+ '''@override\n C suggested3([String z]) {\n // TODO: implement suggested3\n return null;\n }''',
+ displayText: 'suggested3([String z]) { ... }',
+ selectionOffset: 84,
+ selectionLength: 4);
}
CompletionSuggestion _assertOverride(String completion,
- {String displayText}) {
+ {String displayText, int selectionOffset, int selectionLength}) {
CompletionSuggestion cs = getSuggest(
completion: completion,
csKind: CompletionSuggestionKind.OVERRIDE,
@@ -102,8 +133,10 @@
expect(cs.kind, equals(CompletionSuggestionKind.OVERRIDE));
expect(cs.relevance, equals(DART_RELEVANCE_HIGH));
expect(cs.importUri, null);
-// expect(cs.selectionOffset, equals(completion.length));
-// expect(cs.selectionLength, equals(0));
+ if (selectionOffset != null && selectionLength != null) {
+ expect(cs.selectionOffset, selectionOffset);
+ expect(cs.selectionLength, selectionLength);
+ }
expect(cs.isDeprecated, isFalse);
expect(cs.isPotential, isFalse);
expect(cs.element, isNotNull);
diff --git a/pkg/analysis_server/test/services/correction/assist_test.dart b/pkg/analysis_server/test/services/correction/assist_test.dart
index 1961144..a065d89 100644
--- a/pkg/analysis_server/test/services/correction/assist_test.dart
+++ b/pkg/analysis_server/test/services/correction/assist_test.dart
@@ -47,6 +47,7 @@
assertHasAssist(AssistKind kind, String expected) async {
assist = await _assertHasAssist(kind);
change = assist.change;
+ expect(change.id, kind.id);
// apply to "file"
List<SourceFileEdit> fileEdits = change.edits;
expect(fileEdits, hasLength(1));
@@ -913,117 +914,6 @@
''');
}
- test_convertFlutterChild_OK_multiLine() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- /*caret*/child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- key: null,
- ),
-// end
- );
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.CONVERT_FLUTTER_CHILD, '''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- /*caret*/children: <Widget>[
- new Container(
- width: 200.0,
- height: 300.0,
- ),
- ],
- key: null,
- ),
-// end
- );
-}
-''');
- }
-
- test_convertFlutterChild_OK_newlineChild() async {
- // This case could occur with deeply nested constructors, common in Flutter.
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- /*caret*/child:
- new Container(
- width: 200.0,
- height: 300.0,
- ),
- key: null,
- ),
-// end
- );
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.CONVERT_FLUTTER_CHILD, '''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- /*caret*/children: <Widget>[
- new Container(
- width: 200.0,
- height: 300.0,
- ),
- ],
- key: null,
- ),
-// end
- );
-}
-''');
- }
-
- test_convertFlutterChild_OK_singleLine() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- /*caret*/child: new GestureDetector(),
- key: null,
- ),
-// end
- );
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.CONVERT_FLUTTER_CHILD, '''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- /*caret*/children: <Widget>[new GestureDetector()],
- key: null,
- ),
-// end
- );
-}
-''');
- }
-
test_convertPartOfToUri_file_nonSibling() async {
addSource('/pkg/lib/foo.dart', '''
library foo;
@@ -1896,6 +1786,98 @@
''');
}
+ test_convertToFunctionSyntax_BAD_functionTypeAlias_insideParameterList() async {
+ await resolveTestUnit('''
+typedef String F(int x, int y);
+''');
+ await assertNoAssistAt(
+ 'x,', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX);
+ }
+
+ test_convertToFunctionSyntax_BAD_functionTypeAlias_noParameterTypes() async {
+ await resolveTestUnit('''
+typedef String F(x);
+''');
+ await assertNoAssistAt(
+ 'def', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX);
+ }
+
+ test_convertToFunctionSyntax_BAD_functionTypedParameter_insideParameterList() async {
+ await resolveTestUnit('''
+g(String f(int x, int y)) {}
+''');
+ await assertNoAssistAt(
+ 'x,', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX);
+ }
+
+ test_convertToFunctionSyntax_BAD_functionTypedParameter_noParameterTypes() async {
+ await resolveTestUnit('''
+g(String f(x)) {}
+''');
+ await assertNoAssistAt(
+ 'f(', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX);
+ }
+
+ test_convertToFunctionSyntax_OK_functionTypeAlias_noReturnType_noTypeParameters() async {
+ await resolveTestUnit('''
+typedef String F(int x);
+''');
+ await assertHasAssistAt(
+ 'def', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX, '''
+typedef F = String Function(int x);
+''');
+ }
+
+ test_convertToFunctionSyntax_OK_functionTypeAlias_noReturnType_typeParameters() async {
+ await resolveTestUnit('''
+typedef F<P, R>(P x);
+''');
+ await assertHasAssistAt(
+ 'def', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX, '''
+typedef F<P, R> = Function(P x);
+''');
+ }
+
+ test_convertToFunctionSyntax_OK_functionTypeAlias_returnType_noTypeParameters() async {
+ await resolveTestUnit('''
+typedef String F(int x);
+''');
+ await assertHasAssistAt(
+ 'def', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX, '''
+typedef F = String Function(int x);
+''');
+ }
+
+ test_convertToFunctionSyntax_OK_functionTypeAlias_returnType_typeParameters() async {
+ await resolveTestUnit('''
+typedef R F<P, R>(P x);
+''');
+ await assertHasAssistAt(
+ 'def', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX, '''
+typedef F<P, R> = R Function(P x);
+''');
+ }
+
+ test_convertToFunctionSyntax_OK_functionTypedParameter_noReturnType_noTypeParameters() async {
+ await resolveTestUnit('''
+g(f(int x)) {}
+''');
+ await assertHasAssistAt(
+ 'f(', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX, '''
+g(Function(int x) f) {}
+''');
+ }
+
+ test_convertToFunctionSyntax_OK_functionTypedParameter_returnType() async {
+ await resolveTestUnit('''
+g(String f(int x)) {}
+''');
+ await assertHasAssistAt(
+ 'f(', DartAssistKind.CONVERT_INTO_GENERIC_FUNCTION_SYNTAX, '''
+g(String Function(int x) f) {}
+''');
+ }
+
test_convertToGetter_BAD_noInitializer() async {
verifyNoTestUnitErrors = false;
await resolveTestUnit('''
@@ -2267,95 +2249,6 @@
''');
}
- test_convertToStatefulWidget_BAD_notClass() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-/*caret*/main() {}
-''');
- _setCaretLocation();
- assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
- }
-
- test_convertToStatefulWidget_BAD_notStatelessWidget() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-class /*caret*/MyWidget extends Text {
- MyWidget() : super('');
-}
-''');
- _setCaretLocation();
- assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
- }
-
- test_convertToStatefulWidget_BAD_notWidget() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-class /*caret*/MyWidget {}
-''');
- _setCaretLocation();
- assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
- }
-
- test_convertToStatefulWidget_OK() async {
- addFlutterPackage();
- await resolveTestUnit(r'''
-import 'package:flutter/material.dart';
-
-class /*caret*/MyWidget extends StatelessWidget {
- final String aaa;
- final String bbb;
-
- const MyWidget(this.aaa, this.bbb);
-
- @override
- Widget build(BuildContext context) {
- return new Row(
- children: [
- new Text(aaa),
- new Text(bbb),
- new Text('$aaa'),
- new Text('${bbb}'),
- ],
- );
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(
- DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET, r'''
-import 'package:flutter/material.dart';
-
-class /*caret*/MyWidget extends StatefulWidget {
- final String aaa;
- final String bbb;
-
- const MyWidget(this.aaa, this.bbb);
-
- @override
- MyWidgetState createState() {
- return new MyWidgetState();
- }
-}
-
-class MyWidgetState extends State<MyWidget> {
- @override
- Widget build(BuildContext context) {
- return new Row(
- children: [
- new Text(widget.aaa),
- new Text(widget.bbb),
- new Text('${widget.aaa}'),
- new Text('${widget.bbb}'),
- ],
- );
- }
-}
-''');
- }
-
test_encapsulateField_BAD_alreadyPrivate() async {
await resolveTestUnit('''
class A {
@@ -2628,7 +2521,379 @@
''');
}
- test_flutterReplaceWithChild_OK_childIntoChild_multiLine() async {
+ test_flutterConvertToChildren_BAD_childUnresolved() async {
+ addFlutterPackage();
+ verifyNoTestUnitErrors = false;
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+build() {
+ return new Row(
+ /*caret*/child: new Container()
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_CHILDREN);
+ }
+
+ test_flutterConvertToChildren_BAD_notOnChild() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+ body: /*caret*/new Center(
+ child: new Container(),
+ ),
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_CHILDREN);
+ }
+
+ test_flutterConvertToChildren_OK_multiLine() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_CONVERT_TO_CHILDREN, '''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/children: <Widget>[
+ new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ],
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ }
+
+ test_flutterConvertToChildren_OK_newlineChild() async {
+ // This case could occur with deeply nested constructors, common in Flutter.
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/child:
+ new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_CONVERT_TO_CHILDREN, '''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/children: <Widget>[
+ new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ],
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ }
+
+ test_flutterConvertToChildren_OK_singleLine() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/child: new GestureDetector(),
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_CONVERT_TO_CHILDREN, '''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/children: <Widget>[new GestureDetector()],
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ }
+
+ test_flutterConvertToStatefulWidget_BAD_notClass() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+/*caret*/main() {}
+''');
+ _setCaretLocation();
+ assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
+ }
+
+ test_flutterConvertToStatefulWidget_BAD_notStatelessWidget() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+class /*caret*/MyWidget extends Text {
+ MyWidget() : super('');
+}
+''');
+ _setCaretLocation();
+ assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
+ }
+
+ test_flutterConvertToStatefulWidget_BAD_notWidget() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+class /*caret*/MyWidget {}
+''');
+ _setCaretLocation();
+ assertNoAssist(DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET);
+ }
+
+ test_flutterConvertToStatefulWidget_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit(r'''
+import 'package:flutter/material.dart';
+
+class /*caret*/MyWidget extends StatelessWidget {
+ final String aaa;
+ final String bbb;
+
+ const MyWidget(this.aaa, this.bbb);
+
+ @override
+ Widget build(BuildContext context) {
+ return new Row(
+ children: [
+ new Text(aaa),
+ new Text(bbb),
+ new Text('$aaa'),
+ new Text('${bbb}'),
+ ],
+ );
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(
+ DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET, r'''
+import 'package:flutter/material.dart';
+
+class /*caret*/MyWidget extends StatefulWidget {
+ final String aaa;
+ final String bbb;
+
+ const MyWidget(this.aaa, this.bbb);
+
+ @override
+ MyWidgetState createState() {
+ return new MyWidgetState();
+ }
+}
+
+class MyWidgetState extends State<MyWidget> {
+ @override
+ Widget build(BuildContext context) {
+ return new Row(
+ children: [
+ new Text(widget.aaa),
+ new Text(widget.bbb),
+ new Text('${widget.aaa}'),
+ new Text('${widget.bbb}'),
+ ],
+ );
+ }
+}
+''');
+ }
+
+ test_flutterMoveWidgetDown_BAD_last() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: <Widget>[
+ new Text('aaa'),
+ new Text('bbb'),
+ /*caret*/new Text('ccc'),
+ ],
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_MOVE_DOWN);
+ }
+
+ test_flutterMoveWidgetDown_BAD_notInList() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Center(
+ child: /*caret*/new Text('aaa'),
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_MOVE_DOWN);
+ }
+
+ test_flutterMoveWidgetDown_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: <Widget>[
+ new Text('aaa'),
+ /*caret*/new Text('bbb'),
+ new Text('ccc'),
+ ],
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_MOVE_DOWN, '''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: <Widget>[
+ new Text('aaa'),
+ /*caret*/new Text('ccc'),
+ new Text('bbb'),
+ ],
+ );
+}
+''');
+ }
+
+ test_flutterMoveWidgetUp_BAD_first() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: <Widget>[
+ /*caret*/new Text('aaa'),
+ new Text('bbb'),
+ new Text('ccc'),
+ ],
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_MOVE_UP);
+ }
+
+ test_flutterMoveWidgetUp_BAD_notInList() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Center(
+ child: /*caret*/new Text('aaa'),
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_MOVE_UP);
+ }
+
+ test_flutterMoveWidgetUp_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: <Widget>[
+ new Text('aaa'),
+ /*caret*/new Text('bbb'),
+ new Text('ccc'),
+ ],
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_MOVE_UP, '''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: <Widget>[
+ new Text('bbb'),
+ /*caret*/new Text('aaa'),
+ new Text('ccc'),
+ ],
+ );
+}
+''');
+ }
+
+ test_flutterRemoveWidget_BAD_childrenIntoChild() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Center(
+ child: new /*caret*/Row(
+ children: [
+ new Text('aaa'),
+ new Text('bbb'),
+ ],
+ ),
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_REMOVE_WIDGET);
+ }
+
+ test_flutterRemoveWidget_OK_childIntoChild_multiLine() async {
addFlutterPackage();
await resolveTestUnit('''
import 'package:flutter/material.dart';
@@ -2649,7 +2914,7 @@
}
''');
_setCaretLocation();
- await assertHasAssist(DartAssistKind.FLUTTER_REPLACE_WITH_CHILDREN, '''
+ await assertHasAssist(DartAssistKind.FLUTTER_REMOVE_WIDGET, '''
import 'package:flutter/material.dart';
main() {
new Column(
@@ -2666,7 +2931,7 @@
''');
}
- test_flutterReplaceWithChild_OK_childIntoChild_singleLine() async {
+ test_flutterRemoveWidget_OK_childIntoChild_singleLine() async {
addFlutterPackage();
await resolveTestUnit('''
import 'package:flutter/material.dart';
@@ -2681,7 +2946,7 @@
}
''');
_setCaretLocation();
- await assertHasAssist(DartAssistKind.FLUTTER_REPLACE_WITH_CHILDREN, '''
+ await assertHasAssist(DartAssistKind.FLUTTER_REMOVE_WIDGET, '''
import 'package:flutter/material.dart';
main() {
new Padding(
@@ -2692,7 +2957,7 @@
''');
}
- test_flutterReplaceWithChild_OK_childIntoChildren() async {
+ test_flutterRemoveWidget_OK_childIntoChildren() async {
addFlutterPackage();
await resolveTestUnit('''
import 'package:flutter/material.dart';
@@ -2713,7 +2978,7 @@
}
''');
_setCaretLocation();
- await assertHasAssist(DartAssistKind.FLUTTER_REPLACE_WITH_CHILDREN, '''
+ await assertHasAssist(DartAssistKind.FLUTTER_REMOVE_WIDGET, '''
import 'package:flutter/material.dart';
main() {
new Column(
@@ -2730,26 +2995,7 @@
''');
}
- test_flutterReplaceWithChildren_BAD_parentChild() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-main() {
- new Center(
- child: new /*caret*/Row(
- children: [
- new Text('aaa'),
- new Text('bbb'),
- ],
- ),
- );
-}
-''');
- _setCaretLocation();
- await assertNoAssist(DartAssistKind.FLUTTER_REPLACE_WITH_CHILDREN);
- }
-
- test_flutterReplaceWithChildren_OK_intoChildren() async {
+ test_flutterRemoveWidget_OK_intoChildren() async {
addFlutterPackage();
await resolveTestUnit('''
import 'package:flutter/material.dart';
@@ -2779,7 +3025,7 @@
}
''');
_setCaretLocation();
- await assertHasAssist(DartAssistKind.FLUTTER_REPLACE_WITH_CHILDREN, '''
+ await assertHasAssist(DartAssistKind.FLUTTER_REMOVE_WIDGET, '''
import 'package:flutter/material.dart';
main() {
new Column(
@@ -2804,6 +3050,580 @@
''');
}
+ test_flutterSwapWithChild_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Center(
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_SWAP_WITH_CHILD, '''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ child: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ }
+
+ test_flutterSwapWithParent_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ child: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_SWAP_WITH_PARENT, '''
+import 'package:flutter/material.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Center(
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ }
+
+ test_flutterSwapWithParent_OK_outerIsInChildren() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: [
+ new Column(
+ children: [
+ new Padding(
+ padding: new EdgeInsets.all(16.0),
+ child: new /*caret*/Center(
+ child: new Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: <Widget>[],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_SWAP_WITH_PARENT, '''
+import 'package:flutter/material.dart';
+main() {
+ new Column(
+ children: [
+ new Column(
+ children: [
+ new /*caret*/Center(
+ child: new Padding(
+ padding: new EdgeInsets.all(16.0),
+ child: new Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: <Widget>[],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ );
+}
+''');
+ }
+
+ test_flutterWrapCenter_BAD_onCenter() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return /*caret*/new Center();
+ }
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_WRAP_CENTER);
+ }
+
+ test_flutterWrapCenter_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return /*caret*/new Container();
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_CENTER, '''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return /*caret*/new Center(child: new Container());
+ }
+}
+''');
+ }
+
+ test_flutterWrapColumn_OK_coveredByWidget() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+
+class FakeFlutter {
+ main() {
+ return new Container(
+ child: new /*caret*/Text('aaa'),
+ );
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_COLUMN, '''
+import 'package:flutter/widgets.dart';
+
+class FakeFlutter {
+ main() {
+ return new Container(
+ child: new Column(
+ children: [
+ new /*caret*/Text('aaa'),
+ ],
+ ),
+ );
+ }
+}
+''');
+ }
+
+ test_flutterWrapColumn_OK_coversWidgets() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+
+class FakeFlutter {
+ main() {
+ return new Row(children: [
+ new Text('aaa'),
+// start
+ new Text('bbb'),
+ new Text('ccc'),
+// end
+ new Text('ddd'),
+ ]);
+ }
+}
+''');
+ _setStartEndSelection();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_COLUMN, '''
+import 'package:flutter/widgets.dart';
+
+class FakeFlutter {
+ main() {
+ return new Row(children: [
+ new Text('aaa'),
+// start
+ new Column(
+ children: [
+ new Text('bbb'),
+ new Text('ccc'),
+ ],
+ ),
+// end
+ new Text('ddd'),
+ ]);
+ }
+}
+''');
+ }
+
+ test_flutterWrapPadding_BAD_onPadding() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return /*caret*/new Padding();
+ }
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_WRAP_PADDING);
+ }
+
+ test_flutterWrapPadding_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return /*caret*/new Container();
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_PADDING, '''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return /*caret*/new Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: new Container(),
+ );
+ }
+}
+''');
+ }
+
+ test_flutterWrapRow_OK() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+
+class FakeFlutter {
+ main() {
+ return new Column(children: [
+ new Text('aaa'),
+// start
+ new Text('bbb'),
+ new Text('ccc'),
+// end
+ new Text('ddd'),
+ ]);
+ }
+}
+''');
+ _setStartEndSelection();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_ROW, '''
+import 'package:flutter/widgets.dart';
+
+class FakeFlutter {
+ main() {
+ return new Column(children: [
+ new Text('aaa'),
+// start
+ new Row(
+ children: [
+ new Text('bbb'),
+ new Text('ccc'),
+ ],
+ ),
+// end
+ new Text('ddd'),
+ ]);
+ }
+}
+''');
+ }
+
+ test_flutterWrapWidget_BAD_minimal() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+/*caret*/x(){}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_WRAP_GENERIC);
+ }
+
+ test_flutterWrapWidget_BAD_multiLine() async {
+ verifyNoTestUnitErrors = false;
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+build() {
+ return new Container(
+ child: new Row(
+ children: [/*caret*/
+// start
+ new Transform(),
+ new Object(),
+ new AspectRatio(),
+// end
+ ],
+ ),
+ );
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_WRAP_GENERIC);
+ }
+
+ test_flutterWrapWidget_BAD_singleLine() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ var obj;
+// start
+ return new Row(children: [/*caret*/ new Transform()]);
+// end
+ }
+}
+''');
+ _setCaretLocation();
+ await assertNoAssist(DartAssistKind.FLUTTER_WRAP_GENERIC);
+ }
+
+ test_flutterWrapWidget_OK_multiLine() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+build() {
+ return new Container(
+ child: new Row(
+// start
+ children: [/*caret*/
+ new Transform(),
+ new Transform(),
+ new AspectRatio(),
+ ],
+// end
+ ),
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_GENERIC, '''
+import 'package:flutter/widgets.dart';
+build() {
+ return new Container(
+ child: new Row(
+// start
+ children: [
+ new widget(
+ children: [/*caret*/
+ new Transform(),
+ new Transform(),
+ new AspectRatio(),
+ ],
+ ),
+ ],
+// end
+ ),
+ );
+}
+''');
+ }
+
+ test_flutterWrapWidget_OK_multiLines() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return new Container(
+// start
+ child: new /*caret*/DefaultTextStyle(
+ child: new Row(
+ children: <Widget>[
+ new Container(
+ ),
+ ],
+ ),
+ ),
+// end
+ );
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_GENERIC, '''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return new Container(
+// start
+ child: new widget(
+ child: new /*caret*/DefaultTextStyle(
+ child: new Row(
+ children: <Widget>[
+ new Container(
+ ),
+ ],
+ ),
+ ),
+ ),
+// end
+ );
+ }
+}
+''');
+ }
+
+ test_flutterWrapWidget_OK_multiLines_eol2() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {\r
+ main() {\r
+ return new Container(\r
+// start\r
+ child: new /*caret*/DefaultTextStyle(\r
+ child: new Row(\r
+ children: <Widget>[\r
+ new Container(\r
+ ),\r
+ ],\r
+ ),\r
+ ),\r
+// end\r
+ );\r
+ }\r
+}\r
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_GENERIC, '''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {\r
+ main() {\r
+ return new Container(\r
+// start\r
+ child: new widget(\r
+ child: new /*caret*/DefaultTextStyle(\r
+ child: new Row(\r
+ children: <Widget>[\r
+ new Container(\r
+ ),\r
+ ],\r
+ ),\r
+ ),\r
+ ),\r
+// end\r
+ );\r
+ }\r
+}\r
+''');
+ }
+
+ test_flutterWrapWidget_OK_singleLine1() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+// start
+ return /*caret*/new Container();
+// end
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_GENERIC, '''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+// start
+ return /*caret*/new widget(child: new Container());
+// end
+ }
+}
+''');
+ }
+
+ test_flutterWrapWidget_OK_singleLine2() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return new ClipRect./*caret*/rect();
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_GENERIC, '''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ return new widget(child: new ClipRect./*caret*/rect());
+ }
+}
+''');
+ }
+
+ test_flutterWrapWidget_OK_variable() async {
+ addFlutterPackage();
+ await resolveTestUnit('''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ var container = new Container();
+ return /*caret*/container;
+ }
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(DartAssistKind.FLUTTER_WRAP_GENERIC, '''
+import 'package:flutter/widgets.dart';
+class FakeFlutter {
+ main() {
+ var container = new Container();
+ return /*caret*/new widget(child: container);
+ }
+}
+''');
+ }
+
test_importAddShow_BAD_hasShow() async {
await resolveTestUnit('''
import 'dart:math' show PI;
@@ -3715,145 +4535,6 @@
''');
}
- test_moveFlutterWidgetDown_OK() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Center(
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- key: null,
- ),
- ),
-// end
- );
-}
-startResize() {}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.MOVE_FLUTTER_WIDGET_DOWN, '''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- child: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- ),
- key: null,
- ),
-// end
- );
-}
-startResize() {}
-''');
- }
-
- test_moveFlutterWidgetUp_OK() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- child: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- ),
- key: null,
- ),
-// end
- );
-}
-startResize() {}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.MOVE_FLUTTER_WIDGET_UP, '''
-import 'package:flutter/material.dart';
-build() {
- return new Scaffold(
-// start
- body: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Center(
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- key: null,
- ),
- ),
-// end
- );
-}
-startResize() {}
-''');
- }
-
- test_moveFlutterWidgetUp_OK_outerIsInChildren() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/material.dart';
-main() {
- new Column(
- children: [
- new Column(
- children: [
- new Padding(
- padding: new EdgeInsets.all(16.0),
- child: new /*caret*/Center(
- child: new Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[],
- ),
- ),
- ),
- ],
- ),
- ],
- );
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.MOVE_FLUTTER_WIDGET_UP, '''
-import 'package:flutter/material.dart';
-main() {
- new Column(
- children: [
- new Column(
- children: [
- new /*caret*/Center(
- child: new Padding(
- padding: new EdgeInsets.all(16.0),
- child: new Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[],
- ),
- ),
- ),
- ],
- ),
- ],
- );
-}
-''');
- }
-
test_removeTypeAnnotation_classField_OK() async {
await resolveTestUnit('''
class A {
@@ -3980,430 +4661,6 @@
''');
}
- test_reparentFlutterList_BAD_multiLine() async {
- verifyNoTestUnitErrors = false;
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-build() {
- return new Container(
- child: new Row(
- children: [/*caret*/
-// start
- new Transform(),
- new Object(),
- new AspectRatio(),
-// end
- ],
- ),
- );
-}
-''');
- _setCaretLocation();
- await assertNoAssist(DartAssistKind.REPARENT_FLUTTER_LIST);
- }
-
- test_reparentFlutterList_BAD_singleLine() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- var obj;
-// start
- return new Row(children: [/*caret*/ new Transform()]);
-// end
- }
-}
-''');
- _setCaretLocation();
- await assertNoAssist(DartAssistKind.REPARENT_FLUTTER_LIST);
- }
-
- test_reparentFlutterList_OK_multiLine() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-build() {
- return new Container(
- child: new Row(
-// start
- children: [/*caret*/
- new Transform(),
- new Transform(),
- new AspectRatio(),
- ],
-// end
- ),
- );
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_LIST, '''
-import 'package:flutter/widgets.dart';
-build() {
- return new Container(
- child: new Row(
-// start
- children: [
- new widget(
- children: [/*caret*/
- new Transform(),
- new Transform(),
- new AspectRatio(),
- ],
- ),
- ],
-// end
- ),
- );
-}
-''');
- }
-
- test_reparentFlutterWidget_BAD_minimal() async {
- addFlutterPackage();
- await resolveTestUnit('''
-/*caret*/x(){}
-''');
- _setCaretLocation();
- await assertNoAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET);
- }
-
- test_reparentFlutterWidget_BAD_singleLine() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- var obj;
-// start
- return new Container(child: obj.xyz./*caret*/abc);
-// end
- }
-}
-''');
- _setCaretLocation();
- await assertNoAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET);
- }
-
- test_reparentFlutterWidget_OK_multiLines() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return new Container(
-// start
- child: new /*caret*/DefaultTextStyle(
- child: new Row(
- children: <Widget>[
- new Container(
- ),
- ],
- ),
- ),
-// end
- );
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET, '''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return new Container(
-// start
- child: new widget(
- child: new /*caret*/DefaultTextStyle(
- child: new Row(
- children: <Widget>[
- new Container(
- ),
- ],
- ),
- ),
- ),
-// end
- );
- }
-}
-''');
- }
-
- test_reparentFlutterWidget_OK_multiLines_eol2() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {\r
- main() {\r
- return new Container(\r
-// start\r
- child: new /*caret*/DefaultTextStyle(\r
- child: new Row(\r
- children: <Widget>[\r
- new Container(\r
- ),\r
- ],\r
- ),\r
- ),\r
-// end\r
- );\r
- }\r
-}\r
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET, '''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {\r
- main() {\r
- return new Container(\r
-// start\r
- child: new widget(\r
- child: new /*caret*/DefaultTextStyle(\r
- child: new Row(\r
- children: <Widget>[\r
- new Container(\r
- ),\r
- ],\r
- ),\r
- ),\r
- ),\r
-// end\r
- );\r
- }\r
-}\r
-''');
- }
-
- test_reparentFlutterWidget_OK_singleLine1() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
-// start
- return /*caret*/new Container();
-// end
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET, '''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
-// start
- return /*caret*/new widget(child: new Container());
-// end
- }
-}
-''');
- }
-
- test_reparentFlutterWidget_OK_singleLine2() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return new ClipRect./*caret*/rect();
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET, '''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return new widget(child: new ClipRect./*caret*/rect());
- }
-}
-''');
- }
-
- test_reparentFlutterWidget_OK_variable() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- var container = new Container();
- return /*caret*/container;
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET, '''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- var container = new Container();
- return /*caret*/new widget(child: container);
- }
-}
-''');
- }
-
- test_reparentFlutterWidgetCenter_OK() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return /*caret*/new Container();
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET_CENTER, '''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return /*caret*/new Center(child: new Container());
- }
-}
-''');
- }
-
- test_reparentFlutterWidgetPadding_OK() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return /*caret*/new Container();
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGET_PADDING, '''
-import 'package:flutter/widgets.dart';
-class FakeFlutter {
- main() {
- return /*caret*/new Padding(
- padding: const EdgeInsets.all(8.0),
- child: new Container(),
- );
- }
-}
-''');
- }
-
- test_reparentFlutterWidgets_OK_column_coveredByWidget() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-
-class FakeFlutter {
- main() {
- return new Container(
- child: new /*caret*/Text('aaa'),
- );
- }
-}
-''');
- _setCaretLocation();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGETS_COLUMN, '''
-import 'package:flutter/widgets.dart';
-
-class FakeFlutter {
- main() {
- return new Container(
- child: new Column(
- children: [
- new /*caret*/Text('aaa'),
- ],
- ),
- );
- }
-}
-''');
- }
-
- test_reparentFlutterWidgets_OK_column_coversWidgets() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-
-class FakeFlutter {
- main() {
- return new Row(children: [
- new Text('aaa'),
-// start
- new Text('bbb'),
- new Text('ccc'),
-// end
- new Text('ddd'),
- ]);
- }
-}
-''');
- _setStartEndSelection();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGETS_COLUMN, '''
-import 'package:flutter/widgets.dart';
-
-class FakeFlutter {
- main() {
- return new Row(children: [
- new Text('aaa'),
-// start
- new Column(
- children: [
- new Text('bbb'),
- new Text('ccc'),
- ],
- ),
-// end
- new Text('ddd'),
- ]);
- }
-}
-''');
- }
-
- test_reparentFlutterWidgets_OK_row() async {
- addFlutterPackage();
- await resolveTestUnit('''
-import 'package:flutter/widgets.dart';
-
-class FakeFlutter {
- main() {
- return new Column(children: [
- new Text('aaa'),
-// start
- new Text('bbb'),
- new Text('ccc'),
-// end
- new Text('ddd'),
- ]);
- }
-}
-''');
- _setStartEndSelection();
- await assertHasAssist(DartAssistKind.REPARENT_FLUTTER_WIDGETS_ROW, '''
-import 'package:flutter/widgets.dart';
-
-class FakeFlutter {
- main() {
- return new Column(children: [
- new Text('aaa'),
-// start
- new Row(
- children: [
- new Text('bbb'),
- new Text('ccc'),
- ],
- ),
-// end
- new Text('ddd'),
- ]);
- }
-}
-''');
- }
-
test_replaceConditionalWithIfElse_BAD_noEnclosingStatement() async {
await resolveTestUnit('''
var v = true ? 111 : 222;
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index fd1701b..2d378b8 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -958,6 +958,32 @@
''');
}
+ test_addStatic_multipleFields() async {
+ await resolveTestUnit('''
+class C {
+ const int x = 0, y = 0;
+}
+''');
+ await assertHasFix(DartFixKind.ADD_STATIC, '''
+class C {
+ static const int x = 0, y = 0;
+}
+''');
+ }
+
+ test_addStatic_oneField() async {
+ await resolveTestUnit('''
+class C {
+ const int x = 0;
+}
+''');
+ await assertHasFix(DartFixKind.ADD_STATIC, '''
+class C {
+ static const int x = 0;
+}
+''');
+ }
+
test_boolean() async {
await resolveTestUnit('''
main() {
diff --git a/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart b/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
index 6ecf220..6850ece 100644
--- a/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
@@ -35,83 +35,75 @@
}
test_attribute_namedExpression() async {
- newFile('/a.dart', content: r'''
+ FlutterOutline unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';
+main() {
+ return new WidgetA(
+ value: 42,
+ ); // WidgetA
+}
+
class WidgetA extends StatelessWidget {
WidgetA({int value});
}
''');
- FlutterOutline unitOutline = await _computeOutline('''
-import 'package:flutter/widgets.dart';
-import 'a.dart';
+ var main = unitOutline.children[0];
+ var widget = main.children[0];
+ expect(widget.attributes, hasLength(1));
-class MyWidget extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return new WidgetA(
- value: 42,
- ); // WidgetA
- }
-}
-''');
- var myWidget = unitOutline.children[0];
- var build = myWidget.children[0];
-
- var a = build.children[0];
- expect(a.attributes, hasLength(1));
-
- var attribute = a.attributes[0];
+ var attribute = widget.attributes[0];
expect(attribute.name, 'value');
expect(attribute.label, '42');
}
test_attributes_bool() async {
- FlutterOutline unitOutline = await _computeOutline('''
-import 'package:flutter/widgets.dart';
-
-class MyWidget extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return const Text(true)
- }
-}
-''');
- var myWidget = unitOutline.children[0];
- var build = myWidget.children[0];
- var textOutline = build.children[0];
-
- expect(textOutline.attributes, hasLength(1));
-
- FlutterOutlineAttribute attribute = textOutline.attributes[0];
- expect(attribute.name, 'data');
+ var attribute = await _getAttribute('test', 'true');
expect(attribute.label, 'true');
expect(attribute.literalValueBoolean, true);
}
- test_attributes_int() async {
- FlutterOutline unitOutline = await _computeOutline('''
-import 'package:flutter/widgets.dart';
-
-class MyWidget extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return const Text(42)
+ test_attributes_functionExpression_hasParameters_blockExpression() async {
+ var attribute = await _getAttribute('test', '(a) {}');
+ expect(attribute.label, '(…) { … }');
}
-}
-''');
- var myWidget = unitOutline.children[0];
- var build = myWidget.children[0];
- var textOutline = build.children[0];
- expect(textOutline.attributes, hasLength(1));
+ test_attributes_functionExpression_hasParameters_bodyExpression() async {
+ var attribute = await _getAttribute('test', '(a) => 1');
+ expect(attribute.label, '(…) => …');
+ }
- FlutterOutlineAttribute attribute = textOutline.attributes[0];
- expect(attribute.name, 'data');
+ test_attributes_functionExpression_noParameters_blockExpression() async {
+ var attribute = await _getAttribute('test', '() {}');
+ expect(attribute.label, '() { … }');
+ }
+
+ test_attributes_functionExpression_noParameters_bodyExpression() async {
+ var attribute = await _getAttribute('test', '() => 1');
+ expect(attribute.label, '() => …');
+ }
+
+ test_attributes_int() async {
+ var attribute = await _getAttribute('test', '42');
expect(attribute.label, '42');
expect(attribute.literalValueInteger, 42);
}
+ test_attributes_listLiteral() async {
+ var attribute = await _getAttribute('test', '[1, 2, 3]');
+ expect(attribute.label, '[…]');
+ }
+
+ test_attributes_mapLiteral() async {
+ var attribute = await _getAttribute('test', '{1: 10, 2: 20}');
+ expect(attribute.label, '{…}');
+ }
+
+ test_attributes_multiLine() async {
+ var attribute = await _getAttribute('test', '1 +\n 2');
+ expect(attribute.label, '…');
+ }
+
test_attributes_string_interpolation() async {
FlutterOutline unitOutline = await _computeOutline(r'''
import 'package:flutter/widgets.dart';
@@ -137,24 +129,7 @@
}
test_attributes_string_literal() async {
- FlutterOutline unitOutline = await _computeOutline('''
-import 'package:flutter/widgets.dart';
-
-class MyWidget extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return const Text('my text')
- }
-}
-''');
- var myWidget = unitOutline.children[0];
- var build = myWidget.children[0];
- var textOutline = build.children[0];
-
- expect(textOutline.attributes, hasLength(1));
-
- FlutterOutlineAttribute attribute = textOutline.attributes[0];
- expect(attribute.name, 'data');
+ var attribute = await _getAttribute('test', "'my text'");
expect(attribute.label, "'my text'");
expect(attribute.literalValueString, 'my text');
}
@@ -350,7 +325,7 @@
newFile(testPath, content: code);
AnalysisResult analysisResult = await driver.getResult(testPath);
return new FlutterOutlineComputer(
- testPath, analysisResult.lineInfo, analysisResult.unit)
+ testPath, testCode, analysisResult.lineInfo, analysisResult.unit)
.compute();
}
@@ -360,6 +335,34 @@
expect(outline.length, length);
}
+ Future<FlutterOutlineAttribute> _getAttribute(
+ String name, String value) async {
+ FlutterOutline unitOutline = await _computeOutline('''
+import 'package:flutter/widgets.dart';
+
+main() {
+ new MyWidget($value);
+}
+
+class MyWidget extends StatelessWidget {
+ MyWidget($name);
+
+ @override
+ Widget build(BuildContext context) {
+ return const Text('')
+ }
+}
+''');
+ var main = unitOutline.children[0];
+ var newMyWidget = main.children[0];
+
+ expect(newMyWidget.attributes, hasLength(1));
+
+ var attribute = newMyWidget.attributes[0];
+ expect(attribute.name, name);
+ return attribute;
+ }
+
static String _toText(FlutterOutline outline) {
var buffer = new StringBuffer();
diff --git a/pkg/analyzer/lib/file_system/physical_file_system.dart b/pkg/analyzer/lib/file_system/physical_file_system.dart
index 1812123..2314617 100644
--- a/pkg/analyzer/lib/file_system/physical_file_system.dart
+++ b/pkg/analyzer/lib/file_system/physical_file_system.dart
@@ -40,6 +40,27 @@
}
/**
+ * Return a (semi-)canonicalized version of [path] for the purpose of analysis.
+ *
+ * Using the built-in path's [canonicalize] results in fully lowercase paths on
+ * Windows displayed to the user so this method uses [normalize] and then just
+ * uppercases the drive letter on Windows to resolve the most common issues.
+ */
+String _canonicalize(String path) {
+ path = normalize(path);
+ // Ideally we'd call path's [canonicalize] here to ensure that on
+ // case-insensitive file systems that different casing paths resolved to the
+ // same thing; however these paths are used both as both as part of the
+ // identity and also to display to users in error messages so for now we only
+ // canonicalize the drive letter to resolve the most common issues.
+ // https://github.com/dart-lang/sdk/issues/32095
+ if (io.Platform.isWindows && isAbsolute(path)) {
+ path = path.substring(0, 1).toUpperCase() + path.substring(1);
+ }
+ return path;
+}
+
+/**
* The name of the directory containing plugin specific subfolders used to
* store data across sessions.
*/
@@ -90,13 +111,13 @@
@override
File getFile(String path) {
- path = normalize(path);
+ path = _canonicalize(path);
return new _PhysicalFile(new io.File(path));
}
@override
Folder getFolder(String path) {
- path = normalize(path);
+ path = _canonicalize(path);
return new _PhysicalFolder(new io.Directory(path));
}
@@ -255,7 +276,7 @@
@override
String canonicalizePath(String relPath) {
- return normalize(join(path, relPath));
+ return _canonicalize(join(path, relPath));
}
@override
diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart
index 8102be1..d4475b7 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -906,35 +906,29 @@
// The exported source will be null if the URI in the export
// directive was invalid.
LibraryElement exportedLibrary = exportLibraryMap[exportedSource];
- if (exportedLibrary != null) {
- ExportElementImpl exportElement = new ExportElementImpl(node.offset);
- exportElement.metadata = _getElementAnnotations(node.metadata);
- StringLiteral uriLiteral = node.uri;
+ ExportElementImpl exportElement = new ExportElementImpl(node.offset);
+ exportElement.metadata = _getElementAnnotations(node.metadata);
+ StringLiteral uriLiteral = node.uri;
+ if (uriLiteral != null) {
+ exportElement.uriOffset = uriLiteral.offset;
+ exportElement.uriEnd = uriLiteral.end;
+ }
+ exportElement.uri = node.selectedUriContent;
+ exportElement.combinators = _buildCombinators(node);
+ exportElement.exportedLibrary = exportedLibrary;
+ setElementDocumentationComment(exportElement, node);
+ node.element = exportElement;
+ exports.add(exportElement);
+ if (exportedTime >= 0 &&
+ exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) {
+ int offset = node.offset;
+ int length = node.length;
if (uriLiteral != null) {
- exportElement.uriOffset = uriLiteral.offset;
- exportElement.uriEnd = uriLiteral.end;
+ offset = uriLiteral.offset;
+ length = uriLiteral.length;
}
- exportElement.uri = node.selectedUriContent;
- exportElement.combinators = _buildCombinators(node);
- exportElement.exportedLibrary = exportedLibrary;
- setElementDocumentationComment(exportElement, node);
- node.element = exportElement;
- exports.add(exportElement);
- if (exportedTime >= 0 &&
- exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) {
- int offset = node.offset;
- int length = node.length;
- if (uriLiteral != null) {
- offset = uriLiteral.offset;
- length = uriLiteral.length;
- }
- errors.add(new AnalysisError(
- libraryElement.source,
- offset,
- length,
- CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
- [uriLiteral.toSource()]));
- }
+ errors.add(new AnalysisError(libraryElement.source, offset, length,
+ CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY, [uriLiteral.toSource()]));
}
return null;
}
@@ -948,50 +942,48 @@
// The imported source will be null if the URI in the import
// directive was invalid.
LibraryElement importedLibrary = importLibraryMap[importedSource];
- if (importedLibrary != null) {
- if (importedLibrary.isDartCore) {
- explicitlyImportsCore = true;
+ if (importedLibrary != null && importedLibrary.isDartCore) {
+ explicitlyImportsCore = true;
+ }
+ ImportElementImpl importElement = new ImportElementImpl(node.offset);
+ importElement.metadata = _getElementAnnotations(node.metadata);
+ StringLiteral uriLiteral = node.uri;
+ if (uriLiteral != null) {
+ importElement.uriOffset = uriLiteral.offset;
+ importElement.uriEnd = uriLiteral.end;
+ }
+ importElement.uri = node.selectedUriContent;
+ importElement.deferred = node.deferredKeyword != null;
+ importElement.combinators = _buildCombinators(node);
+ importElement.importedLibrary = importedLibrary;
+ setElementDocumentationComment(importElement, node);
+ SimpleIdentifier prefixNode = node.prefix;
+ if (prefixNode != null) {
+ importElement.prefixOffset = prefixNode.offset;
+ String prefixName = prefixNode.name;
+ PrefixElementImpl prefix = nameToPrefixMap[prefixName];
+ if (prefix == null) {
+ prefix = new PrefixElementImpl.forNode(prefixNode);
+ nameToPrefixMap[prefixName] = prefix;
}
- ImportElementImpl importElement = new ImportElementImpl(node.offset);
- importElement.metadata = _getElementAnnotations(node.metadata);
- StringLiteral uriLiteral = node.uri;
+ importElement.prefix = prefix;
+ prefixNode.staticElement = prefix;
+ }
+ node.element = importElement;
+ imports.add(importElement);
+ if (importedTime >= 0 &&
+ importSourceKindMap[importedSource] != SourceKind.LIBRARY) {
+ int offset = node.offset;
+ int length = node.length;
if (uriLiteral != null) {
- importElement.uriOffset = uriLiteral.offset;
- importElement.uriEnd = uriLiteral.end;
+ offset = uriLiteral.offset;
+ length = uriLiteral.length;
}
- importElement.uri = node.selectedUriContent;
- importElement.deferred = node.deferredKeyword != null;
- importElement.combinators = _buildCombinators(node);
- importElement.importedLibrary = importedLibrary;
- setElementDocumentationComment(importElement, node);
- SimpleIdentifier prefixNode = node.prefix;
- if (prefixNode != null) {
- importElement.prefixOffset = prefixNode.offset;
- String prefixName = prefixNode.name;
- PrefixElementImpl prefix = nameToPrefixMap[prefixName];
- if (prefix == null) {
- prefix = new PrefixElementImpl.forNode(prefixNode);
- nameToPrefixMap[prefixName] = prefix;
- }
- importElement.prefix = prefix;
- prefixNode.staticElement = prefix;
- }
- node.element = importElement;
- imports.add(importElement);
- if (importedTime >= 0 &&
- importSourceKindMap[importedSource] != SourceKind.LIBRARY) {
- int offset = node.offset;
- int length = node.length;
- if (uriLiteral != null) {
- offset = uriLiteral.offset;
- length = uriLiteral.length;
- }
- ErrorCode errorCode = importElement.isDeferred
- ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
- : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
- errors.add(new AnalysisError(libraryElement.source, offset, length,
- errorCode, [uriLiteral.toSource()]));
- }
+ ErrorCode errorCode = importElement.isDeferred
+ ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
+ : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
+ errors.add(new AnalysisError(libraryElement.source, offset, length,
+ errorCode, [uriLiteral.toSource()]));
}
return null;
}
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 2fc90b7..16db292 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -4414,7 +4414,7 @@
? getStaticType(lhs)
: leftVariableElement.type;
- if (_checkForUseOfVoidResult(rhs)) {
+ if (!leftType.isVoid && _checkForUseOfVoidResult(rhs)) {
return;
}
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 08c35e1..b23b0c1 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -2534,17 +2534,20 @@
if (element.nameOffset == nodeOffset) {
node.element = element;
// Verify the exported source kind.
- Source exportedSource = element.exportedLibrary.source;
- int exportedTime = sourceModificationTimeMap[exportedSource] ?? -1;
- if (exportedTime >= 0 &&
- exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) {
- StringLiteral uriLiteral = node.uri;
- errors.add(new AnalysisError(
- _enclosingLibrary.source,
- uriLiteral.offset,
- uriLiteral.length,
- CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
- [uriLiteral.toSource()]));
+ LibraryElement exportedLibrary = element.exportedLibrary;
+ if (exportedLibrary != null) {
+ Source exportedSource = exportedLibrary.source;
+ int exportedTime = sourceModificationTimeMap[exportedSource] ?? -1;
+ if (exportedTime >= 0 &&
+ exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) {
+ StringLiteral uriLiteral = node.uri;
+ errors.add(new AnalysisError(
+ _enclosingLibrary.source,
+ uriLiteral.offset,
+ uriLiteral.length,
+ CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
+ [uriLiteral.toSource()]));
+ }
}
break;
}
@@ -2559,20 +2562,23 @@
if (element.nameOffset == nodeOffset) {
node.element = element;
// Verify the imported source kind.
- Source importedSource = element.importedLibrary.source;
- int importedTime = sourceModificationTimeMap[importedSource] ?? -1;
- if (importedTime >= 0 &&
- importSourceKindMap[importedSource] != SourceKind.LIBRARY) {
- StringLiteral uriLiteral = node.uri;
- ErrorCode errorCode = element.isDeferred
- ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
- : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
- errors.add(new AnalysisError(
- _enclosingLibrary.source,
- uriLiteral.offset,
- uriLiteral.length,
- errorCode,
- [uriLiteral.toSource()]));
+ LibraryElement importedLibrary = element.importedLibrary;
+ if (importedLibrary != null) {
+ Source importedSource = importedLibrary.source;
+ int importedTime = sourceModificationTimeMap[importedSource] ?? -1;
+ if (importedTime >= 0 &&
+ importSourceKindMap[importedSource] != SourceKind.LIBRARY) {
+ StringLiteral uriLiteral = node.uri;
+ ErrorCode errorCode = element.isDeferred
+ ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
+ : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
+ errors.add(new AnalysisError(
+ _enclosingLibrary.source,
+ uriLiteral.offset,
+ uriLiteral.length,
+ errorCode,
+ [uriLiteral.toSource()]));
+ }
}
break;
}
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 e5a4f44..706e1c6 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
@@ -1653,14 +1653,7 @@
p.loadLibrary();
}''');
await computeAnalysisResult(source);
- if (enableNewAnalysisDriver) {
- assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
- } else {
- assertErrors(source, [
- CompileTimeErrorCode.URI_DOES_NOT_EXIST,
- StaticWarningCode.UNDEFINED_IDENTIFIER
- ]);
- }
+ assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
}
test_duplicateConstructorName_named() async {
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index 63c7ba1..d24b269 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -27,311 +27,6 @@
}
@reflectiveTest
-class NonErrorResolverSpecTest extends ResolverTestCase {
- test_inconsistentMethodInheritance_overrideTrumpsInherits_getter() async {
- // 16134
- Source source = addSource(r'''
-class B<S> {
- S get g => null;
-}
-abstract class I<U> {
- U get g => null;
-}
-class C extends B<double> implements I<int> {
- num get g => null;
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_inconsistentMethodInheritance_overrideTrumpsInherits_method() async {
- // 16134
- Source source = addSource(r'''
-class B<S> {
- m(S s) => null;
-}
-abstract class I<U> {
- m(U u) => null;
-}
-class C extends B<double> implements I<int> {
- m(num n) => null;
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_inconsistentMethodInheritance_overrideTrumpsInherits_setter() async {
- // 16134
- Source source = addSource(r'''
-class B<S> {
- set t(S s) {}
-}
-abstract class I<U> {
- set t(U u) {}
-}
-class C extends B<double> implements I<int> {
- set t(num n) {}
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_invocationOfNonFunction_localVariable_dynamic2() async {
- Source source = addSource(r'''
-f() {}
-main() {
- var v = f;
- v = 1;
- v();
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_invocationOfNonFunction_proxyOnFunctionClass() async {
- // 16078
- Source source = addSource(r'''
-@proxy
-class Functor implements Function {
- noSuchMethod(inv) {
- return 42;
- }
-}
-main() {
- Functor f = new Functor();
- f();
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_parameterDefaultDoesNotReferToParameterName() async {
- // The final "f" should refer to the top-level function "f", not to the
- // parameter called "f". See dartbug.com/13179.
- Source source = addSource('void f([void f([x]) = f]) {}');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_proxy_annotation_prefixed() async {
- Source source = addSource(r'''
-library L;
-@proxy
-class A {}
-f(A a) {
- a.m();
- var x = a.g;
- a.s = 1;
- var y = a + a;
- a++;
- ++a;
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_prefixed2() async {
- Source source = addSource(r'''
-library L;
-@proxy
-class A {}
-class B {
- f(A a) {
- a.m();
- var x = a.g;
- a.s = 1;
- var y = a + a;
- a++;
- ++a;
- }
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_prefixed3() async {
- Source source = addSource(r'''
-library L;
-class B {
- f(A a) {
- a.m();
- var x = a.g;
- a.s = 1;
- var y = a + a;
- a++;
- ++a;
- }
-}
-@proxy
-class A {}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_proxyHasPrefixedIdentifier() async {
- Source source = addSource(r'''
-library L;
-import 'dart:core' as core;
-@core.proxy class PrefixProxy {}
-main() {
- new PrefixProxy().foo;
- new PrefixProxy().foo();
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_simple() async {
- Source source = addSource(r'''
-library L;
-@proxy
-class B {
- m() {
- n();
- var x = g;
- s = 1;
- var y = this + this;
- }
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_superclass() async {
- Source source = addSource(r'''
-library L;
-class B extends A {
- m() {
- n();
- var x = g;
- s = 1;
- var y = this + this;
- }
-}
-@proxy
-class A {}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_superclass_mixin() async {
- Source source = addSource(r'''
-library L;
-class B extends Object with A {
- m() {
- n();
- var x = g;
- s = 1;
- var y = this + this;
- }
-}
-@proxy
-class A {}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_superinterface() async {
- Source source = addSource(r'''
-library L;
-class B implements A {
- m() {
- n();
- var x = g;
- s = 1;
- var y = this + this;
- }
-}
-@proxy
-class A {}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- }
-
- test_proxy_annotation_superinterface_infiniteLoop() async {
- addSource(r'''
-library L;
-class C implements A {
- m() {
- n();
- var x = g;
- s = 1;
- var y = this + this;
- }
-}
-class B implements A{}
-class A implements B{}''');
- // Test is that a stack overflow isn't reached in resolution
- // (previous line), no need to assert error set.
- }
-
- test_redirectToInvalidReturnType() async {
- Source source = addSource(r'''
-class A {
- A() {}
-}
-class B extends A {
- factory B() = A;
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_returnOfInvalidType_async_future_int_mismatches_future_null() async {
- Source source = addSource(r'''
-import 'dart:async';
-Future<Null> f() async {
- return 5;
-}
-''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_returnOfInvalidType_dynamicAsTypeArgument() async {
- Source source = addSource(r'''
-class I<T> {
- factory I() => new A<T>();
-}
-class A<T> implements I {
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_typeArgumentNotMatchingBounds_typeArgumentList_0() async {
- Source source = addSource("abstract class A<T extends A>{}");
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- test_typeArgumentNotMatchingBounds_typeArgumentList_1() async {
- Source source = addSource("abstract class A<T extends A<A>>{}");
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
- 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>>>>>>>>>>>>>>>>>>>>>{}");
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-}
-
-@reflectiveTest
class NonErrorResolverTest extends ResolverTestCase {
@override
AnalysisOptions get defaultAnalysisOptions =>
diff --git a/pkg/analyzer/test/generated/static_warning_code_kernel_test.dart b/pkg/analyzer/test/generated/static_warning_code_kernel_test.dart
index 266dedf..4f7c884 100644
--- a/pkg/analyzer/test/generated/static_warning_code_kernel_test.dart
+++ b/pkg/analyzer/test/generated/static_warning_code_kernel_test.dart
@@ -1856,12 +1856,6 @@
@override
@failingTest
- test_generalizedVoid_useOfVoidWithInitializerError() async {
- return super.test_generalizedVoid_useOfVoidWithInitializerError();
- }
-
- @override
- @failingTest
test_generalizedVoid_useOfVoidAssignedToDynamicError() async {
return super.test_generalizedVoid_useOfVoidAssignedToDynamicError();
}
diff --git a/pkg/analyzer/test/generated/static_warning_code_test.dart b/pkg/analyzer/test/generated/static_warning_code_test.dart
index 81eb7e5..8478566 100644
--- a/pkg/analyzer/test/generated/static_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_warning_code_test.dart
@@ -3702,7 +3702,7 @@
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
- test_generalizedVoid_useOfVoidWithInitializerError() async {
+ test_generalizedVoid_useOfVoidWithInitializerOk() async {
Source source = addSource(r'''
void main() {
void x;
@@ -3710,7 +3710,7 @@
}
''');
await computeAnalysisResult(source);
- assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
+ assertNoErrors(source);
}
test_generalizedVoid_useOfVoidAssignedToDynamicError() async {
@@ -4100,13 +4100,12 @@
verify([source]);
}
- @failingTest
test_useOfVoidResult_inForLoop_ok() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
- for(var a = m();;) {}
+ for(void a = m();;) {}
}
}''');
await computeAnalysisResult(source);
@@ -4127,13 +4126,12 @@
verify([source]);
}
- @failingTest
test_useOfVoidResult_variableDeclaration_function_ok() async {
Source source = addSource(r'''
void f() {}
class A {
n() {
- var a = f();
+ void a = f();
}
}''');
await computeAnalysisResult(source);
@@ -4167,13 +4165,12 @@
verify([source]);
}
- @failingTest
test_useOfVoidResult_variableDeclaration_method_ok() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
- var a = m();
+ void a = m();
}
}''');
await computeAnalysisResult(source);
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index 8d963c9..484eb63 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -811,6 +811,20 @@
expect(element, isNotNull);
}
+ void test_computeLibraryElement_unresolvedUris() {
+ Source source = addSource("/lib.dart", r'''
+import 'package:foo/bar.dart';
+export 'package:foo/baz.dart';
+''');
+ var libraryElement = context.computeLibraryElement(source);
+ expect(libraryElement.imports, hasLength(2));
+ expect(libraryElement.exports, hasLength(1));
+ expect(libraryElement.imports[0].uri, 'package:foo/bar.dart');
+ expect(libraryElement.imports[0].importedLibrary, isNull);
+ expect(libraryElement.exports[0].uri, 'package:foo/baz.dart');
+ expect(libraryElement.exports[0].exportedLibrary, isNull);
+ }
+
void test_computeLineInfo_dart() {
Source source = addSource("/test.dart", r'''
library lib;
@@ -2480,15 +2494,6 @@
assertNamedElements(importedLibraries, ["dart.core", "libB"]);
}
- void test_resolveCompilationUnit_library() {
- Source source = addSource("/lib.dart", "library lib;");
- LibraryElement library = context.computeLibraryElement(source);
- CompilationUnit compilationUnit =
- context.resolveCompilationUnit(source, library);
- expect(compilationUnit, isNotNull);
- expect(compilationUnit.element, isNotNull);
- }
-
// void test_resolveCompilationUnit_sourceChangeDuringResolution() {
// _context = new _AnalysisContext_sourceChangeDuringResolution();
// AnalysisContextFactory.initContextWithCore(_context);
@@ -2500,6 +2505,15 @@
// expect(_context.getLineInfo(source), isNotNull);
// }
+ void test_resolveCompilationUnit_library() {
+ Source source = addSource("/lib.dart", "library lib;");
+ LibraryElement library = context.computeLibraryElement(source);
+ CompilationUnit compilationUnit =
+ context.resolveCompilationUnit(source, library);
+ expect(compilationUnit, isNotNull);
+ expect(compilationUnit.element, isNotNull);
+ }
+
void test_resolveCompilationUnit_source() {
Source source = addSource("/lib.dart", "library lib;");
CompilationUnit compilationUnit =
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 18e4279..3ffa729 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -3516,7 +3516,7 @@
test_inferVariableVoid() async {
var mainUnit = await checkFileElement('''
void f() {}
-var x = /*error:USE_OF_VOID_RESULT*/f();
+var x = f();
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
@@ -4309,12 +4309,12 @@
void printRunning() { print("running"); }
var x = run<dynamic>(printRunning);
-var y = /*error:USE_OF_VOID_RESULT*/run(printRunning);
+var y = run(printRunning);
main() {
void printRunning() { print("running"); }
var x = run<dynamic>(printRunning);
- var y = /*error:USE_OF_VOID_RESULT*/run(printRunning);
+ var y = run(printRunning);
x = 123;
x = 'hi';
y = 123;
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart
index e996e68..e2ef187 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart
@@ -200,8 +200,9 @@
}
@override
- void write(String string) {
+ void write(String string, {StringBuffer displayTextBuffer}) {
_buffer.write(string);
+ displayTextBuffer?.write(string);
}
@override
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
index ebbb2f5..e2925d5 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
@@ -316,7 +316,7 @@
@override
void writeOverrideOfInheritedMember(ExecutableElement member,
- {StringBuffer, displayTextBuffer, String returnTypeGroupName}) {
+ {StringBuffer displayTextBuffer, String returnTypeGroupName}) {
// prepare environment
String prefix = getIndent(1);
// may be property
@@ -352,15 +352,20 @@
write(' ');
}
// name
- write(member.displayName);
+ write(member.displayName, displayTextBuffer: displayTextBuffer);
+
// parameters + body
if (isGetter) {
writeln(' => null;');
+ displayTextBuffer?.write(' => ...');
} else {
- writeTypeParameters(member.typeParameters, methodBeingCopied: member);
+ writeTypeParameters(member.typeParameters,
+ methodBeingCopied: member, displayTextBuffer: displayTextBuffer);
List<ParameterElement> parameters = member.parameters;
- writeParameters(parameters, methodBeingCopied: member);
+ writeParameters(parameters,
+ methodBeingCopied: member, displayTextBuffer: displayTextBuffer);
writeln(' {');
+ displayTextBuffer?.write(' {');
// TO-DO
write(prefix2);
writeln('// TODO: implement ${member.displayName}');
@@ -371,6 +376,7 @@
// close method
write(prefix);
writeln('}');
+ displayTextBuffer?.write(' ... }');
}
}
@@ -400,51 +406,52 @@
@override
void writeParameters(Iterable<ParameterElement> parameters,
- {ExecutableElement methodBeingCopied}) {
- write('(');
+ {StringBuffer displayTextBuffer, ExecutableElement methodBeingCopied}) {
+ write('(', displayTextBuffer: displayTextBuffer);
bool sawNamed = false;
bool sawPositional = false;
for (int i = 0; i < parameters.length; i++) {
ParameterElement parameter = parameters.elementAt(i);
if (i > 0) {
- write(', ');
+ write(', ', displayTextBuffer: displayTextBuffer);
}
// may be optional
ParameterKind parameterKind = parameter.parameterKind;
if (parameterKind == ParameterKind.NAMED) {
if (!sawNamed) {
- write('{');
+ write('{', displayTextBuffer: displayTextBuffer);
sawNamed = true;
}
}
if (parameterKind == ParameterKind.POSITIONAL) {
if (!sawPositional) {
- write('[');
+ write('[', displayTextBuffer: displayTextBuffer);
sawPositional = true;
}
}
// parameter
writeParameterSource(parameter.type, parameter.name,
- methodBeingCopied: methodBeingCopied);
+ methodBeingCopied: methodBeingCopied,
+ displayTextBuffer: displayTextBuffer);
// default value
String defaultCode = parameter.defaultValueCode;
if (defaultCode != null) {
if (sawPositional) {
- write(' = ');
+ write(' = ', displayTextBuffer: displayTextBuffer);
} else {
- write(': ');
+ write(': ', displayTextBuffer: displayTextBuffer);
}
- write(defaultCode);
+ write(defaultCode, displayTextBuffer: displayTextBuffer);
}
}
// close parameters
if (sawNamed) {
- write('}');
+ write('}', displayTextBuffer: displayTextBuffer);
}
if (sawPositional) {
- write(']');
+ write(']', displayTextBuffer: displayTextBuffer);
}
- write(')');
+ write(')', displayTextBuffer: displayTextBuffer);
}
@override
@@ -472,13 +479,13 @@
@override
void writeParameterSource(DartType type, String name,
- {ExecutableElement methodBeingCopied}) {
+ {StringBuffer displayTextBuffer, ExecutableElement methodBeingCopied}) {
_EnclosingElementFinder finder = new _EnclosingElementFinder();
finder.find(dartFileEditBuilder.unit, offset);
String parameterSource = _getTypeSource(
type, finder.enclosingClass, finder.enclosingExecutable,
parameterName: name, methodBeingCopied: methodBeingCopied);
- write(parameterSource);
+ write(parameterSource, displayTextBuffer: displayTextBuffer);
}
@override
@@ -516,8 +523,8 @@
@override
void writeTypeParameter(TypeParameterElement typeParameter,
- {ExecutableElement methodBeingCopied}) {
- write(typeParameter.name);
+ {StringBuffer displayTextBuffer, ExecutableElement methodBeingCopied}) {
+ write(typeParameter.name, displayTextBuffer: displayTextBuffer);
if (typeParameter.bound != null) {
_EnclosingElementFinder finder = new _EnclosingElementFinder();
finder.find(dartFileEditBuilder.unit, offset);
@@ -525,26 +532,28 @@
finder.enclosingExecutable,
methodBeingCopied: methodBeingCopied);
if (bound != null) {
- write(' extends ');
- write(bound);
+ write(' extends ', displayTextBuffer: displayTextBuffer);
+ write(bound, displayTextBuffer: displayTextBuffer);
}
}
}
@override
void writeTypeParameters(List<TypeParameterElement> typeParameters,
- {ExecutableElement methodBeingCopied}) {
+ {StringBuffer displayTextBuffer, ExecutableElement methodBeingCopied}) {
if (typeParameters.isNotEmpty) {
- write('<');
+ write('<', displayTextBuffer: displayTextBuffer);
bool isFirst = true;
for (TypeParameterElement typeParameter in typeParameters) {
if (!isFirst) {
- write(', ');
+ write(', ', displayTextBuffer: displayTextBuffer);
}
isFirst = false;
- writeTypeParameter(typeParameter, methodBeingCopied: methodBeingCopied);
+ writeTypeParameter(typeParameter,
+ methodBeingCopied: methodBeingCopied,
+ displayTextBuffer: displayTextBuffer);
}
- write('>');
+ write('>', displayTextBuffer: displayTextBuffer);
}
}
diff --git a/pkg/analyzer_plugin/lib/utilities/assist/assist.dart b/pkg/analyzer_plugin/lib/utilities/assist/assist.dart
index 80dac24..16f713a 100644
--- a/pkg/analyzer_plugin/lib/utilities/assist/assist.dart
+++ b/pkg/analyzer_plugin/lib/utilities/assist/assist.dart
@@ -83,9 +83,9 @@
*/
class AssistKind {
/**
- * The name of this kind of assist, used for debugging.
+ * The unique identifier of this kind of assist.
*/
- final String name;
+ final String id;
/**
* The priority of this kind of assist for the kind of error being addressed.
@@ -101,13 +101,13 @@
final String message;
/**
- * Initialize a newly created kind of assist to have the given [name],
- * [relevance] and [message].
+ * Initialize a newly created kind of assist to have the given [id],
+ * [priority] and [message].
*/
- const AssistKind(this.name, this.priority, this.message);
+ const AssistKind(this.id, this.priority, this.message);
@override
- String toString() => name;
+ String toString() => id;
}
/**
diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
index 4acdff3..e255aa1 100644
--- a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
@@ -900,7 +900,7 @@
// TODO: implement add
return null;
}
-''');
+''', displayText: 'add(A a) { ... }');
}
test_writeOverrideOfInheritedMember_method_functionTypeAlias() async {
@@ -916,7 +916,7 @@
void perform(F f) {
// TODO: implement perform
}
-''');
+''', displayText: 'perform(F f) { ... }');
}
test_writeOverrideOfInheritedMember_method_functionTypedParameter() async {
@@ -932,7 +932,7 @@
forEach(int Function(double p1, String p2) f) {
// TODO: implement forEach
}
-''');
+''', displayText: 'forEach(int Function(double p1, String p2) f) { ... }');
}
test_writeOverrideOfInheritedMember_method_generic_noBounds() async {
@@ -948,7 +948,7 @@
// TODO: implement get
return null;
}
-''');
+''', displayText: 'get<T>(T key) { ... }');
}
test_writeOverrideOfInheritedMember_method_generic_withBounds() async {
@@ -964,7 +964,7 @@
// TODO: implement get
return null;
}
-''');
+''', displayText: 'get<T extends V2>(K2 key) { ... }');
}
test_writeOverrideOfInheritedMember_method_genericFunctionTypedParameter() async {
@@ -981,29 +981,24 @@
// TODO: implement foo
return null;
}
-''');
+''', displayText: 'foo(T Function<T>() fn) { ... }');
}
test_writeOverrideOfInheritedMember_method_nullAsTypeArgument() async {
- await _assertWriteOverrideOfInheritedMethod(
- '''
+ await _assertWriteOverrideOfInheritedMethod('''
abstract class A {
List<Null> foo();
}
class B extends A {
}
-''',
- '''
+''', '''
@override
List<Null> foo() {
// TODO: implement foo
return null;
}
-''',
- // TODO(pquitslund): Add tests once implemented.
- //displayText: 'foo() { ... }'
- );
+''', displayText: 'foo() { ... }');
}
test_writeOverrideOfInheritedMember_method_voidAsTypeArgument() async {
@@ -1020,7 +1015,7 @@
// TODO: implement foo
return null;
}
-''');
+''', displayText: 'foo() { ... }');
}
test_writeParameterMatchingArgument() async {
diff --git a/pkg/compiler/lib/src/compile_time_constants.dart b/pkg/compiler/lib/src/compile_time_constants.dart
index 521bdd6..aa51632 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -16,7 +16,6 @@
import 'constants/values.dart';
import 'common_elements.dart' show CommonElements;
import 'elements/elements.dart';
-import 'elements/entities.dart';
import 'elements/modelx.dart' show ConstantVariableMixin;
import 'elements/operators.dart';
import 'elements/resolution_types.dart';
@@ -1262,9 +1261,9 @@
new ConstructedConstantExpression(
type, targetConstructor, callStructure, arguments);
- Map<FieldEntity, ConstantExpression> fields = expression
- .computeInstanceFields(new AstEvaluationEnvironment(compiler));
- fields.forEach((_field, ConstantExpression expression) {
+ InstanceData instanceData = expression
+ .computeInstanceData(new AstEvaluationEnvironment(compiler));
+ instanceData.fieldMap.forEach((_field, ConstantExpression expression) {
FieldElement field = _field;
ConstantValue value = expression.evaluate(
new AstEvaluationEnvironment(compiler), constantSystem);
@@ -1481,4 +1480,7 @@
@override
DiagnosticReporter get reporter => _compiler.reporter;
+
+ @override
+ bool get enableAssertions => _compiler.options.enableUserAssertions;
}
diff --git a/pkg/compiler/lib/src/constants/constant_constructors.dart b/pkg/compiler/lib/src/constants/constant_constructors.dart
index d65b873..288c063 100644
--- a/pkg/compiler/lib/src/constants/constant_constructors.dart
+++ b/pkg/compiler/lib/src/constants/constant_constructors.dart
@@ -92,7 +92,11 @@
}
});
return new GenerativeConstantConstructor(
- currentClass.thisType, defaultValues, fieldMap, constructorInvocation);
+ currentClass.thisType,
+ defaultValues,
+ fieldMap,
+ const <AssertConstantExpression>[],
+ constructorInvocation);
}
ConstantConstructor visitRedirectingGenerativeConstructorDeclaration(
diff --git a/pkg/compiler/lib/src/constants/constructors.dart b/pkg/compiler/lib/src/constants/constructors.dart
index b7e4ba4..7924b20 100644
--- a/pkg/compiler/lib/src/constants/constructors.dart
+++ b/pkg/compiler/lib/src/constants/constructors.dart
@@ -18,6 +18,13 @@
ERRONEOUS,
}
+class InstanceData {
+ final Map<FieldEntity, ConstantExpression> fieldMap;
+ final List<AssertConstantExpression> assertions;
+
+ InstanceData(this.fieldMap, this.assertions);
+}
+
/// Definition of a constant constructor.
abstract class ConstantConstructor {
ConstantConstructorKind get kind;
@@ -27,12 +34,11 @@
InterfaceType computeInstanceType(
EvaluationEnvironment environment, InterfaceType newType);
- /// Computes the constant expressions of the fields of the created instance
- /// in a const constructor invocation with [arguments].
- Map<FieldEntity, ConstantExpression> computeInstanceFields(
- EvaluationEnvironment environment,
- List<ConstantExpression> arguments,
- CallStructure callStructure);
+ /// Computes the constant expressions of the fields and initializer assertions
+ /// of the created instance in a const constructor invocation with
+ /// [arguments].
+ InstanceData computeInstanceData(EvaluationEnvironment environment,
+ List<ConstantExpression> arguments, CallStructure callStructure);
accept(ConstantConstructorVisitor visitor, arg);
}
@@ -62,10 +68,11 @@
final InterfaceType type;
final Map<dynamic /*int|String*/, ConstantExpression> defaultValues;
final Map<FieldEntity, ConstantExpression> fieldMap;
+ final List<AssertConstantExpression> assertions;
final ConstructedConstantExpression superConstructorInvocation;
GenerativeConstantConstructor(this.type, this.defaultValues, this.fieldMap,
- this.superConstructorInvocation);
+ this.assertions, this.superConstructorInvocation);
ConstantConstructorKind get kind => ConstantConstructorKind.GENERATIVE;
@@ -74,18 +81,19 @@
return environment.substByContext(type, newType);
}
- Map<FieldEntity, ConstantExpression> computeInstanceFields(
- EvaluationEnvironment environment,
- List<ConstantExpression> arguments,
- CallStructure callStructure) {
+ InstanceData computeInstanceData(EvaluationEnvironment environment,
+ List<ConstantExpression> arguments, CallStructure callStructure) {
NormalizedArguments args =
new NormalizedArguments(defaultValues, callStructure, arguments);
- Map<FieldEntity, ConstantExpression> appliedFieldMap =
- applyFields(environment, args, superConstructorInvocation);
+ InstanceData appliedInstanceData =
+ applyInstanceData(environment, args, superConstructorInvocation);
fieldMap.forEach((FieldEntity field, ConstantExpression constant) {
- appliedFieldMap[field] = constant.apply(args);
+ appliedInstanceData.fieldMap[field] = constant.apply(args);
});
- return appliedFieldMap;
+ for (AssertConstantExpression assertion in assertions) {
+ appliedInstanceData.assertions.add(assertion.apply(args));
+ }
+ return appliedInstanceData;
}
accept(ConstantConstructorVisitor visitor, arg) {
@@ -138,24 +146,30 @@
/// [constructorInvocation]. If [constructorInvocation] is `null`, an empty
/// map is created. Returns `null` if an erroneous constant constructor was
/// encountered in the super-chain.
- static Map<FieldEntity, ConstantExpression> applyFields(
+ static InstanceData applyInstanceData(
EvaluationEnvironment environment,
NormalizedArguments args,
ConstructedConstantExpression constructorInvocation) {
Map<FieldEntity, ConstantExpression> appliedFieldMap =
<FieldEntity, ConstantExpression>{};
+ List<AssertConstantExpression> appliedAssertions =
+ <AssertConstantExpression>[];
if (constructorInvocation != null) {
- Map<FieldEntity, ConstantExpression> fieldMap =
- constructorInvocation.computeInstanceFields(environment);
- if (fieldMap == null) {
+ InstanceData instanceData =
+ constructorInvocation.computeInstanceData(environment);
+ if (instanceData == null) {
// An erroneous constant constructor was encountered in the super-chain.
return null;
}
- fieldMap.forEach((FieldEntity field, ConstantExpression constant) {
+ instanceData.fieldMap
+ .forEach((FieldEntity field, ConstantExpression constant) {
appliedFieldMap[field] = constant.apply(args);
});
+ for (AssertConstantExpression assertion in instanceData.assertions) {
+ appliedAssertions.add(assertion.apply(args));
+ }
}
- return appliedFieldMap;
+ return new InstanceData(appliedFieldMap, appliedAssertions);
}
}
@@ -177,16 +191,13 @@
thisConstructorInvocation.computeInstanceType(environment), newType);
}
- Map<FieldEntity, ConstantExpression> computeInstanceFields(
- EvaluationEnvironment environment,
- List<ConstantExpression> arguments,
- CallStructure callStructure) {
+ InstanceData computeInstanceData(EvaluationEnvironment environment,
+ List<ConstantExpression> arguments, CallStructure callStructure) {
NormalizedArguments args =
new NormalizedArguments(defaultValues, callStructure, arguments);
- Map<FieldEntity, ConstantExpression> appliedFieldMap =
- GenerativeConstantConstructor.applyFields(
- environment, args, thisConstructorInvocation);
- return appliedFieldMap;
+ InstanceData appliedInstanceData = GenerativeConstantConstructor
+ .applyInstanceData(environment, args, thisConstructorInvocation);
+ return appliedInstanceData;
}
accept(ConstantConstructorVisitor visitor, arg) {
@@ -234,13 +245,11 @@
targetConstructorInvocation.computeInstanceType(environment), newType);
}
- Map<FieldEntity, ConstantExpression> computeInstanceFields(
- EvaluationEnvironment environment,
- List<ConstantExpression> arguments,
- CallStructure callStructure) {
+ InstanceData computeInstanceData(EvaluationEnvironment environment,
+ List<ConstantExpression> arguments, CallStructure callStructure) {
ConstantConstructor constantConstructor =
environment.getConstructorConstant(targetConstructorInvocation.target);
- return constantConstructor.computeInstanceFields(
+ return constantConstructor.computeInstanceData(
environment, arguments, callStructure);
}
@@ -278,10 +287,8 @@
}
@override
- Map<FieldEntity, ConstantExpression> computeInstanceFields(
- EvaluationEnvironment environment,
- List<ConstantExpression> arguments,
- CallStructure callStructure) {
+ InstanceData computeInstanceData(EvaluationEnvironment environment,
+ List<ConstantExpression> arguments, CallStructure callStructure) {
return null;
}
diff --git a/pkg/compiler/lib/src/constants/evaluation.dart b/pkg/compiler/lib/src/constants/evaluation.dart
index 38dfacc..cdb11cc 100644
--- a/pkg/compiler/lib/src/constants/evaluation.dart
+++ b/pkg/compiler/lib/src/constants/evaluation.dart
@@ -47,6 +47,9 @@
ConstructorEntity constructor, ConstantValue evaluate());
ConstantValue evaluateField(FieldEntity field, ConstantValue evaluate());
+
+ /// `true` if assertions are enabled.
+ bool get enableAssertions;
}
abstract class EvaluationEnvironmentBase implements EvaluationEnvironment {
@@ -60,6 +63,20 @@
DiagnosticReporter get reporter;
+ /// Returns the [Spannable] used for reporting errors and warnings.
+ ///
+ /// Returns the second-to-last in the spannable stack, if available, to point
+ /// to the use, rather than the declaration, of a constructor or field.
+ ///
+ /// For instance
+ ///
+ /// const foo = const bool.fromEnvironment("foo", default: 0);
+ ///
+ /// will point to `foo` instead of the declaration of `bool.fromEnvironment`.
+ Spannable get _spannable => _spannableStack.tail.isEmpty
+ ? _spannableStack.head
+ : _spannableStack.tail.head;
+
@override
ConstantValue evaluateField(FieldEntity field, ConstantValue evaluate()) {
if (_currentlyEvaluatedFields.add(field)) {
@@ -90,7 +107,7 @@
ConstantExpression expression, MessageKind kind, Map arguments) {
if (constantRequired) {
// TODO(johnniwinther): Should [ConstantExpression] have a location?
- reporter.reportErrorMessage(_spannableStack.head, kind, arguments);
+ reporter.reportErrorMessage(_spannable, kind, arguments);
}
}
@@ -98,7 +115,7 @@
void reportWarning(
ConstantExpression expression, MessageKind kind, Map arguments) {
if (constantRequired) {
- reporter.reportWarningMessage(_spannableStack.head, kind, arguments);
+ reporter.reportWarningMessage(_spannable, kind, arguments);
}
}
}
diff --git a/pkg/compiler/lib/src/constants/expressions.dart b/pkg/compiler/lib/src/constants/expressions.dart
index d189156..ae50ac0 100644
--- a/pkg/compiler/lib/src/constants/expressions.dart
+++ b/pkg/compiler/lib/src/constants/expressions.dart
@@ -43,6 +43,7 @@
LOCAL_VARIABLE,
POSITIONAL_REFERENCE,
NAMED_REFERENCE,
+ ASSERT,
}
/// An expression that is a compile-time constant.
@@ -564,13 +565,12 @@
sb.write('])');
}
- Map<FieldEntity, ConstantExpression> computeInstanceFields(
- EvaluationEnvironment environment) {
+ InstanceData computeInstanceData(EvaluationEnvironment environment) {
ConstantConstructor constantConstructor =
environment.getConstructorConstant(target);
assert(constantConstructor != null,
failedAt(target, "No constant constructor computed for $target."));
- return constantConstructor.computeInstanceFields(
+ return constantConstructor.computeInstanceData(
environment, arguments, callStructure);
}
@@ -589,15 +589,15 @@
ConstantValue evaluate(
EvaluationEnvironment environment, ConstantSystem constantSystem) {
return environment.evaluateConstructor(target, () {
- Map<FieldEntity, ConstantExpression> fieldMap =
- computeInstanceFields(environment);
- if (fieldMap == null) {
+ InstanceData instanceData = computeInstanceData(environment);
+ if (instanceData == null) {
return new NonConstantValue();
}
bool isValidAsConstant = true;
Map<FieldEntity, ConstantValue> fieldValues =
<FieldEntity, ConstantValue>{};
- fieldMap.forEach((FieldEntity field, ConstantExpression constant) {
+ instanceData.fieldMap
+ .forEach((FieldEntity field, ConstantExpression constant) {
ConstantValue value = constant.evaluate(environment, constantSystem);
assert(
value != null,
@@ -609,6 +609,11 @@
isValidAsConstant = false;
}
});
+ for (AssertConstantExpression assertion in instanceData.assertions) {
+ if (!assertion.evaluate(environment, constantSystem).isConstant) {
+ isValidAsConstant = false;
+ }
+ }
if (isValidAsConstant) {
return new ConstructedConstantValue(
computeInstanceType(environment), fieldValues);
@@ -1919,6 +1924,85 @@
commonElements.stringType;
}
+class AssertConstantExpression extends ConstantExpression {
+ final ConstantExpression condition;
+ final ConstantExpression message;
+
+ AssertConstantExpression(this.condition, this.message);
+
+ @override
+ ConstantExpressionKind get kind => ConstantExpressionKind.ASSERT;
+
+ @override
+ bool _equals(AssertConstantExpression other) {
+ return condition == other.condition && message == other.message;
+ }
+
+ @override
+ int _computeHashCode() {
+ return 13 * condition.hashCode + 17 * message.hashCode;
+ }
+
+ @override
+ void _createStructuredText(StringBuffer sb) {
+ sb.write('assert(');
+ condition._createStructuredText(sb);
+ sb.write(',message=');
+ if (message != null) {
+ message._createStructuredText(sb);
+ } else {
+ sb.write('null');
+ }
+ sb.write(')');
+ }
+
+ @override
+ ConstantValue evaluate(
+ EvaluationEnvironment environment, ConstantSystem constantSystem) {
+ ConstantValue conditionValue =
+ condition.evaluate(environment, constantSystem);
+ bool validAssert;
+ if (environment.enableAssertions) {
+ // Boolean conversion:
+ validAssert =
+ conditionValue is BoolConstantValue && conditionValue.primitiveValue;
+ } else {
+ validAssert = true;
+ }
+ if (!validAssert) {
+ if (message != null) {
+ ConstantValue value = message.evaluate(environment, constantSystem);
+ if (value is PrimitiveConstantValue) {
+ String text = '${value.primitiveValue}';
+ environment.reportError(this,
+ MessageKind.INVALID_ASSERT_VALUE_MESSAGE, {'message': text});
+ } else {
+ environment.reportError(this, MessageKind.INVALID_ASSERT_VALUE,
+ {'assertion': condition.toDartText()});
+ // TODO(johnniwinther): Report invalid constant message?
+ }
+ } else {
+ environment.reportError(this, MessageKind.INVALID_ASSERT_VALUE,
+ {'assertion': condition.toDartText()});
+ }
+ return new NonConstantValue();
+ }
+
+ // Return a valid constant value to signal that assertion didn't fail.
+ return new NullConstantValue();
+ }
+
+ @override
+ accept(ConstantExpressionVisitor visitor, [context]) {
+ return visitor.visitAssert(this, context);
+ }
+
+ ConstantExpression apply(NormalizedArguments arguments) {
+ return new AssertConstantExpression(
+ condition.apply(arguments), message?.apply(arguments));
+ }
+}
+
/// A constant expression referenced with a deferred prefix.
/// For example `lib.C`.
class DeferredConstantExpression extends ConstantExpression {
@@ -2001,6 +2085,7 @@
R visitStringFromEnvironment(
StringFromEnvironmentConstantExpression exp, A context);
R visitDeferred(DeferredConstantExpression exp, A context);
+ R visitAssert(AssertConstantExpression exp, A context);
R visitPositional(PositionalArgumentReference exp, A context);
R visitNamed(NamedArgumentReference exp, A context);
@@ -2278,5 +2363,16 @@
sb.write(')');
}
+ @override
+ void visitAssert(AssertConstantExpression exp, [_]) {
+ sb.write('assert(');
+ visit(exp.condition);
+ if (exp.message != null) {
+ sb.write(', ');
+ visit(exp.message);
+ }
+ sb.write(')');
+ }
+
String toString() => sb.toString();
}
diff --git a/pkg/compiler/lib/src/diagnostics/messages.dart b/pkg/compiler/lib/src/diagnostics/messages.dart
index bd60f84..35e0838 100644
--- a/pkg/compiler/lib/src/diagnostics/messages.dart
+++ b/pkg/compiler/lib/src/diagnostics/messages.dart
@@ -198,6 +198,8 @@
INSTANCE_STATIC_SAME_NAME_CONT,
INTERNAL_LIBRARY,
INTERNAL_LIBRARY_FROM,
+ INVALID_ASSERT_VALUE,
+ INVALID_ASSERT_VALUE_MESSAGE,
INVALID_ARGUMENT_AFTER_NAMED,
INVALID_AWAIT,
INVALID_AWAIT_FOR,
@@ -3608,6 +3610,13 @@
"Constructor '#{constructorName}' is not a valid constant "
"constructor."),
+ MessageKind.INVALID_ASSERT_VALUE: const MessageTemplate(
+ MessageKind.INVALID_ASSERT_VALUE, "Assertion '#{assertion}' failed."),
+
+ MessageKind.INVALID_ASSERT_VALUE_MESSAGE: const MessageTemplate(
+ MessageKind.INVALID_ASSERT_VALUE_MESSAGE,
+ "Assertion failed: #{message}"),
+
//////////////////////////////////////////////////////////////////////////////
// Patch errors start.
//////////////////////////////////////////////////////////////////////////////
diff --git a/pkg/compiler/lib/src/js_emitter/model.dart b/pkg/compiler/lib/src/js_emitter/model.dart
index c3207c7..bebb3ac 100644
--- a/pkg/compiler/lib/src/js_emitter/model.dart
+++ b/pkg/compiler/lib/src/js_emitter/model.dart
@@ -189,7 +189,7 @@
Constant(this.name, this.holder, this.value);
String toString() {
- return 'Constant(name=${name},value=${value.toStructuredText()})';
+ return 'Constant(name=${name.key},value=${value.toStructuredText()})';
}
}
@@ -233,7 +233,7 @@
this.isLazy);
String toString() {
- return 'StaticField(name=${name},element=${element})';
+ return 'StaticField(name=${name.key},element=${element})';
}
}
@@ -363,7 +363,7 @@
_mixinClass = mixinClass;
}
- String toString() => 'Mixin(name=${name},element=$element)';
+ String toString() => 'Mixin(name=${name.key},element=$element)';
}
/// A field.
@@ -409,7 +409,7 @@
bool get needsInterceptedSetterOnThis => setterFlags == 3;
String toString() {
- return 'Field(name=${name},element=${element})';
+ return 'Field(name=${name.key},element=${element})';
}
}
@@ -511,7 +511,7 @@
bool get isStatic => false;
String toString() {
- return 'InstanceMethod(name=${name},element=${element}'
+ return 'InstanceMethod(name=${name.key},element=${element}'
',code=${js.nodeToString(code)})';
}
}
@@ -550,7 +550,7 @@
: super(name, code);
String toString() {
- return 'ParameterStubMethod(name=${name},element=${element}'
+ return 'ParameterStubMethod(name=${name.key},element=${element}'
',code=${js.nodeToString(code)})';
}
}
@@ -588,7 +588,7 @@
bool get isStatic => true;
String toString() {
- return 'StaticDartMethod(name=${name},element=${element}'
+ return 'StaticDartMethod(name=${name.key},element=${element}'
',code=${js.nodeToString(code)})';
}
}
@@ -599,7 +599,7 @@
: super(name, code);
String toString() {
- return 'StaticStubMethod(name=${name},element=${element}}'
+ return 'StaticStubMethod(name=${name.key},element=${element}}'
',code=${js.nodeToString(code)})';
}
}
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index 30499d6..980faf4 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -938,8 +938,8 @@
IndexedConstructor constructor;
if (node is ir.Constructor) {
functionNode = node.function;
- constructor = createGenerativeConstructor(
- enclosingClass, name, _getParameterStructure(functionNode),
+ constructor = createGenerativeConstructor(enclosingClass, name,
+ _getParameterStructure(functionNode, includeTypeParameters: false),
isExternal: isExternal, isConst: node.isConst);
definition = new SpecialMemberDefinition(
constructor, node, MemberKind.constructor);
@@ -948,8 +948,8 @@
bool isFromEnvironment = isExternal &&
name.text == 'fromEnvironment' &&
const ['int', 'bool', 'String'].contains(enclosingClass.name);
- constructor = createFactoryConstructor(
- enclosingClass, name, _getParameterStructure(functionNode),
+ constructor = createFactoryConstructor(enclosingClass, name,
+ _getParameterStructure(functionNode, includeTypeParameters: false),
isExternal: isExternal,
isConst: node.isConst,
isFromEnvironmentConstructor: isFromEnvironment);
@@ -1034,15 +1034,21 @@
});
}
- ParameterStructure _getParameterStructure(ir.FunctionNode node) {
+ ParameterStructure _getParameterStructure(ir.FunctionNode node,
+ // TODO(johnniwinther): Remove this when type arguments are passed to
+ // constructors like calling a generic method.
+ {bool includeTypeParameters: true}) {
// TODO(johnniwinther): Cache the computed function type.
int requiredParameters = node.requiredParameterCount;
int positionalParameters = node.positionalParameters.length;
int typeParameters = node.typeParameters.length;
List<String> namedParameters =
node.namedParameters.map((p) => p.name).toList()..sort();
- return new ParameterStructure(requiredParameters, positionalParameters,
- namedParameters, options.strongMode ? typeParameters : 0);
+ return new ParameterStructure(
+ requiredParameters,
+ positionalParameters,
+ namedParameters,
+ options.strongMode && includeTypeParameters ? typeParameters : 0);
}
IndexedLibrary createLibrary(String name, Uri canonicalUri);
@@ -1807,6 +1813,9 @@
@override
DiagnosticReporter get reporter => _elementMap.reporter;
+
+ @override
+ bool get enableAssertions => _elementMap.options.enableUserAssertions;
}
class KernelResolutionWorldBuilder extends KernelResolutionWorldBuilderBase {
diff --git a/pkg/compiler/lib/src/kernel/element_map_mixins.dart b/pkg/compiler/lib/src/kernel/element_map_mixins.dart
index 9117831..2041dd4 100644
--- a/pkg/compiler/lib/src/kernel/element_map_mixins.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_mixins.dart
@@ -878,6 +878,7 @@
}
ConstructedConstantExpression superConstructorInvocation;
+ List<AssertConstantExpression> assertions = <AssertConstantExpression>[];
for (ir.Initializer initializer in node.initializers) {
if (initializer is ir.FieldInitializer) {
registerField(initializer.field, visit(initializer.value));
@@ -888,14 +889,11 @@
superConstructorInvocation = _computeConstructorInvocation(
initializer.target, initializer.arguments);
} else if (initializer is ir.AssertInitializer) {
- // Assert in initializer is currently not supported in dart2js.
- // TODO(johnniwinther): Support assert in initializer.
- String constructorName = '${cls.name}.${node.name}';
- elementMap.reporter.reportErrorMessage(
- computeSourceSpanFromTreeNode(initializer),
- MessageKind.INVALID_CONSTANT_CONSTRUCTOR,
- {'constructorName': constructorName});
- return new ErroneousConstantConstructor();
+ ConstantExpression condition = visit(initializer.statement.condition);
+ ConstantExpression message = initializer.statement.message != null
+ ? visit(initializer.statement.message)
+ : null;
+ assertions.add(new AssertConstantExpression(condition, message));
} else if (initializer is ir.InvalidInitializer) {
String constructorName = '${cls.name}.${node.name}';
elementMap.reporter.reportErrorMessage(
@@ -926,8 +924,8 @@
return new RedirectingGenerativeConstantConstructor(
defaultValues, superConstructorInvocation);
} else {
- return new GenerativeConstantConstructor(
- type, defaultValues, fieldMap, superConstructorInvocation);
+ return new GenerativeConstantConstructor(type, defaultValues, fieldMap,
+ assertions, superConstructorInvocation);
}
}
}
diff --git a/pkg/compiler/lib/src/resolution/constructors.dart b/pkg/compiler/lib/src/resolution/constructors.dart
index 8d721f4..ba5ec7b 100644
--- a/pkg/compiler/lib/src/resolution/constructors.dart
+++ b/pkg/compiler/lib/src/resolution/constructors.dart
@@ -479,6 +479,7 @@
constructor.enclosingClass.thisType,
defaultValues,
fieldInitializers,
+ const <AssertConstantExpression>[],
constructorInvocation);
}
}
diff --git a/pkg/compiler/lib/src/serialization/constant_serialization.dart b/pkg/compiler/lib/src/serialization/constant_serialization.dart
index 69d4418..b1eaa93 100644
--- a/pkg/compiler/lib/src/serialization/constant_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/constant_serialization.dart
@@ -193,6 +193,11 @@
encoder.setElement(Key.IMPORT, exp.import as ImportElement);
encoder.setConstant(Key.EXPRESSION, exp.expression);
}
+
+ @override
+ void visitAssert(AssertConstantExpression exp, ObjectEncoder context) {
+ throw new UnsupportedError("AssertConstantExpression is not supported.");
+ }
}
/// Utility class for deserializing [ConstantExpression]s.
@@ -299,6 +304,7 @@
decoder.getConstant(Key.EXPRESSION),
decoder.getElement(Key.IMPORT) as ImportElement);
case ConstantExpressionKind.SYNTHETIC:
+ case ConstantExpressionKind.ASSERT:
}
throw new UnsupportedError("Unexpected constant kind: ${kind} in $decoder");
}
@@ -428,7 +434,11 @@
case ConstantConstructorKind.GENERATIVE:
ResolutionInterfaceType type = readType();
return new GenerativeConstantConstructor(
- type, readDefaults(), readFields(), readConstructorInvocation());
+ type,
+ readDefaults(),
+ readFields(),
+ const <AssertConstantExpression>[],
+ readConstructorInvocation());
case ConstantConstructorKind.REDIRECTING_GENERATIVE:
return new RedirectingGenerativeConstantConstructor(
readDefaults(), readConstructorInvocation());
diff --git a/pkg/compiler/lib/src/serialization/equivalence.dart b/pkg/compiler/lib/src/serialization/equivalence.dart
index 9fef23a..3deda32 100644
--- a/pkg/compiler/lib/src/serialization/equivalence.dart
+++ b/pkg/compiler/lib/src/serialization/equivalence.dart
@@ -930,6 +930,15 @@
strategy.testConstants(
exp1, exp2, 'expression', exp1.expression, exp2.expression);
}
+
+ @override
+ bool visitAssert(
+ AssertConstantExpression exp1, covariant AssertConstantExpression exp2) {
+ return strategy.testConstants(
+ exp1, exp2, 'condition', exp1.condition, exp2.condition) &&
+ strategy.testConstants(
+ exp1, exp2, 'message', exp1.message, exp2.message);
+ }
}
/// Visitor that checks for structural equivalence of [ConstantValue]s.
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 9d4b34a..096366f 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -4922,7 +4922,8 @@
failedAt(
function,
"Only ${argumentIndex} of ${compiledArguments.length} "
- "arguments have been read from: ${compiledArguments}"));
+ "arguments have been read from: ${compiledArguments} passed to "
+ "$function."));
_returnType =
_elementMap.elementEnvironment.getFunctionType(function).returnType;
diff --git a/pkg/compiler/lib/src/use_unused_api.dart b/pkg/compiler/lib/src/use_unused_api.dart
index fa487cb..6edbf01 100644
--- a/pkg/compiler/lib/src/use_unused_api.dart
+++ b/pkg/compiler/lib/src/use_unused_api.dart
@@ -104,7 +104,7 @@
constant.isObject;
cs.isBool(constant);
constructedConstant.computeInstanceType(null);
- constructedConstant.computeInstanceFields(null);
+ constructedConstant.computeInstanceData(null);
expression.evaluate(null, null);
new NullConstantConstructorVisitor()
..visit(null, null)
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 3228ddf..740e940 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -3012,9 +3012,44 @@
debugEvent("Assert");
Expression message = popForValueIfNotNull(commaToken);
Expression condition = popForValue();
+
+ // Compute start and end offsets for the condition expression.
+ // This code is a temporary workaround because expressions don't carry
+ // their start and end offsets currently.
+ //
+ // The token that follows leftParenthesis is considered to be the
+ // first token of the condition.
+ // TODO(ahe): this really should be condition.fileOffset.
+ int startOffset = leftParenthesis.next.offset;
+ int endOffset;
+ {
+ // Search forward from leftParenthesis to find the last token of
+ // the condition - which is a token immediately followed by a commaToken,
+ // right parenthesis or a trailing comma.
+ Token conditionBoundary = commaToken ?? leftParenthesis.endGroup;
+ Token conditionLastToken = leftParenthesis;
+ while (!conditionLastToken.isEof) {
+ Token nextToken = conditionLastToken.next;
+ if (nextToken == conditionBoundary) {
+ break;
+ } else if (optional(',', nextToken) &&
+ nextToken.next == conditionBoundary) {
+ // The next token is trailing comma, which means current token is
+ // the last token of the condition.
+ break;
+ }
+ conditionLastToken = nextToken;
+ }
+ if (conditionLastToken.isEof) {
+ endOffset = startOffset = -1;
+ } else {
+ endOffset = conditionLastToken.offset + conditionLastToken.length;
+ }
+ }
+
AssertStatement statement = new ShadowAssertStatement(condition,
- conditionStartOffset: leftParenthesis.offset + 1,
- conditionEndOffset: leftParenthesis.endGroup.offset,
+ conditionStartOffset: startOffset,
+ conditionEndOffset: endOffset,
message: message);
switch (kind) {
case Assert.Statement:
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
index 20555a2..785f889 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
@@ -135,6 +135,7 @@
Supertype buildSupertype(
LibraryBuilder library, List<KernelTypeBuilder> arguments) {
Class cls = isPatch ? origin.target : this.cls;
+ arguments ??= calculatedBounds;
if (arguments != null) {
return new Supertype(cls, buildTypeArguments(library, arguments));
} else {
diff --git a/pkg/front_end/test/fasta/assert_locations_test.dart b/pkg/front_end/test/fasta/assert_locations_test.dart
new file mode 100644
index 0000000..b8bcf7e
--- /dev/null
+++ b/pkg/front_end/test/fasta/assert_locations_test.dart
@@ -0,0 +1,152 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE.md file.
+
+library fasta.test.assert_locations_test;
+
+import 'package:async_helper/async_helper.dart' show asyncTest;
+
+import 'package:expect/expect.dart' show Expect;
+
+import 'package:kernel/ast.dart'
+ show Program, RecursiveVisitor, Procedure, AssertStatement;
+
+import "package:front_end/src/api_prototype/compiler_options.dart"
+ show CompilerOptions;
+
+import 'package:front_end/src/testing/compiler_common.dart' show compileScript;
+
+import 'package:front_end/src/fasta/fasta_codes.dart' show LocatedMessage;
+
+import 'package:front_end/src/fasta/severity.dart' show Severity;
+
+/// Span of the condition expression in the assert statement.
+class ConditionSpan {
+ final startOffset;
+ final endOffset;
+ ConditionSpan(this.startOffset, this.endOffset);
+}
+
+/// Generated test with multiple functions each containing a single
+/// assertion statement inside. [spans] specifies the mapping
+/// between function name and [ConditionSpan] for an [AssertionStatement]
+/// inside that function.
+class Test {
+ final String source;
+ final Map<String, ConditionSpan> spans;
+
+ Test(this.source, this.spans);
+}
+
+Test generateTest() {
+ final sb = new StringBuffer();
+ final spans = new Map<String, ConditionSpan>();
+
+ // Create a test case for assert statement with the given [condition] and
+ // [message]. Argument list would contain a trailing comma if [trailingComma]
+ // is [true].
+ // [additionalOffset] specifies an offset in characters from the opening
+ // parenthesis of the assert statement to the first character of the
+ // condition.
+ void makeAssertWithMessage(String condition,
+ {String message, bool trailingComma: false, int additionalOffset: 0}) {
+ final name = 'testCase${spans.length}';
+ sb.writeln('void $name(x) {');
+ sb.write('assert(');
+ final startOffset = sb.length + additionalOffset;
+ sb.write(condition);
+ final endOffset = sb.length;
+ if (message != null) {
+ sb.write(', "${message}"');
+ }
+ if (trailingComma) {
+ sb.write(',');
+ }
+ sb.writeln(');');
+ sb.writeln('}');
+ spans[name] = new ConditionSpan(startOffset, endOffset);
+ }
+
+ // Create test cases for various variants of the assert statement with
+ // the given condition.
+ void makeAssert(String condition, {int additionalOffset: 0}) {
+ makeAssertWithMessage(condition, additionalOffset: additionalOffset);
+ makeAssertWithMessage(condition,
+ trailingComma: true, additionalOffset: additionalOffset);
+ makeAssertWithMessage(condition,
+ message: 'message message', additionalOffset: additionalOffset);
+ makeAssertWithMessage(condition,
+ message: 'message message',
+ trailingComma: true,
+ additionalOffset: additionalOffset);
+ }
+
+ // Create all test cases.
+ makeAssert('''
+
+ (
+ x != null
+ )''', additionalOffset: 3);
+ makeAssert('''(x != null)''');
+ makeAssert('''x''');
+ makeAssert('''((x))''');
+ makeAssert('''!x''');
+ makeAssert('''((!x))''');
+ makeAssert('''x.method("a", "b")''');
+
+ // Add a dummy main to avoid compilation errors.
+ sb.writeln('''
+void main() {}
+''');
+
+ return new Test(sb.toString(), spans);
+}
+
+/// Visitor that verifies that all [AssertStatement]s in the Kernel AST
+/// have expected spans for their conditions.
+class VerifyingVisitor extends RecursiveVisitor<Null> {
+ final Test test;
+
+ /// Set of names of verified [Procedure]s.
+ final Set<String> verified = new Set<String>();
+
+ /// When [AssertStatement] is reached it is checked against this
+ /// span.
+ ConditionSpan expectedSpan;
+
+ VerifyingVisitor(this.test);
+
+ @override
+ visitProcedure(Procedure node) {
+ expectedSpan = test.spans[node.name.name];
+ if (expectedSpan != null) {
+ super.visitProcedure(node);
+ verified.add(node.name.name);
+ expectedSpan = null;
+ }
+ }
+
+ @override
+ visitAssertStatement(AssertStatement node) {
+ Expect.equals(expectedSpan.startOffset, node.conditionStartOffset);
+ Expect.equals(expectedSpan.endOffset, node.conditionEndOffset);
+ }
+}
+
+void main() {
+ asyncTest(() async {
+ Test test = generateTest();
+ CompilerOptions options = new CompilerOptions()
+ ..onProblem = (LocatedMessage message, Severity severity,
+ String formatted, int line, int column) {
+ Expect.fail("Unexpected error: $formatted");
+ }
+ ..strongMode = true;
+ Program p = await compileScript(test.source,
+ options: options, fileName: 'synthetic-test.dart');
+ Expect.isNotNull(p);
+ VerifyingVisitor visitor = new VerifyingVisitor(test);
+ p.mainMethod.enclosingLibrary.accept(visitor);
+ Expect.setEquals(test.spans.keys, visitor.verified);
+ });
+}
diff --git a/pkg/front_end/testcases/ast_builder.status b/pkg/front_end/testcases/ast_builder.status
index c804aae..d236b72 100644
--- a/pkg/front_end/testcases/ast_builder.status
+++ b/pkg/front_end/testcases/ast_builder.status
@@ -83,6 +83,7 @@
inference/unsafe_block_closure_inference_function_call_explicit_type_param_via_expr2: Fail
inference_new/dependency_only_if_generic_method: Fail
inference_new/for_each_identifier_downwards: Crash
+instantiate_to_bound/supertypes: Crash
invalid_cast: Crash
invocations: Crash
metadata_enum: Crash
diff --git a/pkg/front_end/testcases/instantiate_to_bound/supertypes.dart b/pkg/front_end/testcases/instantiate_to_bound/supertypes.dart
new file mode 100644
index 0000000..65f0c61
--- /dev/null
+++ b/pkg/front_end/testcases/instantiate_to_bound/supertypes.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// The test checks that instantiate to bound is applied to raw generic
+// supertypes.
+
+import 'package:expect/expect.dart';
+
+class B {}
+
+class X<T extends B> {}
+
+class Y extends X {}
+
+void main() {
+ Expect.isTrue(new Y() is X);
+}
diff --git a/pkg/front_end/testcases/instantiate_to_bound/supertypes.dart.strong.expect b/pkg/front_end/testcases/instantiate_to_bound/supertypes.dart.strong.expect
new file mode 100644
index 0000000..c261752
--- /dev/null
+++ b/pkg/front_end/testcases/instantiate_to_bound/supertypes.dart.strong.expect
@@ -0,0 +1,23 @@
+library;
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+class B extends core::Object {
+ synthetic constructor •() → void
+ : super core::Object::•()
+ ;
+}
+class X<T extends self::B> extends core::Object {
+ synthetic constructor •() → void
+ : super core::Object::•()
+ ;
+}
+class Y extends self::X<self::B> {
+ synthetic constructor •() → void
+ : super self::X::•()
+ ;
+}
+static method main() → void {
+ exp::Expect::isTrue(new self::Y::•() is self::X<self::B>);
+}
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index 87b92be..4ad291a 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -1670,6 +1670,7 @@
void writeVariableDeclaration(VariableDeclaration node,
{bool useVarKeyword: false}) {
if (showOffsets) writeWord("[${node.fileOffset}]");
+ if (showMetadata) writeMetadata(node);
writeAnnotationList(node.annotations);
writeModifier(node.isCovariant, 'covariant');
writeModifier(node.isGenericCovariantImpl, 'generic-covariant-impl');
diff --git a/pkg/vm/bin/kernel_service.dart b/pkg/vm/bin/kernel_service.dart
index 0345df1..b53b6bb 100644
--- a/pkg/vm/bin/kernel_service.dart
+++ b/pkg/vm/bin/kernel_service.dart
@@ -27,7 +27,6 @@
import 'package:front_end/src/api_prototype/file_system.dart';
import 'package:front_end/src/api_prototype/front_end.dart';
-import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
import 'package:front_end/src/api_prototype/memory_file_system.dart';
import 'package:front_end/src/api_prototype/standard_file_system.dart';
import 'package:front_end/src/compute_platform_binaries_location.dart'
@@ -37,6 +36,7 @@
import 'package:kernel/kernel.dart' show Program;
import 'package:kernel/target/targets.dart' show TargetFlags;
import 'package:kernel/target/vm.dart' show VmTarget;
+import 'package:vm/incremental_compiler.dart';
const bool verbose = const bool.fromEnvironment('DFE_VERBOSE');
const String platformKernelFile = 'virtual_platform_kernel.dill';
@@ -47,10 +47,12 @@
// Current tags include the following:
// 0 - Perform normal compilation.
// 1 - Update in-memory file system with in-memory sources (used by tests).
-// 2 - APP JIT snapshot training run for kernel_service.
+// 2 - Accept last compilation result.
+// 3 - APP JIT snapshot training run for kernel_service.
const int kCompileTag = 0;
const int kUpdateSourcesTag = 1;
-const int kTrainTag = 2;
+const int kAcceptTag = 2;
+const int kTrainTag = 3;
abstract class Compiler {
final FileSystem fileSystem;
@@ -111,10 +113,10 @@
Future<Program> compileInternal(Uri script);
}
-class IncrementalCompiler extends Compiler {
- IncrementalKernelGenerator generator;
+class IncrementalCompilerWrapper extends Compiler {
+ IncrementalCompiler generator;
- IncrementalCompiler(FileSystem fileSystem, Uri platformKernelPath,
+ IncrementalCompilerWrapper(FileSystem fileSystem, Uri platformKernelPath,
{bool strongMode: false, bool suppressWarnings: false, syncAsync: false})
: super(fileSystem, platformKernelPath,
strongMode: strongMode,
@@ -124,20 +126,20 @@
@override
Future<Program> compileInternal(Uri script) async {
if (generator == null) {
- generator = new IncrementalKernelGenerator(options, script);
+ generator = new IncrementalCompiler(options, script);
}
- return await generator.computeDelta(entryPoint: script);
+ errors.clear();
+ return await generator.compile(entryPoint: script);
}
- void invalidate(Uri uri) {
- generator.invalidate(uri);
- }
+ void accept() => generator.accept();
+ void invalidate(Uri uri) => generator.invalidate(uri);
}
-class SingleShotCompiler extends Compiler {
+class SingleShotCompilerWrapper extends Compiler {
final bool requireMain;
- SingleShotCompiler(FileSystem fileSystem, Uri platformKernelPath,
+ SingleShotCompilerWrapper(FileSystem fileSystem, Uri platformKernelPath,
{this.requireMain: false,
bool strongMode: false,
bool suppressWarnings: false,
@@ -166,7 +168,7 @@
{bool strongMode: false,
bool suppressWarnings: false,
bool syncAsync: false}) async {
- IncrementalCompiler compiler = lookupIncrementalCompiler(isolateId);
+ IncrementalCompilerWrapper compiler = lookupIncrementalCompiler(isolateId);
if (compiler != null) {
updateSources(compiler, sourceFiles);
invalidateSources(compiler, sourceFiles);
@@ -175,11 +177,11 @@
? StandardFileSystem.instance
: _buildFileSystem(sourceFiles, platformKernel);
- // TODO(aam): IncrementalCompiler instance created below have to be
+ // TODO(aam): IncrementalCompilerWrapper instance created below have to be
// destroyed when corresponding isolate is shut down. To achieve that kernel
// isolate needs to receive a message indicating that particular
// isolate was shut down. Message should be handled here in this script.
- compiler = new IncrementalCompiler(fileSystem, platformKernelPath,
+ compiler = new IncrementalCompilerWrapper(fileSystem, platformKernelPath,
strongMode: strongMode,
suppressWarnings: suppressWarnings,
syncAsync: syncAsync);
@@ -188,7 +190,7 @@
return compiler;
}
-void updateSources(IncrementalCompiler compiler, List sourceFiles) {
+void updateSources(IncrementalCompilerWrapper compiler, List sourceFiles) {
final bool hasMemoryFS = compiler.fileSystem is HybridFileSystem;
if (sourceFiles.isNotEmpty) {
final FileSystem fs = compiler.fileSystem;
@@ -208,7 +210,7 @@
}
}
-void invalidateSources(IncrementalCompiler compiler, List sourceFiles) {
+void invalidateSources(IncrementalCompilerWrapper compiler, List sourceFiles) {
if (sourceFiles.isNotEmpty) {
for (int i = 0; i < sourceFiles.length ~/ 2; i++) {
compiler.invalidate(Uri.parse(sourceFiles[i * 2]));
@@ -251,15 +253,24 @@
// unit tests compile sources that are not on the file system, so this can only
// happen during unit tests.
if (tag == kUpdateSourcesTag) {
- assert(
- incremental,
- "Incremental compiler required for use of"
- "'kUpdateSourcesTag'");
+ assert(incremental,
+ "Incremental compiler required for use of 'kUpdateSourcesTag'");
compiler = lookupIncrementalCompiler(isolateId);
assert(compiler != null);
updateSources(compiler, sourceFiles);
port.send(new CompilationResult.ok(null).toResponse());
return;
+ } else if (tag == kAcceptTag) {
+ assert(
+ incremental, "Incremental compiler required for use of 'kAcceptTag'");
+ compiler = lookupIncrementalCompiler(isolateId);
+ // There are unit tests that invoke the IncrementalCompiler directly and
+ // request a reload, meaning that we won't have a compiler for this isolate.
+ if (compiler != null) {
+ (compiler as IncrementalCompilerWrapper).accept();
+ }
+ port.send(new CompilationResult.ok(null).toResponse());
+ return;
}
// script should only be null for kUpdateSourcesTag.
@@ -279,7 +290,7 @@
final FileSystem fileSystem = sourceFiles.isEmpty && platformKernel == null
? StandardFileSystem.instance
: _buildFileSystem(sourceFiles, platformKernel);
- compiler = new SingleShotCompiler(fileSystem, platformKernelPath,
+ compiler = new SingleShotCompilerWrapper(fileSystem, platformKernelPath,
requireMain: sourceFiles.isEmpty,
strongMode: strong,
suppressWarnings: suppressWarnings,
diff --git a/pkg/vm/lib/incremental_compiler.dart b/pkg/vm/lib/incremental_compiler.dart
index 017d612..ac51130 100644
--- a/pkg/vm/lib/incremental_compiler.dart
+++ b/pkg/vm/lib/incremental_compiler.dart
@@ -18,8 +18,10 @@
List<Program> _pendingDeltas;
CompilerOptions _compilerOptions;
- IncrementalCompiler(this._compilerOptions, Uri entryPoint) {
- _generator = new IncrementalKernelGenerator(_compilerOptions, entryPoint);
+ IncrementalCompiler(this._compilerOptions, Uri entryPoint,
+ {Uri bootstrapDill}) {
+ _generator = new IncrementalKernelGenerator(
+ _compilerOptions, entryPoint, bootstrapDill);
_pendingDeltas = <Program>[];
}
@@ -36,13 +38,18 @@
}
// If more than one delta is pending, we need to combine them.
+ Procedure mainMethod;
Map<Uri, Library> combined = <Uri, Library>{};
for (Program delta in _pendingDeltas) {
+ if (delta.mainMethod != null) {
+ mainMethod = delta.mainMethod;
+ }
for (Library library in delta.libraries) {
combined[library.importUri] = library;
}
}
- return new Program(libraries: combined.values.toList());
+ return new Program(libraries: combined.values.toList())
+ ..mainMethod = mainMethod;
}
/// This lets incremental compiler know that results of last [compile] call
diff --git a/pkg/vm/lib/kernel_front_end.dart b/pkg/vm/lib/kernel_front_end.dart
index 569b786..298dae7 100644
--- a/pkg/vm/lib/kernel_front_end.dart
+++ b/pkg/vm/lib/kernel_front_end.dart
@@ -60,8 +60,9 @@
globalTypeFlow.transformProgram(coreTypes, program);
} else {
devirtualization.transformProgram(coreTypes, program);
- no_dynamic_invocations_annotator.transformProgram(coreTypes, program);
}
+
+ no_dynamic_invocations_annotator.transformProgram(program);
}
}
diff --git a/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart b/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart
index 7950fa0..a5db2e7 100644
--- a/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart
+++ b/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart
@@ -5,14 +5,13 @@
library vm.transformations.no_dynamic_invocations_annotator;
import 'package:kernel/ast.dart';
-import 'package:kernel/core_types.dart' show CoreTypes;
import '../metadata/procedure_attributes.dart';
/// Assumes strong mode and closed world. If a procedure can not be riched
/// via dynamic invocation from anywhere then annotates it with appropriate
/// [ProcedureAttributeMetadata] annotation.
-Program transformProgram(CoreTypes coreTypes, Program program) {
+Program transformProgram(Program program) {
new NoDynamicInvocationsAnnotator(program).visitProgram(program);
return program;
}
diff --git a/pkg/vm/lib/transformations/type_flow/analysis.dart b/pkg/vm/lib/transformations/type_flow/analysis.dart
index de9316c..42b78f0 100644
--- a/pkg/vm/lib/transformations/type_flow/analysis.dart
+++ b/pkg/vm/lib/transformations/type_flow/analysis.dart
@@ -28,7 +28,6 @@
// * Verify incremental re-calculation by fresh analysis starting with known
// allocated classes.
// * Auto-generate entry_points.json during build.
-// * Support FutureOr<T> properly.
//
// === Precision ===
// * Handle '==' with null.
@@ -778,6 +777,11 @@
return true;
}
+ // TODO(alexmarkov): handle FutureOr more precisely (requires generics).
+ if (superClass == _typeFlowAnalysis.environment.futureOrClass) {
+ return true;
+ }
+
_ClassData subClassData = getClassData(subClass);
_ClassData superClassData = getClassData(superClass);
@@ -799,6 +803,7 @@
}
assertx(base is InterfaceType); // TODO(alexmarkov)
+ final baseClass = (base as InterfaceType).classNode;
// TODO(alexmarkov): take type arguments into account.
@@ -806,11 +811,13 @@
// subtypes is too large
if (base == const DynamicType() ||
- base == _typeFlowAnalysis.environment.objectType) {
+ base == _typeFlowAnalysis.environment.objectType ||
+ // TODO(alexmarkov): handle FutureOr more precisely (requires generics).
+ baseClass == _typeFlowAnalysis.environment.futureOrClass) {
return const AnyType();
}
- _ClassData classData = getClassData((base as InterfaceType).classNode);
+ _ClassData classData = getClassData(baseClass);
final allocatedSubtypes = classData.allocatedSubtypes;
if (!_sealed) {
@@ -1028,6 +1035,10 @@
Call callSite(TreeNode node) => summaryCollector.callSites[node];
+ Type fieldType(Field field) => _fieldValues[field]?.value;
+
+ Args<Type> argumentTypes(Member member) => _summaries[member]?.argumentTypes;
+
/// ---- Implementation of [CallHandler] interface. ----
@override
diff --git a/pkg/vm/lib/transformations/type_flow/summary.dart b/pkg/vm/lib/transformations/type_flow/summary.dart
index 50dfbb2..58a259c 100644
--- a/pkg/vm/lib/transformations/type_flow/summary.dart
+++ b/pkg/vm/lib/transformations/type_flow/summary.dart
@@ -59,8 +59,9 @@
/// Input parameter of the summary.
class Parameter extends Statement {
final String _name;
- final DartType staticType;
+ final Type staticType;
Type defaultValue;
+ Type _argumentType = const EmptyType();
Parameter(this._name, this.staticType);
@@ -76,6 +77,12 @@
Type apply(List<Type> computedTypes, TypeHierarchy typeHierarchy,
CallHandler callHandler) =>
throw 'Unable to apply _Parameter';
+
+ Type get argumentType => _argumentType;
+
+ void _observeArgumentType(Type argType, TypeHierarchy typeHierarchy) {
+ _argumentType = _argumentType.union(argType, typeHierarchy);
+ }
}
/// Narrows down [arg] to [type].
@@ -279,8 +286,16 @@
types.setAll(0, args);
+ for (int i = 0; i < args.length; i++) {
+ Parameter param = _statements[i] as Parameter;
+ param._observeArgumentType(args[i], typeHierarchy);
+ types[i] = args[i].intersection(param.staticType, typeHierarchy);
+ }
+
for (int i = args.length; i < parameterCount; i++) {
- types[i] = (_statements[i] as Parameter).defaultValue;
+ Parameter param = _statements[i] as Parameter;
+ param._observeArgumentType(param.defaultValue, typeHierarchy);
+ types[i] = param.defaultValue;
assertx(types[i] != null);
}
@@ -299,4 +314,14 @@
return result.getComputedType(types);
}
+
+ Args<Type> get argumentTypes {
+ final positional = new List<Type>(parameterCount);
+ for (int i = 0; i < parameterCount; i++) {
+ Parameter param = _statements[i] as Parameter;
+ positional[i] = param.argumentType;
+ }
+ // TODO(alexmarkov): support named parameters
+ return new Args<Type>(positional);
+ }
}
diff --git a/pkg/vm/lib/transformations/type_flow/summary_collector.dart b/pkg/vm/lib/transformations/type_flow/summary_collector.dart
index 3899672..d5c121a 100644
--- a/pkg/vm/lib/transformations/type_flow/summary_collector.dart
+++ b/pkg/vm/lib/transformations/type_flow/summary_collector.dart
@@ -263,7 +263,8 @@
if (hasReceiver) {
// TODO(alexmarkov): subclass cone
_receiver = _declareParameter(
- "this", new InterfaceType(member.enclosingClass), null);
+ "this", member.enclosingClass.rawType, null,
+ isReceiver: true);
_environment.thisType = member.enclosingClass?.thisType;
}
@@ -385,8 +386,11 @@
}
Parameter _declareParameter(
- String name, DartType type, Expression initializer) {
- final param = new Parameter(name, type);
+ String name, DartType type, Expression initializer,
+ {bool isReceiver: false}) {
+ Type staticType =
+ isReceiver ? new ConeType(type) : new Type.fromStatic(type);
+ final param = new Parameter(name, staticType);
_summary.add(param);
assertx(param.index < _summary.parameterCount);
if (param.index >= _summary.requiredParameterCount) {
diff --git a/pkg/vm/lib/transformations/type_flow/transformer.dart b/pkg/vm/lib/transformations/type_flow/transformer.dart
index 63f91ae..78e54e4 100644
--- a/pkg/vm/lib/transformations/type_flow/transformer.dart
+++ b/pkg/vm/lib/transformations/type_flow/transformer.dart
@@ -142,80 +142,134 @@
program.addMetadataRepository(_metadata);
}
- void _annotateNode(TreeNode node) {
- final callSite = _typeFlowAnalysis.callSite(node);
- if ((callSite != null) && callSite.isResultUsed && callSite.isReachable) {
- final resultType = callSite.resultType;
- assertx(resultType != null);
+ InferredType _convertType(Type type) {
+ assertx(type != null);
- Class concreteClass;
+ Class concreteClass;
- final nullable = resultType is NullableType;
- if (nullable) {
- final baseType = (resultType as NullableType).baseType;
+ final nullable = type is NullableType;
+ if (nullable) {
+ final baseType = (type as NullableType).baseType;
- if (baseType == const EmptyType()) {
- concreteClass = _typeFlowAnalysis.environment.coreTypes.nullClass;
- } else {
- concreteClass =
- baseType.getConcreteClass(_typeFlowAnalysis.hierarchyCache);
- }
+ if (baseType == const EmptyType()) {
+ concreteClass = _typeFlowAnalysis.environment.coreTypes.nullClass;
} else {
concreteClass =
- resultType.getConcreteClass(_typeFlowAnalysis.hierarchyCache);
+ baseType.getConcreteClass(_typeFlowAnalysis.hierarchyCache);
}
+ } else {
+ concreteClass = type.getConcreteClass(_typeFlowAnalysis.hierarchyCache);
+ }
- if ((concreteClass != null) || !nullable) {
- _metadata.mapping[node] = new InferredType(concreteClass, nullable);
+ if ((concreteClass != null) || !nullable) {
+ return new InferredType(concreteClass, nullable);
+ }
+
+ return null;
+ }
+
+ void _setInferredType(TreeNode node, Type type) {
+ final inferredType = _convertType(type);
+ if (inferredType != null) {
+ _metadata.mapping[node] = inferredType;
+ }
+ }
+
+ void _annotateCallSite(TreeNode node) {
+ final callSite = _typeFlowAnalysis.callSite(node);
+ if ((callSite != null) && callSite.isResultUsed && callSite.isReachable) {
+ _setInferredType(node, callSite.resultType);
+ }
+ }
+
+ void _annotateMember(Member member) {
+ if (_typeFlowAnalysis.isMemberUsed(member)) {
+ if (member is Field) {
+ _setInferredType(member, _typeFlowAnalysis.fieldType(member));
+ } else {
+ Args<Type> argTypes = _typeFlowAnalysis.argumentTypes(member);
+ assertx(argTypes != null);
+
+ final int firstParamIndex = hasReceiverArg(member) ? 1 : 0;
+
+ final positionalParams = member.function.positionalParameters;
+ assertx(argTypes.positionalCount ==
+ firstParamIndex + positionalParams.length);
+
+ for (int i = 0; i < positionalParams.length; i++) {
+ _setInferredType(
+ positionalParams[i], argTypes.values[firstParamIndex + i]);
+ }
+
+ // TODO(alexmarkov): figure out how to pass receiver type.
+ // TODO(alexmarkov): support named parameters
}
}
}
@override
+ visitConstructor(Constructor node) {
+ _annotateMember(node);
+ super.visitConstructor(node);
+ }
+
+ @override
+ visitProcedure(Procedure node) {
+ _annotateMember(node);
+ super.visitProcedure(node);
+ }
+
+ @override
+ visitField(Field node) {
+ _annotateMember(node);
+ super.visitField(node);
+ }
+
+ @override
visitMethodInvocation(MethodInvocation node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitMethodInvocation(node);
}
@override
visitPropertyGet(PropertyGet node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitPropertyGet(node);
}
@override
visitDirectMethodInvocation(DirectMethodInvocation node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitDirectMethodInvocation(node);
}
@override
visitDirectPropertyGet(DirectPropertyGet node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitDirectPropertyGet(node);
}
@override
visitSuperMethodInvocation(SuperMethodInvocation node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitSuperMethodInvocation(node);
}
@override
visitSuperPropertyGet(SuperPropertyGet node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitSuperPropertyGet(node);
}
@override
visitStaticInvocation(StaticInvocation node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitStaticInvocation(node);
}
@override
visitStaticGet(StaticGet node) {
- _annotateNode(node);
+ _annotateCallSite(node);
super.visitStaticGet(node);
}
}
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/calls.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/calls.dart.expect
index 1e61c59..3b59fa8 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/calls.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/calls.dart.expect
@@ -1,39 +1,39 @@
------------ #lib::A:: ------------
-%this = _Parameter #0 [#lib::A]
+%this = _Parameter #0 [_T (#lib::A)+]
t1 = _Call direct [dart.core::Object::] (%this)
RESULT: _T {}?
------------ #lib::A::foo1 ------------
-%this = _Parameter #0 [#lib::A]
-%x = _Parameter #1 [dart.core::Object]
+%this = _Parameter #0 [_T (#lib::A)+]
+%x = _Parameter #1 [_T (dart.core::Object)+?]
RESULT: _T {}?
------------ #lib::B:: ------------
-%this = _Parameter #0 [#lib::B]
+%this = _Parameter #0 [_T (#lib::B)+]
t1 = _Call direct [dart.core::Object::] (%this)
RESULT: _T {}?
------------ #lib::B::bar1 ------------
-%this = _Parameter #0 [#lib::B]
-%arg = _Parameter #1 [dart.core::Object]
+%this = _Parameter #0 [_T (#lib::B)+]
+%arg = _Parameter #1 [_T (dart.core::Object)+?]
RESULT: _T {}?
------------ #lib::B::bar2 ------------
-%this = _Parameter #0 [#lib::B]
+%this = _Parameter #0 [_T (#lib::B)+]
RESULT: _T {}?
------------ #lib::B::bar3 ------------
-%this = _Parameter #0 [#lib::B]
-%y = _Parameter #1 [dart.core::int]
+%this = _Parameter #0 [_T (#lib::B)+]
+%y = _Parameter #1 [_T (dart.core::int)+?]
RESULT: _T {}?
------------ #lib::B::bar4 ------------
RESULT: _T {}?
------------ #lib::C:: ------------
-%this = _Parameter #0 [#lib::C]
+%this = _Parameter #0 [_T (#lib::C)+]
t1 = _Call direct [dart.core::Object::] (%this)
RESULT: _T {}?
------------ #lib::C::interfaceCalls ------------
-%this = _Parameter #0 [#lib::C]
-%aa = _Parameter #1 [#lib::A]
-%a2 = _Parameter #2 [dart.core::Object]
-%a3 = _Parameter #3 [dart.core::Object]
-%a4 = _Parameter #4 [dart.core::Object]
+%this = _Parameter #0 [_T (#lib::C)+]
+%aa = _Parameter #1 [_T (#lib::A)+?]
+%a2 = _Parameter #2 [_T (dart.core::Object)+?]
+%a3 = _Parameter #3 [_T (dart.core::Object)+?]
+%a4 = _Parameter #4 [_T (dart.core::Object)+?]
t5 = _Call direct [#lib::B::] (_T (#lib::B))
t6 = _Call [#lib::A::foo1] (%aa, _T (#lib::B))
t7* = _Call get [#lib::A::foo2] (%aa)
@@ -43,11 +43,11 @@
a4 = _Join [dart.core::Object] (%a4, _T ANY?)
RESULT: a4
------------ #lib::C::dynamicCalls ------------
-%this = _Parameter #0 [#lib::C]
-%aa = _Parameter #1 [dynamic]
-%a2 = _Parameter #2 [dart.core::Object]
-%a3 = _Parameter #3 [dart.core::Object]
-%a4 = _Parameter #4 [dart.core::Object]
+%this = _Parameter #0 [_T (#lib::C)+]
+%aa = _Parameter #1 [_T ANY?]
+%a2 = _Parameter #2 [_T (dart.core::Object)+?]
+%a3 = _Parameter #3 [_T (dart.core::Object)+?]
+%a4 = _Parameter #4 [_T (dart.core::Object)+?]
t5 = _Call direct [#lib::B::] (_T (#lib::B))
t6 = _Call dynamic [foo1] (%aa, _T (#lib::B))
t7* = _Call dynamic get [foo2] (%aa)
@@ -57,15 +57,15 @@
a4 = _Join [dart.core::Object] (%a4, t10)
RESULT: a4
------------ #lib::D:: ------------
-%this = _Parameter #0 [#lib::D]
+%this = _Parameter #0 [_T (#lib::D)+]
t1 = _Call direct [#lib::B::] (%this)
RESULT: _T {}?
------------ #lib::D::superCalls ------------
-%this = _Parameter #0 [#lib::D]
-%a1 = _Parameter #1 [dart.core::Object]
-%a2 = _Parameter #2 [dart.core::Object]
-%a3 = _Parameter #3 [dart.core::Object]
-%a4 = _Parameter #4 [dart.core::Object]
+%this = _Parameter #0 [_T (#lib::D)+]
+%a1 = _Parameter #1 [_T (dart.core::Object)+?]
+%a2 = _Parameter #2 [_T (dart.core::Object)+?]
+%a3 = _Parameter #3 [_T (dart.core::Object)+?]
+%a4 = _Parameter #4 [_T (dart.core::Object)+?]
t5 = _Call direct [#lib::B::bar1] (%this, %a1)
t6* = _Call direct get [#lib::B::bar4] (%this)
t7 = _Call direct set [#lib::B::bar3] (%this, t6)
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect
index 2f27227..35081b4 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect
@@ -1,4 +1,4 @@
------------ #lib::main ------------
-%args = _Parameter #0 [dart.core::List<dart.core::String>]
+%args = _Parameter #0 [_T (dart.core::List<dynamic>)+?]
t1 = _Call direct [dart.core::print] (_T (dart.core::String)+)
RESULT: _T {}?
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect
index a34ced5..e189190 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect
@@ -1,5 +1,5 @@
------------ #lib::T:: ------------
-%this = _Parameter #0 [#lib::T]
+%this = _Parameter #0 [_T (#lib::T)+]
t1 = _Call direct [dart.core::Object::] (%this)
RESULT: _T {}?
------------ #lib::empty1 ------------
@@ -18,7 +18,7 @@
t0 = _Call direct [#lib::T::] (_T (#lib::T))
RESULT: _T (#lib::T)
------------ #lib::return2 ------------
-%i = _Parameter #0 [dart.core::int]
+%i = _Parameter #0 [_T (dart.core::int)+?]
t1* = _Call [dart.core::num::-] (%i, _T (dart.core::int)+)
t2* = _Call direct [#lib::return2] (t1)
RESULT: t2
@@ -29,77 +29,77 @@
t0 = _Call direct [#lib::T::] (_T (#lib::T))
RESULT: _T {}?
------------ #lib::expr2 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1 = _Call direct [#lib::T::] (_T (#lib::T))
t2 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
------------ #lib::expr3 ------------
-%c = _Parameter #0 [dart.core::bool]
-%x = _Parameter #1 [dart.core::Object]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
+%x = _Parameter #1 [_T (dart.core::Object)+?]
t2 = _Call direct [#lib::T::] (_T (#lib::T))
t3 = _Call [dart.core::Object::toString] (%x)
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
------------ #lib::throw1 ------------
-%c = _Parameter #0 [dart.core::bool]
-%x = _Parameter #1 [dart.core::Object]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
+%x = _Parameter #1 [_T (dart.core::Object)+?]
RESULT: _T {}
------------ #lib::throw2 ------------
-%c = _Parameter #0 [dart.core::bool]
-%x = _Parameter #1 [dart.core::Object]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
+%x = _Parameter #1 [_T (dart.core::Object)+?]
t2 = _Call direct [#lib::T::] (_T (#lib::T))
RESULT: _T (#lib::T)
------------ #lib::loop1 ------------
-%c = _Parameter #0 [dart.core::bool]
-%x = _Parameter #1 [dart.core::Object]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
+%x = _Parameter #1 [_T (dart.core::Object)+?]
RESULT: _T {}?
------------ #lib::loop2 ------------
-%c = _Parameter #0 [dart.core::bool]
-%x = _Parameter #1 [dart.core::Object]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
+%x = _Parameter #1 [_T (dart.core::Object)+?]
t2 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
------------ #lib::loop3 ------------
-%c = _Parameter #0 [dart.core::bool]
-%x = _Parameter #1 [dart.core::Object]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
+%x = _Parameter #1 [_T (dart.core::Object)+?]
t2 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
------------ #lib::switch_ ------------
-%c = _Parameter #0 [dart.core::bool]
-%i = _Parameter #1 [dart.core::int]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
+%i = _Parameter #1 [_T (dart.core::int)+?]
t2 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
------------ #lib::if1 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1 = _Call direct [#lib::T::] (_T (#lib::T))
RESULT: _T (#lib::T)
------------ #lib::if2 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
------------ #lib::if3 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
RESULT: _T {}?
------------ #lib::if4 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
RESULT: _T {}?
------------ #lib::if5 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1* = _Call direct [#lib::if5] (%c)
t2* = _Call direct [#lib::if5] (_T (dart.core::bool)+)
%result = _Join [void] (t1, t2, _T {}?)
RESULT: %result
------------ #lib::label1 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
------------ #lib::try1 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
@@ -111,7 +111,7 @@
t0 = _Call direct [#lib::T::] (_T (#lib::T))
RESULT: _T (#lib::T)
------------ #lib::try4 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1 = _Call direct [#lib::T::] (_T (#lib::T))
%result = _Join [dynamic] (_T (#lib::T), _T {}?)
RESULT: %result
@@ -122,7 +122,7 @@
t0 = _Call direct [#lib::T::] (_T (#lib::T))
RESULT: _T (#lib::T)
------------ #lib::try7 ------------
-%c = _Parameter #0 [dart.core::bool]
+%c = _Parameter #0 [_T (dart.core::bool)+?]
t1 = _Call direct [#lib::T::] (_T (#lib::T))
RESULT: _T (#lib::T)
------------ #lib::main ------------
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect
index c25357b..c400675 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect
@@ -1,14 +1,14 @@
------------ #lib::A:: ------------
-%this = _Parameter #0 [#lib::A]
+%this = _Parameter #0 [_T (#lib::A)+]
t1 = _Call direct [dart.core::Object::] (%this)
RESULT: _T {}?
------------ #lib::B:: ------------
-%this = _Parameter #0 [#lib::B]
+%this = _Parameter #0 [_T (#lib::B)+]
t1 = _Call direct [dart.core::Object::] (%this)
RESULT: _T {}?
------------ #lib::foo ------------
-%a1 = _Parameter #0 [dart.core::Object]
-%a2 = _Parameter #1 [dart.core::Object]
+%a1 = _Parameter #0 [_T (dart.core::Object)+?]
+%a2 = _Parameter #1 [_T (dart.core::Object)+?]
t2 = _Call direct get [#lib::someStatic] ()
t3 = _Call direct [#lib::A::] (_T (#lib::A))
a1 = _Join [dart.core::Object] (%a1, _T (#lib::A), _T (#lib::B))
@@ -20,8 +20,8 @@
t10 = _Narrow (t9 to _T (dart.core::Object)+?)
RESULT: t10
------------ #lib::bar ------------
-%a1 = _Parameter #0 [dart.core::Object]
-%a2 = _Parameter #1 [dart.core::int]
+%a1 = _Parameter #0 [_T (dart.core::Object)+?]
+%a2 = _Parameter #1 [_T (dart.core::int)+?]
t2 = _Narrow (%a1 to _T (dart.core::int)+)
t3* = _Call [dart.core::num::+] (t2, %a2)
t4* = _Call [dart.core::num::*] (t3, _T (dart.core::int)+)
@@ -29,13 +29,13 @@
%result = _Join [dart.core::int] (t4, t5)
RESULT: %result
------------ #lib::loop1 ------------
-%a1 = _Parameter #0 [dart.core::Object]
-%a2 = _Parameter #1 [dart.core::Object]
+%a1 = _Parameter #0 [_T (dart.core::Object)+?]
+%a2 = _Parameter #1 [_T (dart.core::Object)+?]
t2* = _Call direct [#lib::loop1] (_T (dart.core::Object)+?, %a1)
x = _Join [dart.core::Object] (%a1, t2, %a2)
RESULT: x
------------ #lib::loop2 ------------
-%x = _Parameter #0 [dart.core::int]
+%x = _Parameter #0 [_T (dart.core::int)+?]
t1* = _Call [dart.core::num::+] (_T (dart.core::int)+?, _T (dart.core::int)+)
i = _Join [dart.core::int] (_T (dart.core::int)+, t1)
t3 = _Call [dart.core::num::<] (i, _T (dart.core::int)+)
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect
index e409910..82e6549 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect
@@ -4,29 +4,29 @@
import "dart:typed_data" as typ;
class _Vector extends core::Object {
- final field core::int _offset;
- final field core::int _length;
- final field core::List<core::double> _elements;
- constructor •(core::int size) → void
+[@vm.inferred-type.metadata=!] final field core::int _offset;
+[@vm.inferred-type.metadata=!] final field core::int _length;
+[@vm.inferred-type.metadata=dart.typed_data::_Float64List] final field core::List<core::double> _elements;
+ constructor •([@vm.inferred-type.metadata=!] core::int size) → void
: self::_Vector::_offset = 0, self::_Vector::_length = size, self::_Vector::_elements = [@vm.inferred-type.metadata=dart.typed_data::_Float64List] typ::Float64List::•(size), super core::Object::•()
;
constructor fromVOL(core::List<core::double> values, core::int offset, core::int length) → void
: self::_Vector::_offset = offset, self::_Vector::_length = length, self::_Vector::_elements = values, super core::Object::•()
throw "TFA Error: #lib::_Vector::fromVOL";
operator [](core::int i) → core::double
- return [@vm.direct-call.metadata=dart.typed_data::_Float64List::[]] [@vm.inferred-type.metadata=dart.core::_Double] [@vm.direct-call.metadata=#lib::_Vector::_elements??] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements}.{core::List::[]}(i.{core::num::+}([@vm.direct-call.metadata=#lib::_Vector::_offset??] [@vm.inferred-type.metadata=!] this.{self::_Vector::_offset}));
- operator []=(core::int i, core::double value) → void {
- [@vm.direct-call.metadata=#lib::_Vector::_elements??] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements}.{core::List::[]=}([@vm.inferred-type.metadata=!] i.{core::num::+}([@vm.direct-call.metadata=#lib::_Vector::_offset??] [@vm.inferred-type.metadata=!] this.{self::_Vector::_offset}), value);
+ return [@vm.direct-call.metadata=dart.typed_data::_Float64List::[]] [@vm.inferred-type.metadata=dart.core::_Double] [@vm.direct-call.metadata=#lib::_Vector::_elements] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements}.{core::List::[]}(i.{core::num::+}([@vm.direct-call.metadata=#lib::_Vector::_offset] [@vm.inferred-type.metadata=!] this.{self::_Vector::_offset}));
+ operator []=([@vm.inferred-type.metadata=!] core::int i, core::double value) → void {
+ [@vm.direct-call.metadata=#lib::_Vector::_elements] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements}.{core::List::[]=}(i.{core::num::+}([@vm.direct-call.metadata=#lib::_Vector::_offset] [@vm.inferred-type.metadata=!] this.{self::_Vector::_offset}), value);
}
- operator *(self::_Vector a) → core::double {
+ operator *([@vm.inferred-type.metadata=#lib::_Vector] self::_Vector a) → core::double {
core::double result = 0.0;
for (core::int i = 0; [@vm.direct-call.metadata=dart.core::_IntegerImplementation::<??] i.{core::num::<}([@vm.direct-call.metadata=#lib::_Vector::_length] [@vm.inferred-type.metadata=!] this.{self::_Vector::_length}); i = i.{core::num::+}(1))
result = [@vm.direct-call.metadata=dart.core::_Double::+??] [@vm.inferred-type.metadata=dart.core::_Double] result.{core::double::+}([@vm.direct-call.metadata=dart.core::_Double::*] [@vm.inferred-type.metadata=dart.core::_Double] [@vm.direct-call.metadata=#lib::_Vector::[]] [@vm.inferred-type.metadata=dart.core::_Double] this.{self::_Vector::[]}(i).{core::double::*}([@vm.direct-call.metadata=#lib::_Vector::[]] [@vm.inferred-type.metadata=dart.core::_Double] a.{self::_Vector::[]}(i)));
return result;
}
}
-static field self::_Vector v = new self::_Vector::•(10);
-static field core::double x = 0.0;
+[@vm.inferred-type.metadata=#lib::_Vector]static field self::_Vector v = new self::_Vector::•(10);
+[@vm.inferred-type.metadata=dart.core::_Double]static field core::double x = 0.0;
static method main(core::List<core::String> args) → dynamic {
core::Stopwatch timer = let final core::Stopwatch #t1 = new core::Stopwatch::•() in let final dynamic #t2 = [@vm.direct-call.metadata=dart.core::Stopwatch::start] #t1.{core::Stopwatch::start}() in #t1;
for (core::int i = 0; [@vm.direct-call.metadata=dart.core::_IntegerImplementation::<??] i.{core::num::<}(100000000); i = i.{core::num::+}(1)) {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect
index b8520e9..7f01388 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect
@@ -34,24 +34,24 @@
method toString() → core::String
return "D";
}
-static field self::A dd;
-static field self::E ee = new self::E::•();
-static method callerA1(self::A aa) → void {
+[@vm.inferred-type.metadata=#lib::D?]static field self::A dd;
+[@vm.inferred-type.metadata=#lib::E]static field self::E ee = new self::E::•();
+static method callerA1([@vm.inferred-type.metadata=!] self::A aa) → void {
aa.{self::A::foo}();
}
-static method callerA2(self::A aa) → void {
+static method callerA2([@vm.inferred-type.metadata=#lib::B] self::A aa) → void {
[@vm.direct-call.metadata=#lib::B::foo] aa.{self::A::foo}();
}
-static method callerA3(self::A aa) → void {
+static method callerA3([@vm.inferred-type.metadata=#lib::C] self::A aa) → void {
[@vm.direct-call.metadata=#lib::C::foo] aa.{self::A::foo}();
}
-static method callerA4(self::A aa) → void {
+static method callerA4([@vm.inferred-type.metadata=#lib::D?] self::A aa) → void {
[@vm.direct-call.metadata=#lib::C::foo??] aa.{self::A::foo}();
}
-static method callerE1(dynamic x) → void {
+static method callerE1([@vm.inferred-type.metadata=!] dynamic x) → void {
[@vm.direct-call.metadata=dart.core::_StringBase::toString] x.{core::Object::toString}();
}
-static method callerE2(dynamic x) → void {
+static method callerE2([@vm.inferred-type.metadata=#lib::E] dynamic x) → void {
[@vm.direct-call.metadata=#lib::E::toString] x.{core::Object::toString}();
}
static method main(core::List<core::String> args) → dynamic {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart b/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart
new file mode 100644
index 0000000..3fb1a95
--- /dev/null
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+class A {}
+
+class B extends A {}
+
+void foo1_a1(x) {}
+void foo1_a2(x) {}
+void foo1_a3(x) {}
+void foo1_a4(x) {}
+
+void foo1(Future<A> a1, A a2, FutureOr<A> a3, FutureOr<A> a4) {
+ foo1_a1(a1);
+ foo1_a2(a2);
+ foo1_a3(a3);
+ foo1_a4(a4);
+}
+
+void foo2_a1(x) {}
+void foo2_a2(x) {}
+void foo2_a3(x) {}
+void foo2_a4(x) {}
+
+void foo2(Future<A> a1, A a2, FutureOr<A> a3, FutureOr<A> a4) {
+ foo2_a1(a1);
+ foo2_a2(a2);
+ foo2_a3(a3);
+ foo2_a4(a4);
+}
+
+Function unknown;
+getDynamic() => unknown.call();
+
+main(List<String> args) {
+ foo1(new Future<B>.value(new B()), new B(), new Future<B>.value(new B()),
+ new B());
+ foo2(getDynamic(), getDynamic(), getDynamic(), getDynamic());
+}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart.expect
new file mode 100644
index 0000000..f86761e
--- /dev/null
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart.expect
@@ -0,0 +1,42 @@
+library #lib;
+import self as self;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+class A extends core::Object {
+ synthetic constructor •() → void
+ : super core::Object::•()
+ ;
+}
+class B extends self::A {
+ synthetic constructor •() → void
+ : super self::A::•()
+ ;
+}
+[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function unknown;
+static method foo1_a1([@vm.inferred-type.metadata=dart.async::_Future] dynamic x) → void {}
+static method foo1_a2([@vm.inferred-type.metadata=#lib::B] dynamic x) → void {}
+static method foo1_a3([@vm.inferred-type.metadata=dart.async::_Future] dynamic x) → void {}
+static method foo1_a4([@vm.inferred-type.metadata=#lib::B] dynamic x) → void {}
+static method foo1([@vm.inferred-type.metadata=dart.async::_Future] asy::Future<self::A> a1, [@vm.inferred-type.metadata=#lib::B] self::A a2, [@vm.inferred-type.metadata=dart.async::_Future] asy::FutureOr<self::A> a3, [@vm.inferred-type.metadata=#lib::B] asy::FutureOr<self::A> a4) → void {
+ self::foo1_a1(a1);
+ self::foo1_a2(a2);
+ self::foo1_a3(a3);
+ self::foo1_a4(a4);
+}
+static method foo2_a1([@vm.inferred-type.metadata=dart.async::_Future?] dynamic x) → void {}
+static method foo2_a2([@vm.inferred-type.metadata=#lib::B?] dynamic x) → void {}
+static method foo2_a3(dynamic x) → void {}
+static method foo2_a4(dynamic x) → void {}
+static method foo2([@vm.inferred-type.metadata=dart.async::_Future?] asy::Future<self::A> a1, [@vm.inferred-type.metadata=#lib::B?] self::A a2, asy::FutureOr<self::A> a3, asy::FutureOr<self::A> a4) → void {
+ self::foo2_a1(a1);
+ self::foo2_a2(a2);
+ self::foo2_a3(a3);
+ self::foo2_a4(a4);
+}
+static method getDynamic() → dynamic
+ return self::unknown.call();
+static method main(core::List<core::String> args) → dynamic {
+ self::foo1([@vm.inferred-type.metadata=dart.async::_Future] asy::Future::value<self::B>(new self::B::•()), new self::B::•(), [@vm.inferred-type.metadata=dart.async::_Future] asy::Future::value<self::B>(new self::B::•()), new self::B::•());
+ self::foo2(self::getDynamic() as{TypeError} asy::Future<self::A>, self::getDynamic() as{TypeError} self::A, self::getDynamic() as{TypeError} asy::FutureOr<self::A>, self::getDynamic() as{TypeError} asy::FutureOr<self::A>);
+}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
index 237f42e..e4209cf 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
@@ -46,7 +46,7 @@
return [@vm.inferred-type.metadata=!] self::field1;
}
class D extends core::Object {
- field core::Object field2 = [@vm.inferred-type.metadata=!] self::getValue();
+[@vm.inferred-type.metadata=!] field core::Object field2 = [@vm.inferred-type.metadata=!] self::getValue();
synthetic constructor •() → void
: super core::Object::•()
;
@@ -55,26 +55,26 @@
synthetic constructor •() → void
: super core::Object::•()
;
- method barL1(self::D dd) → dynamic
+ method barL1([@vm.inferred-type.metadata=#lib::D] self::D dd) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL2] [@vm.inferred-type.metadata=!] this.{self::DeepCaller2::barL2}(dd);
- method barL2(self::D dd) → dynamic
+ method barL2([@vm.inferred-type.metadata=#lib::D] self::D dd) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL3] [@vm.inferred-type.metadata=!] this.{self::DeepCaller2::barL3}(dd);
- method barL3(self::D dd) → dynamic
+ method barL3([@vm.inferred-type.metadata=#lib::D] self::D dd) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL4] [@vm.inferred-type.metadata=!] this.{self::DeepCaller2::barL4}(dd);
- method barL4(self::D dd) → dynamic
+ method barL4([@vm.inferred-type.metadata=#lib::D] self::D dd) → dynamic
return [@vm.direct-call.metadata=#lib::D::field2] [@vm.inferred-type.metadata=!] dd.{self::D::field2};
}
-static field core::Function unknown;
-static field core::Object field1 = [@vm.inferred-type.metadata=!] self::getValue();
+[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function unknown;
+[@vm.inferred-type.metadata=!]static field core::Object field1 = [@vm.inferred-type.metadata=!] self::getValue();
static method getDynamic() → dynamic
return self::unknown.call();
static method getValue() → core::Object {
self::A aa = self::getDynamic() as{TypeError} self::A;
return [@vm.inferred-type.metadata=!] aa.{self::A::foo}();
}
-static method use1(self::DeepCaller1 x) → dynamic
+static method use1([@vm.inferred-type.metadata=#lib::DeepCaller1] self::DeepCaller1 x) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller1::barL1] [@vm.inferred-type.metadata=!] x.{self::DeepCaller1::barL1}();
-static method use2(self::DeepCaller2 x) → dynamic
+static method use2([@vm.inferred-type.metadata=#lib::DeepCaller2] self::DeepCaller2 x) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL1] [@vm.inferred-type.metadata=!] x.{self::DeepCaller2::barL1}(new self::D::•());
static method createC() → dynamic {
new self::C::•();
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect
index 344b2fb..6df2428 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect
@@ -36,13 +36,13 @@
synthetic constructor •() → void
: super core::Object::•()
;
- method bar(self::A aa) → dynamic
+ method bar([@vm.inferred-type.metadata=#lib::B?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::B::foo??] [@vm.inferred-type.metadata=#lib::T1] aa.{self::A::foo}();
}
-static field core::Function unknown;
-static method use1(self::Intermediate i, self::A aa) → dynamic
+[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function unknown;
+static method use1([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate i, [@vm.inferred-type.metadata=#lib::B?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::Intermediate::bar] [@vm.inferred-type.metadata=#lib::T1] i.{self::Intermediate::bar}(aa);
-static method use2(self::Intermediate i, self::A aa) → dynamic
+static method use2([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate i, [@vm.inferred-type.metadata=#lib::B?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::Intermediate::bar] [@vm.inferred-type.metadata=#lib::T1] i.{self::Intermediate::bar}(aa);
static method getDynamic() → dynamic
return self::unknown.call();
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect
index 79b33b7..9133d59 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect
@@ -54,12 +54,12 @@
method bar(self::A aa) → dynamic
return [@vm.inferred-type.metadata=!] aa.{self::A::foo}();
}
-static field core::Function unknown;
-static method use1(self::Intermediate i, self::A aa) → dynamic
+[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function unknown;
+static method use1([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate i, self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::Intermediate::bar] [@vm.inferred-type.metadata=!] i.{self::Intermediate::bar}(aa);
-static method use2(self::Intermediate i, self::A aa) → dynamic
+static method use2([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate i, self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::Intermediate::bar] [@vm.inferred-type.metadata=!] i.{self::Intermediate::bar}(aa);
-static method use3(self::Intermediate i, self::A aa) → dynamic
+static method use3([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate i, self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::Intermediate::bar] [@vm.inferred-type.metadata=!] i.{self::Intermediate::bar}(aa);
static method getDynamic() → dynamic
return self::unknown.call();
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect
index 68fff2b..55d3d4e 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect
@@ -39,7 +39,7 @@
method bazz() → dynamic
return new self::T3::•();
}
-static field core::Function unknown;
+[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function unknown;
static method use_foo1(dynamic x) → dynamic
return [@vm.inferred-type.metadata=#lib::T1] x.foo();
static method use_foo2(dynamic x) → dynamic
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
index eef7a9d..78b259d 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
@@ -13,8 +13,8 @@
;
}
class A extends core::Object {
- field dynamic field1 = new self::T1::•();
- field dynamic field2 = new self::T1::•();
+[@vm.inferred-type.metadata=#lib::T1] field dynamic field1 = new self::T1::•();
+[@vm.inferred-type.metadata=!] field dynamic field2 = new self::T1::•();
synthetic constructor •() → void
: super core::Object::•()
;
@@ -23,36 +23,36 @@
synthetic constructor •() → void
: super core::Object::•()
;
- method barL1(self::A aa) → dynamic
+ method barL1([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller1::barL2] [@vm.inferred-type.metadata=#lib::T1] this.{self::DeepCaller1::barL2}(aa);
- method barL2(self::A aa) → dynamic
+ method barL2([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller1::barL3] [@vm.inferred-type.metadata=#lib::T1] this.{self::DeepCaller1::barL3}(aa);
- method barL3(self::A aa) → dynamic
+ method barL3([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller1::barL4] [@vm.inferred-type.metadata=#lib::T1] this.{self::DeepCaller1::barL4}(aa);
- method barL4(self::A aa) → dynamic
+ method barL4([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::A::field1??] [@vm.inferred-type.metadata=#lib::T1] aa.{self::A::field1};
}
class DeepCaller2 extends core::Object {
synthetic constructor •() → void
: super core::Object::•()
;
- method barL1(self::A aa) → dynamic
+ method barL1([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL2] [@vm.inferred-type.metadata=!] this.{self::DeepCaller2::barL2}(aa);
- method barL2(self::A aa) → dynamic
+ method barL2([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL3] [@vm.inferred-type.metadata=!] this.{self::DeepCaller2::barL3}(aa);
- method barL3(self::A aa) → dynamic
+ method barL3([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL4] [@vm.inferred-type.metadata=!] this.{self::DeepCaller2::barL4}(aa);
- method barL4(self::A aa) → dynamic
+ method barL4([@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::A::field2??] [@vm.inferred-type.metadata=!] aa.{self::A::field2};
}
-static field core::Function unknown;
-static method use1(self::DeepCaller1 x, self::A aa) → dynamic
+[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function unknown;
+static method use1([@vm.inferred-type.metadata=#lib::DeepCaller1] self::DeepCaller1 x, [@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller1::barL1] [@vm.inferred-type.metadata=#lib::T1] x.{self::DeepCaller1::barL1}(aa);
-static method use2(self::DeepCaller2 x, self::A aa) → dynamic
+static method use2([@vm.inferred-type.metadata=#lib::DeepCaller2] self::DeepCaller2 x, [@vm.inferred-type.metadata=#lib::A?] self::A aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller2::barL1] [@vm.inferred-type.metadata=!] x.{self::DeepCaller2::barL1}(aa);
static method getDynamic() → dynamic
return self::unknown.call();
-static method setField2(self::A aa, dynamic value) → void {
+static method setField2([@vm.inferred-type.metadata=#lib::A] self::A aa, [@vm.inferred-type.metadata=#lib::T2] dynamic value) → void {
[@vm.direct-call.metadata=#lib::A::field2] aa.{self::A::field2} = value;
}
static method main(core::List<core::String> args) → dynamic {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart.expect
index 17533c2..5a3bce0 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart.expect
@@ -21,8 +21,8 @@
method foo() → void {}
}
class Point extends core::Object {
- final field self::I x;
- const constructor •(self::I x) → void
+[@vm.inferred-type.metadata=!] final field self::I x;
+ const constructor •([@vm.inferred-type.metadata=!] self::I x) → void
: self::Point::x = x, super core::Object::•()
;
method newPoint1() → self::Point
@@ -30,7 +30,7 @@
method newPoint2() → self::Point
return new self::Point::•([@vm.direct-call.metadata=#lib::Point::x] [@vm.inferred-type.metadata=!] this.{self::Point::x});
}
-static method getX(dynamic point) → dynamic {
+static method getX([@vm.inferred-type.metadata=#lib::Point] dynamic point) → dynamic {
point.x;
}
static method main() → dynamic {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect
index 2d4e301..7410cd7 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect
@@ -39,7 +39,7 @@
synthetic constructor •() → void
: super self::A::•()
;
- method noSuchMethod(core::Invocation invocation) → dynamic {
+ method noSuchMethod([@vm.inferred-type.metadata=dart.core::_InvocationMirror?] core::Invocation invocation) → dynamic {
return new self::T1::•();
}
}
@@ -47,7 +47,7 @@
synthetic constructor •() → void
: super core::Object::•()
;
- method noSuchMethod(core::Invocation invocation) → dynamic {
+ method noSuchMethod([@vm.inferred-type.metadata=dart.core::_InvocationMirror?] core::Invocation invocation) → dynamic {
return new self::T2::•();
}
}
@@ -62,7 +62,7 @@
;
method foo() → dynamic
throw "TFA Error: #lib::E::foo";
- method noSuchMethod(core::Invocation invocation) → dynamic {
+ method noSuchMethod([@vm.inferred-type.metadata=dart.core::_InvocationMirror?] core::Invocation invocation) → dynamic {
return new self::T4::•();
}
}
@@ -72,7 +72,7 @@
;
method twoArg(dynamic a1, dynamic a2) → dynamic
throw "TFA Error: #lib::F::twoArg";
- method noSuchMethod(core::Invocation invocation) → dynamic {
+ method noSuchMethod([@vm.inferred-type.metadata=dart.core::_InvocationMirror?] core::Invocation invocation) → dynamic {
return new self::T2::•();
}
}
@@ -80,13 +80,13 @@
synthetic constructor •() → void
: super core::Object::•()
;
- method noSuchMethod(core::Invocation invocation) → dynamic {
+ method noSuchMethod([@vm.inferred-type.metadata=dart.core::_InvocationMirror?] core::Invocation invocation) → dynamic {
return new self::T5::•();
}
}
-static field self::A bb = new self::B::•();
-static field self::A dd = new self::D::•();
-static field core::Function unknown;
+[@vm.inferred-type.metadata=#lib::B]static field self::A bb = new self::B::•();
+[@vm.inferred-type.metadata=#lib::D]static field self::A dd = new self::D::•();
+[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function unknown;
static method getDynamic() → dynamic
return self::unknown.call();
static method main(core::List<core::String> args) → dynamic {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect
index d00fa90..1f42b77 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect
@@ -24,7 +24,7 @@
}
class TearOffInterfaceMethod extends core::Object {
field dynamic bazz;
- constructor •(self::A arg) → void
+ constructor •([@vm.inferred-type.metadata=#lib::B] self::A arg) → void
: self::TearOffInterfaceMethod::bazz = arg.{self::A::foo}, super core::Object::•()
;
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_super_method.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_super_method.dart.expect
index 8a28d7c..a1b09f0 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_super_method.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_super_method.dart.expect
@@ -40,7 +40,7 @@
method bar() → core::int
return [@vm.direct-call.metadata=#lib::Base::doCall] this.{self::Base::doCall}(super.{self::Base::foo});
}
-static field self::A aa = new self::B::•();
+[@vm.inferred-type.metadata=#lib::B]static field self::A aa = new self::B::•();
static method knownResult() → dynamic
return new self::B::•();
static method main(core::List<core::String> args) → dynamic {
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index a5cc7ac..32aa820 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -36,8 +36,6 @@
#include "bin/gzip.h"
#endif
-#include "vm/kernel.h"
-
extern "C" {
extern const uint8_t kDartVmSnapshotData[];
extern const uint8_t kDartVmSnapshotInstructions[];
@@ -439,8 +437,8 @@
isolate = Dart_CreateIsolateFromKernel(script_uri, NULL, platform_program,
flags, isolate_data, error);
} else {
- *error = OS::SCreate(
- NULL, "Platform kernel not available to create service isolate.");
+ *error =
+ strdup("Platform kernel not available to create service isolate.");
delete isolate_data;
return NULL;
}
@@ -553,8 +551,11 @@
if (!isolate_run_app_snapshot && kernel_program == NULL) {
if (!dfe.CanUseDartFrontend()) {
- *error = OS::SCreate(NULL, "Dart frontend unavailable to compile %s.",
- script_uri);
+ const char* format = "Dart frontend unavailable to compile script %s.";
+ intptr_t len = snprintf(NULL, 0, format, script_uri) + 2;
+ *error = reinterpret_cast<char*>(malloc(len));
+ ASSERT(error != NULL);
+ snprintf(*error, len, format, script_uri);
return NULL;
}
diff --git a/runtime/observatory/tests/service/service_kernel.status b/runtime/observatory/tests/service/service_kernel.status
index 831090c..2618858 100644
--- a/runtime/observatory/tests/service/service_kernel.status
+++ b/runtime/observatory/tests/service/service_kernel.status
@@ -47,25 +47,33 @@
coverage_leaf_function_test: RuntimeError
coverage_optimized_function_test: Skip # Timeout
get_source_report_test: RuntimeError
-get_vm_timeline_rpc_test: Pass, Timeout
-issue_25465_test: Pass, Timeout
-issue_30555_test: Pass, Timeout
-next_through_assign_call_test: Pass, Timeout
-next_through_call_on_field_in_class_test: Pass, Timeout
-next_through_create_list_and_map_test: Pass, Timeout
-next_through_is_and_as_test: Pass, Timeout
-next_through_multi_catch_test: Pass, Timeout
-next_through_simple_async_with_returns_test: Pass, Timeout
-next_through_simple_linear_2_test: Pass, Timeout
+get_vm_timeline_rpc_test: Pass, Timeout # Issue 32137.
+issue_25465_test: Pass, Timeout # Issue 32137.
+issue_30555_test: Pass, RuntimeError, Timeout # Issue 32137.
+next_through_assign_call_test: Skip # Issues 32137 and 32138.
+next_through_assign_int_test: Skip # Issues 32137 and 32138.
+next_through_call_on_field_in_class_test: Pass, Timeout # Issue 32137.
+next_through_call_on_field_test: Skip # Issues 32137 and 32138.
+next_through_create_list_and_map_test: Skip # Issues 32137 and 32138.
+next_through_function_expression_test: Skip # Issues 32137 and 32138.
+next_through_is_and_as_test: Skip # Issues 32137 and 32138.
+next_through_multi_catch_test: Skip # Issues 32137 and 32138.
+next_through_simple_async_with_returns_test: Skip # Issues 32137 and 32138.
+next_through_simple_linear_2_test: Skip # Issues 32137 and 32138.
+next_through_simple_linear_test: Skip # Issues 32137 and 32138.
+pause_idle_isolate_test: Skip # Issues 32137 and 32138.
+pause_on_start_and_exit_test: Pass, RuntimeError # Issue 32137.
regress_28443_test: Pass, Timeout
+regress_28980_test: Skip # Issues 32137 and 32138.
reload_sources_test: RuntimeError
+set_vm_name_rpc_test: Pass, Timeout # Issue 32137.
step_test: Pass, Slow
step_through_constructor_test: Pass, Slow
-step_through_function_2_test: Pass, Timeout
-step_through_function_test: Pass, Timeout
-step_through_property_get_test: Pass, Timeout
-step_through_switch_test: Pass, Timeout
-step_through_switch_with_continue_test: Pass, Timeout
+step_through_function_2_test: Pass, Timeout # Issue 32137.
+step_through_function_test: Skip # Issues 32137 and 32138.
+step_through_property_get_test: Pass, Timeout # Issue 32137.
+step_through_switch_test: Pass, Timeout # Issue 32137.
+step_through_switch_with_continue_test: Pass, Timeout # Issue 32137.
[ $compiler == dartk && $system == windows && $strong ]
add_breakpoint_rpc_kernel_test: Skip # Timeout
@@ -103,3 +111,4 @@
[ $compiler == dartk && $strong && ($arch == simarm || $arch == simarm64) ]
async_single_step_exception_test: RuntimeError
+
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index 2856f70..c311538 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -1979,16 +1979,23 @@
}
}
intptr_t cid = cls.id();
- if ((cid == kMintCid) || (cid == kBigintCid) || (cid == kDoubleCid)) {
+ if ((cid == kMintCid) || (cid == kBigintCid)) {
// Constants stored as a plain list, no rehashing needed.
constants = Array::MakeFixedLength(retained_constants);
cls.set_constants(constants);
} else {
// Rehash.
cls.set_constants(Object::empty_array());
- for (intptr_t j = 0; j < retained_constants.Length(); j++) {
- constant ^= retained_constants.At(j);
- cls.InsertCanonicalConstant(Z, constant);
+ if (cid == kDoubleCid) {
+ for (intptr_t j = 0; j < retained_constants.Length(); j++) {
+ constant ^= retained_constants.At(j);
+ cls.InsertCanonicalDouble(Z, Double::Cast(constant));
+ }
+ } else {
+ for (intptr_t j = 0; j < retained_constants.Length(); j++) {
+ constant ^= retained_constants.At(j);
+ cls.InsertCanonicalConstant(Z, constant);
+ }
}
}
diff --git a/runtime/vm/compiler/backend/type_propagator.cc b/runtime/vm/compiler/backend/type_propagator.cc
index d69740c..dfbd141 100644
--- a/runtime/vm/compiler/backend/type_propagator.cc
+++ b/runtime/vm/compiler/backend/type_propagator.cc
@@ -947,10 +947,29 @@
// Note: in catch-blocks we have ParameterInstr for each local variable
// not only for normal parameters.
if (index() < scope->num_variables()) {
- LocalVariable* param = scope->VariableAt(index());
+ const LocalVariable* param = scope->VariableAt(index());
+ CompileType* inferred_type = NULL;
+ if (block_->IsGraphEntry()) {
+ inferred_type = param->parameter_type();
+ }
+ // Best bet: use inferred type if it has a concrete class.
+ if ((inferred_type != NULL) &&
+ (inferred_type->ToNullableCid() != kDynamicCid)) {
+ TraceStrongModeType(this, inferred_type);
+ return *inferred_type;
+ }
+ // If parameter type was checked by caller, then use Dart type annotation,
+ // plus non-nullability from inferred type if known.
if (param->was_type_checked_by_caller()) {
- return CompileType::FromAbstractType(param->type(),
- CompileType::kNullable);
+ const bool is_nullable =
+ (inferred_type == NULL) || inferred_type->is_nullable();
+ TraceStrongModeType(this, param->type());
+ return CompileType::FromAbstractType(param->type(), is_nullable);
+ }
+ // Last resort: use inferred non-nullability.
+ if (inferred_type != NULL) {
+ TraceStrongModeType(this, inferred_type);
+ return *inferred_type;
}
}
}
@@ -1063,6 +1082,7 @@
CompileType* inferred_type = result_type();
if ((inferred_type != NULL) &&
(inferred_type->ToNullableCid() != kDynamicCid)) {
+ TraceStrongModeType(this, inferred_type);
return *inferred_type;
}
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
index dd4a560..cf07b3e 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
@@ -771,7 +771,12 @@
Class::Handle(builder_->zone_, H.LookupClassByKernelClass(kernel_name));
ASSERT(!klass.IsNull());
- const intptr_t cid = klass.id();
+ intptr_t cid = klass.id();
+ if (cid == kClosureCid) {
+ // VM uses more specific function types and doesn't expect instances of
+ // _Closure class, so inferred _Closure class doesn't make sense for the VM.
+ cid = kDynamicCid;
+ }
return InferredTypeMetadata(cid, nullable);
}
@@ -2053,6 +2058,8 @@
intptr_t pos,
ParameterTypeCheckMode type_check_mode) {
intptr_t kernel_offset = builder_->ReaderOffset(); // no tag.
+ const InferredTypeMetadata parameter_type =
+ builder_->inferred_type_metadata_helper_.GetInferredType(kernel_offset);
VariableDeclarationHelper helper(builder_);
helper.ReadUntilExcluding(VariableDeclarationHelper::kType);
String& name = H.DartSymbol(helper.name_index_);
@@ -2060,8 +2067,8 @@
helper.SetJustRead(VariableDeclarationHelper::kType);
helper.ReadUntilExcluding(VariableDeclarationHelper::kInitializer);
- LocalVariable* variable =
- MakeVariable(helper.position_, helper.position_, name, type);
+ LocalVariable* variable = MakeVariable(helper.position_, helper.position_,
+ name, type, ¶meter_type);
if (helper.IsFinal()) {
variable->set_is_final();
}
@@ -2113,8 +2120,15 @@
TokenPosition declaration_pos,
TokenPosition token_pos,
const String& name,
- const AbstractType& type) {
- return new (Z) LocalVariable(declaration_pos, token_pos, name, type);
+ const AbstractType& type,
+ const InferredTypeMetadata* param_type_md /* = NULL */) {
+ CompileType* param_type = NULL;
+ if ((param_type_md != NULL) && !param_type_md->IsTrivial()) {
+ param_type = new (Z) CompileType(CompileType::CreateNullable(
+ param_type_md->nullable, param_type_md->cid));
+ }
+ return new (Z)
+ LocalVariable(declaration_pos, token_pos, name, type, param_type);
}
void StreamingScopeBuilder::AddExceptionVariable(
@@ -6885,9 +6899,10 @@
argument_names, ICData::kNoRebind, &result_type,
type_args_len);
} else {
- instructions += InstanceCall(
- position, name, token_kind, type_args_len, argument_count,
- argument_names, checked_argument_count, *interface_target, &result_type);
+ instructions +=
+ InstanceCall(position, name, token_kind, type_args_len, argument_count,
+ argument_names, checked_argument_count, *interface_target,
+ &result_type);
}
// Drop temporaries preserving result on the top of the stack.
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h
index 34df86f..5bef7e4 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h
@@ -577,6 +577,8 @@
const intptr_t cid;
const bool nullable;
+
+ bool IsTrivial() const { return (cid == kDynamicCid) && nullable; }
};
// Helper class which provides access to inferred type metadata.
@@ -744,7 +746,8 @@
LocalVariable* MakeVariable(TokenPosition declaration_pos,
TokenPosition token_pos,
const String& name,
- const AbstractType& type);
+ const AbstractType& type,
+ const InferredTypeMetadata* param_type_md = NULL);
void AddExceptionVariable(GrowableArray<LocalVariable*>* variables,
const char* prefix,
diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc
index ede8726..a3c0dd1 100644
--- a/runtime/vm/compiler/frontend/kernel_to_il.cc
+++ b/runtime/vm/compiler/frontend/kernel_to_il.cc
@@ -1227,22 +1227,23 @@
Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld))));
}
-Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
- const String& name,
- Token::Kind kind,
- intptr_t type_args_len,
- intptr_t argument_count,
- const Array& argument_names,
- intptr_t checked_argument_count,
- const Function& interface_target,
- const InferredTypeMetadata* result_type) {
+Fragment FlowGraphBuilder::InstanceCall(
+ TokenPosition position,
+ const String& name,
+ Token::Kind kind,
+ intptr_t type_args_len,
+ intptr_t argument_count,
+ const Array& argument_names,
+ intptr_t checked_argument_count,
+ const Function& interface_target,
+ const InferredTypeMetadata* result_type) {
const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0);
ArgumentArray arguments = GetArguments(total_count);
InstanceCallInstr* call = new (Z) InstanceCallInstr(
position, name, kind, arguments, type_args_len, argument_names,
checked_argument_count, ic_data_array_, GetNextDeoptId(),
interface_target);
- if (result_type != NULL) {
+ if ((result_type != NULL) && !result_type->IsTrivial()) {
call->SetResultType(Z, CompileType::CreateNullable(result_type->nullable,
result_type->cid));
}
@@ -1528,7 +1529,7 @@
ASSERT((result_type == NULL) || (result_type->cid == kDynamicCid) ||
(result_type->cid == recognized_cid));
call->SetResultType(Z, CompileType::FromCid(recognized_cid));
- } else if (result_type != NULL) {
+ } else if ((result_type != NULL) && !result_type->IsTrivial()) {
call->SetResultType(Z, CompileType::CreateNullable(result_type->nullable,
result_type->cid));
}
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 49cb711..6ee6b79 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -5925,14 +5925,23 @@
Dart_CompileToKernel(const char* script_uri,
const uint8_t* platform_kernel,
intptr_t platform_kernel_size) {
-#if defined(DART_PRECOMPILED_RUNTIME)
Dart_KernelCompilationResult result;
+#if defined(DART_PRECOMPILED_RUNTIME)
result.status = Dart_KernelCompilationStatus_Unknown;
result.error = strdup("Dart_CompileToKernel is unsupported.");
return result;
#else
- return KernelIsolate::CompileToKernel(script_uri, platform_kernel,
- platform_kernel_size, 0, NULL, true);
+ result = KernelIsolate::CompileToKernel(script_uri, platform_kernel,
+ platform_kernel_size, 0, NULL, true);
+ if (result.status == Dart_KernelCompilationStatus_Ok) {
+ if (KernelIsolate::AcceptCompilation().status !=
+ Dart_KernelCompilationStatus_Ok) {
+ FATAL(
+ "An error occurred in the CFE while accepting the most recent"
+ " compilation results.");
+ }
+ }
+ return result;
#endif
}
@@ -5943,15 +5952,25 @@
int source_files_count,
Dart_SourceFile sources[],
bool incremental_compile) {
-#if defined(DART_PRECOMPILED_RUNTIME)
Dart_KernelCompilationResult result;
+#if defined(DART_PRECOMPILED_RUNTIME)
result.status = Dart_KernelCompilationStatus_Unknown;
result.error = strdup("Dart_CompileSourcesToKernel is unsupported.");
return result;
#else
- return KernelIsolate::CompileToKernel(
+ result = KernelIsolate::CompileToKernel(
script_uri, platform_kernel, platform_kernel_size, source_files_count,
sources, incremental_compile);
+ if (result.status == Dart_KernelCompilationStatus_Ok) {
+ if (KernelIsolate::AcceptCompilation().status !=
+ Dart_KernelCompilationStatus_Ok) {
+ FATAL(
+ "An error occurred in the CFE while accepting the most recent"
+ " compilation results.");
+ }
+ }
+ return result;
+
#endif
}
diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc
index 9dc702d..6db3341 100644
--- a/runtime/vm/isolate_reload.cc
+++ b/runtime/vm/isolate_reload.cc
@@ -521,6 +521,16 @@
free(buffer);
}
+static void AcceptCompilation(Thread* thread) {
+ TransitionVMToNative transition(thread);
+ if (KernelIsolate::AcceptCompilation().status !=
+ Dart_KernelCompilationStatus_Ok) {
+ FATAL(
+ "An error occurred in the CFE while accepting the most recent"
+ " compilation results.");
+ }
+}
+
// NOTE: This function returns *after* FinalizeLoading is called.
void IsolateReloadContext::Reload(bool force_reload,
const char* root_script_url,
@@ -559,6 +569,8 @@
if (packages_url_ != NULL) {
packages_url = String::New(packages_url_);
}
+
+ bool did_kernel_compilation = false;
if (isolate()->use_dart_frontend()) {
// Load the kernel program and figure out the modified libraries.
const GrowableObjectArray& libs =
@@ -592,7 +604,7 @@
CommonFinalizeTail();
return;
}
-
+ did_kernel_compilation = true;
kernel_program.set(
ReadPrecompiledKernelFromBuffer(retval.kernel, retval.kernel_size));
}
@@ -611,6 +623,13 @@
I->object_store()->set_changed_in_last_reload(
GrowableObjectArray::Handle(GrowableObjectArray::New()));
ReportOnJSON(js_);
+
+ // If we use the CFE and performed a compilation, we need to notify that
+ // we have accepted the compilation to clear some state in the incremental
+ // compiler.
+ if (isolate()->use_dart_frontend() && did_kernel_compilation) {
+ AcceptCompilation(thread);
+ }
TIR_Print("---- SKIPPING RELOAD (No libraries were modified)\n");
return;
}
@@ -671,6 +690,13 @@
isolate()->object_store()->set_root_library(lib);
FinalizeLoading();
result = Object::null();
+
+ // If we use the CFE and performed a compilation, we need to notify that
+ // we have accepted the compilation to clear some state in the incremental
+ // compiler.
+ if (did_kernel_compilation) {
+ AcceptCompilation(thread);
+ }
} else {
result = tmp.raw();
}
diff --git a/runtime/vm/kernel_isolate.cc b/runtime/vm/kernel_isolate.cc
index 7b0f1f6..829c764 100644
--- a/runtime/vm/kernel_isolate.cc
+++ b/runtime/vm/kernel_isolate.cc
@@ -46,10 +46,12 @@
// Current tags include the following:
// 0 - Perform normal compilation.
// 1 - Update in-memory file system with in-memory sources (used by tests).
-// 2 - APP JIT snapshot training run for kernel_service.
+// 2 - Accept last compilation result.
+// 3 - APP JIT snapshot training run for kernel_service.
const int KernelIsolate::kCompileTag = 0;
const int KernelIsolate::kUpdateSourcesTag = 1;
-const int KernelIsolate::kTrainTag = 2;
+const int KernelIsolate::kAcceptTag = 2;
+const int KernelIsolate::kTrainTag = 3;
Dart_IsolateCreateCallback KernelIsolate::create_callback_ = NULL;
Monitor* KernelIsolate::monitor_ = new Monitor();
@@ -568,6 +570,22 @@
incremental_compile);
}
+Dart_KernelCompilationResult KernelIsolate::AcceptCompilation() {
+ // This must be the main script to be loaded. Wait for Kernel isolate
+ // to finish initialization.
+ Dart_Port kernel_port = WaitForKernelPort();
+ if (kernel_port == ILLEGAL_PORT) {
+ Dart_KernelCompilationResult result;
+ result.status = Dart_KernelCompilationStatus_Unknown;
+ result.error = strdup("Error while initializing Kernel isolate");
+ return result;
+ }
+
+ KernelCompilationRequest request;
+ return request.SendAndWaitForResponse(kAcceptTag, kernel_port, NULL, NULL, 0,
+ 0, NULL, true);
+}
+
Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources(
int source_files_count,
Dart_SourceFile source_files[]) {
diff --git a/runtime/vm/kernel_isolate.h b/runtime/vm/kernel_isolate.h
index 6d32010..001aa41 100644
--- a/runtime/vm/kernel_isolate.h
+++ b/runtime/vm/kernel_isolate.h
@@ -20,6 +20,7 @@
static const char* kName;
static const int kCompileTag;
static const int kUpdateSourcesTag;
+ static const int kAcceptTag;
static const int kTrainTag;
static void Run();
@@ -39,6 +40,7 @@
Dart_SourceFile source_files[] = NULL,
bool incremental_compile = true);
+ static Dart_KernelCompilationResult AcceptCompilation();
static Dart_KernelCompilationResult UpdateInMemorySources(
int source_files_count,
Dart_SourceFile source_files[]);
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 840ca2f..9a8cf11 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -4403,31 +4403,77 @@
patch_prefix, class_name);
}
-// Returns an instance of Double or Double::null().
-// 'index' points to either:
-// - constants_list_ position of found element, or
-// - constants_list_ position where new canonical can be inserted.
-RawDouble* Class::LookupCanonicalDouble(Zone* zone,
- double value,
- intptr_t* index) const {
- ASSERT(this->raw() == Isolate::Current()->object_store()->double_class());
- const Array& constants = Array::Handle(zone, this->constants());
- const intptr_t constants_len = constants.Length();
- // Linear search to see whether this value is already present in the
- // list of canonicalized constants.
- Double& canonical_value = Double::Handle(zone);
- while (*index < constants_len) {
- canonical_value ^= constants.At(*index);
- if (canonical_value.IsNull()) {
- break;
- }
- if (canonical_value.BitwiseEqualsToDouble(value)) {
- ASSERT(canonical_value.IsCanonical());
- return canonical_value.raw();
- }
- *index = *index + 1;
+class CanonicalDoubleKey {
+ public:
+ explicit CanonicalDoubleKey(const Double& key)
+ : key_(&key), value_(key.value()) {}
+ explicit CanonicalDoubleKey(const double value) : key_(NULL), value_(value) {}
+
+ bool Matches(const Double& obj) const {
+ return obj.BitwiseEqualsToDouble(value_);
}
- return Double::null();
+ uword Hash() const { return Hash(value_); }
+
+ // Thomas Wang, Integer Hash Functions.
+ // https://gist.github.com/badboy/6267743
+ // "64 bit to 32 bit Hash Functions"
+ static uword Hash(double value) {
+ uint64_t v = bit_cast<uint64_t>(value);
+ v = ~v + (v << 18);
+ v = v ^ (v >> 31);
+ v = v * 21;
+ v = v ^ (v >> 11);
+ v = v + (v << 6);
+ v = v ^ (v >> 22);
+ return static_cast<uint32_t>(v);
+ }
+
+ const Double* key_;
+ const double value_;
+
+ private:
+ DISALLOW_ALLOCATION();
+};
+
+// Traits for looking up Canonical Instances based on a hash of the fields.
+class CanonicalDoubleTraits {
+ public:
+ static const char* Name() { return "CanonicalDoubleTraits"; }
+ static bool ReportStats() { return false; }
+
+ // Called when growing the table.
+ static bool IsMatch(const Object& a, const Object& b) {
+ return a.raw() == b.raw();
+ }
+ static bool IsMatch(const CanonicalDoubleKey& a, const Object& b) {
+ return a.Matches(Double::Cast(b));
+ }
+ static uword Hash(const Object& key) {
+ ASSERT(key.IsDouble());
+ return CanonicalDoubleKey::Hash(Double::Cast(key).value());
+ }
+ static uword Hash(const CanonicalDoubleKey& key) { return key.Hash(); }
+ static RawObject* NewKey(const CanonicalDoubleKey& obj) {
+ if (obj.key_ != NULL) {
+ return obj.key_->raw();
+ } else {
+ UNIMPLEMENTED();
+ return NULL;
+ }
+ }
+};
+typedef UnorderedHashSet<CanonicalDoubleTraits> CanonicalDoubleSet;
+
+// Returns an instance of Double or Double::null().
+RawDouble* Class::LookupCanonicalDouble(Zone* zone, double value) const {
+ ASSERT(this->raw() == Isolate::Current()->object_store()->double_class());
+ if (this->constants() == Object::empty_array().raw()) return Double::null();
+
+ Double& canonical_value = Double::Handle(zone);
+ CanonicalDoubleSet constants(zone, this->constants());
+ canonical_value ^= constants.GetOrNull(CanonicalDoubleKey(value));
+ this->set_constants(constants.Release());
+ return canonical_value.raw();
}
RawMint* Class::LookupCanonicalMint(Zone* zone,
@@ -4554,9 +4600,19 @@
return canonical_value.raw();
}
-void Class::InsertCanonicalNumber(Zone* zone,
- intptr_t index,
- const Number& constant) const {
+void Class::InsertCanonicalDouble(Zone* zone, const Double& constant) const {
+ if (this->constants() == Object::empty_array().raw()) {
+ this->set_constants(Array::Handle(
+ zone, HashTables::New<CanonicalDoubleSet>(128, Heap::kOld)));
+ }
+ CanonicalDoubleSet constants(zone, this->constants());
+ constants.InsertNewOrGet(CanonicalDoubleKey(constant));
+ this->set_constants(constants.Release());
+}
+
+void Class::InsertCanonicalInt(Zone* zone,
+ intptr_t index,
+ const Number& constant) const {
// The constant needs to be added to the list. Grow the list if it is full.
Array& canonical_list = Array::Handle(zone, constants());
const intptr_t list_len = canonical_list.Length();
@@ -4571,7 +4627,8 @@
void Class::RehashConstants(Zone* zone) const {
intptr_t cid = id();
if ((cid == kMintCid) || (cid == kBigintCid) || (cid == kDoubleCid)) {
- // Constants stored as a plain list, no rehashing needed.
+ // Constants stored as a plain list or in a hashset with a stable hashcode,
+ // which only depends on the actual value of the constant.
return;
}
@@ -4579,6 +4636,7 @@
if (old_constants.Length() == 0) return;
set_constants(Object::empty_array());
+
CanonicalInstancesSet set(zone, old_constants.raw());
Instance& constant = Instance::Handle(zone);
CanonicalInstancesSet::Iterator it(&set);
@@ -18584,7 +18642,7 @@
}
ASSERT(result.IsOld());
result.SetCanonical();
- cls.InsertCanonicalNumber(zone, index, result);
+ cls.InsertCanonicalInt(zone, index, result);
return result.raw();
}
}
@@ -18610,7 +18668,7 @@
}
case kDoubleCid: {
Double& dbl = Double::Handle(zone);
- dbl ^= cls.LookupCanonicalDouble(zone, Double::Cast(*this).value(), &idx);
+ dbl ^= cls.LookupCanonicalDouble(zone, Double::Cast(*this).value());
return (dbl.raw() == this->raw());
}
case kBigintCid: {
@@ -19110,7 +19168,7 @@
canonical_value.SetCanonical();
// The value needs to be added to the constants list. Grow the list if
// it is full.
- cls.InsertCanonicalNumber(zone, index, canonical_value);
+ cls.InsertCanonicalInt(zone, index, canonical_value);
return canonical_value.raw();
}
}
@@ -19228,9 +19286,8 @@
// Linear search to see whether this value is already present in the
// list of canonicalized constants.
Double& canonical_value = Double::Handle(zone);
- intptr_t index = 0;
- canonical_value ^= cls.LookupCanonicalDouble(zone, value, &index);
+ canonical_value ^= cls.LookupCanonicalDouble(zone, value);
if (!canonical_value.IsNull()) {
return canonical_value.raw();
}
@@ -19238,16 +19295,15 @@
SafepointMutexLocker ml(isolate->constant_canonicalization_mutex());
// Retry lookup.
{
- canonical_value ^= cls.LookupCanonicalDouble(zone, value, &index);
+ canonical_value ^= cls.LookupCanonicalDouble(zone, value);
if (!canonical_value.IsNull()) {
return canonical_value.raw();
}
}
canonical_value = Double::New(value, Heap::kOld);
canonical_value.SetCanonical();
- // The value needs to be added to the constants list. Grow the list if
- // it is full.
- cls.InsertCanonicalNumber(zone, index, canonical_value);
+ // The value needs to be added to the constants list.
+ cls.InsertCanonicalDouble(zone, canonical_value);
return canonical_value.raw();
}
}
@@ -19544,7 +19600,7 @@
value.SetCanonical();
// The value needs to be added to the constants list. Grow the list if
// it is full.
- cls.InsertCanonicalNumber(zone, index, value);
+ cls.InsertCanonicalInt(zone, index, value);
return value.raw();
}
}
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index a409542..1c15efe 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1210,13 +1210,11 @@
RawLibraryPrefix* LookupLibraryPrefix(const String& name) const;
- // Returns an instance of Double or Double::null().
+ RawDouble* LookupCanonicalDouble(Zone* zone, double value) const;
+ // Returns an instance of Mint or Mint::null().
// 'index' points to either:
// - constants_list_ position of found element, or
// - constants_list_ position where new canonical can be inserted.
- RawDouble* LookupCanonicalDouble(Zone* zone,
- double value,
- intptr_t* index) const;
RawMint* LookupCanonicalMint(Zone* zone,
int64_t value,
intptr_t* index) const;
@@ -1228,9 +1226,10 @@
RawInstance* InsertCanonicalConstant(Zone* zone,
const Instance& constant) const;
- void InsertCanonicalNumber(Zone* zone,
- intptr_t index,
- const Number& constant) const;
+ void InsertCanonicalDouble(Zone* zone, const Double& constant) const;
+ void InsertCanonicalInt(Zone* zone,
+ intptr_t index,
+ const Number& constant) const;
void RehashConstants(Zone* zone) const;
diff --git a/runtime/vm/scopes.h b/runtime/vm/scopes.h
index 7a1a51e..e739416 100644
--- a/runtime/vm/scopes.h
+++ b/runtime/vm/scopes.h
@@ -16,6 +16,7 @@
namespace dart {
+class CompileType;
class LocalScope;
class LocalVariable : public ZoneAllocated {
@@ -23,12 +24,14 @@
LocalVariable(TokenPosition declaration_pos,
TokenPosition token_pos,
const String& name,
- const AbstractType& type)
+ const AbstractType& type,
+ CompileType* parameter_type = NULL)
: declaration_pos_(declaration_pos),
token_pos_(token_pos),
name_(name),
owner_(NULL),
type_(type),
+ parameter_type_(parameter_type),
const_value_(NULL),
is_final_(false),
is_captured_(false),
@@ -53,6 +56,8 @@
const AbstractType& type() const { return type_; }
+ CompileType* parameter_type() const { return parameter_type_; }
+
bool is_final() const { return is_final_; }
void set_is_final() { is_final_ = true; }
@@ -135,6 +140,8 @@
const AbstractType& type_; // Declaration type of local variable.
+ CompileType* const parameter_type_; // NULL or incoming parameter type.
+
const Instance* const_value_; // NULL or compile-time const value.
bool is_final_; // If true, this variable is readonly.
diff --git a/sdk/lib/_http/websocket.dart b/sdk/lib/_http/websocket.dart
index 99dc790..33a4f18 100644
--- a/sdk/lib/_http/websocket.dart
+++ b/sdk/lib/_http/websocket.dart
@@ -413,6 +413,18 @@
* not, the receiving end will close the connection.
*/
void addUtf8Text(List<int> bytes);
+
+ /**
+ * Gets the user agent used for WebSocket connections.
+ */
+ static String get userAgent => _WebSocketImpl.userAgent;
+
+ /**
+ * Sets the user agent to use for WebSocket connections.
+ */
+ static set userAgent(String userAgent) {
+ _WebSocketImpl.userAgent = userAgent;
+ }
}
class WebSocketException implements IOException {
diff --git a/sdk/lib/_http/websocket_impl.dart b/sdk/lib/_http/websocket_impl.dart
index 4ed7bb2..fa89b00 100644
--- a/sdk/lib/_http/websocket_impl.dart
+++ b/sdk/lib/_http/websocket_impl.dart
@@ -1249,6 +1249,12 @@
return _sink.close();
}
+ static String get userAgent => _httpClient.userAgent;
+
+ static set userAgent(String userAgent) {
+ _httpClient.userAgent = userAgent;
+ }
+
void _close([int code, String reason]) {
if (_writeClosed) return;
if (_outCloseCode == null) {
diff --git a/sdk/lib/_internal/js_runtime/lib/js_rti.dart b/sdk/lib/_internal/js_runtime/lib/js_rti.dart
index e7d9bef..f4c540e 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_rti.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_rti.dart
@@ -539,6 +539,13 @@
* against.
*/
bool checkSubtype(Object object, String isField, List checks, String asField) {
+ return JS_GET_FLAG('STRONG_MODE')
+ ? checkSubtypeV2(object, isField, checks, asField)
+ : checkSubtypeV1(object, isField, checks, asField);
+}
+
+bool checkSubtypeV1(
+ Object object, String isField, List checks, String asField) {
if (object == null) return false;
var arguments = getRuntimeTypeInfo(object);
// Interceptor is needed for JSArray and native classes.
@@ -551,7 +558,24 @@
if (isSubclass == null) return false;
// Should the asField function be passed the receiver?
var substitution = getField(interceptor, asField);
- return checkArguments(substitution, arguments, checks);
+ return checkArgumentsV1(substitution, arguments, checks);
+}
+
+bool checkSubtypeV2(
+ Object object, String isField, List checks, String asField) {
+ if (object == null) return false;
+ var arguments = getRuntimeTypeInfo(object);
+ // Interceptor is needed for JSArray and native classes.
+ // TODO(sra): It could be a more specialized interceptor since [object] is not
+ // `null` or a primitive.
+ // TODO(9586): Move type info for static functions onto an interceptor.
+ var interceptor = getInterceptor(object);
+ var isSubclass = getField(interceptor, isField);
+ // When we read the field and it is not there, [isSubclass] will be `null`.
+ if (isSubclass == null) return false;
+ // Should the asField function be passed the receiver?
+ var substitution = getField(interceptor, asField);
+ return checkArgumentsV2(substitution, arguments, null, checks, null);
}
/// Returns the field's type name.
@@ -564,6 +588,7 @@
isCheckPropertyToJsConstructorName(isField), arguments);
}
+/// Called from generated code.
Object subtypeCast(Object object, String isField, List checks, String asField) {
if (object == null) return object;
if (checkSubtype(object, isField, checks, asField)) return object;
@@ -571,6 +596,7 @@
throw new CastErrorImplementation(object, typeName);
}
+/// Called from generated code.
Object assertSubtype(
Object object, String isField, List checks, String asField) {
if (object == null) return object;
@@ -581,6 +607,8 @@
/// Checks that the type represented by [subtype] is a subtype of [supertype].
/// If not a type error with [message] is thrown.
+///
+/// Called from generated code.
assertIsSubtype(var subtype, var supertype, String message) {
if (!isSubtype(subtype, supertype)) {
throwTypeError(message);
@@ -599,8 +627,13 @@
* See the comment in the beginning of this file for a description of the
* possible values for [substitution].
*/
-bool checkArguments(var substitution, var arguments, var checks) {
- return areSubtypes(substitute(substitution, arguments), checks);
+bool checkArgumentsV1(var substitution, var arguments, var checks) {
+ return areSubtypesV1(substitute(substitution, arguments), checks);
+}
+
+bool checkArgumentsV2(
+ var substitution, var arguments, var sEnv, var checks, var tEnv) {
+ return areSubtypesV2(substitute(substitution, arguments), sEnv, checks, tEnv);
}
/**
@@ -614,7 +647,8 @@
* See the comment in the beginning of this file for a description of type
* representations.
*/
-bool areSubtypes(var s, var t) {
+
+bool areSubtypesV1(var s, var t) {
// `null` means a raw type.
if (s == null || t == null) return true;
@@ -624,7 +658,33 @@
int len = getLength(s);
for (int i = 0; i < len; i++) {
- if (!isSubtype(getIndex(s, i), getIndex(t, i))) {
+ if (!isSubtypeV1(getIndex(s, i), getIndex(t, i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool areSubtypesV2(var s, var sEnv, var t, var tEnv) {
+ // `null` means a raw type.
+ if (t == null) return true;
+ if (s == null) {
+ int len = getLength(t);
+ for (int i = 0; i < len; i++) {
+ if (!isSubtypeV2(null, null, getIndex(t, i), tEnv)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ assert(isJsArray(s));
+ assert(isJsArray(t));
+ assert(getLength(s) == getLength(t));
+
+ int len = getLength(s);
+ for (int i = 0; i < len; i++) {
+ if (!isSubtypeV2(getIndex(s, i), sEnv, getIndex(t, i), tEnv)) {
return false;
}
}
@@ -684,6 +744,7 @@
return isSubtype(type, t);
}
+/// Called from generated code.
Object subtypeOfRuntimeTypeCast(Object object, var type) {
if (object != null && !checkSubtypeOfRuntimeType(object, type)) {
throw new CastErrorImplementation(object, runtimeTypeToString(type));
@@ -691,6 +752,7 @@
return object;
}
+/// Called from generated code.
Object assertSubtypeOfRuntimeType(Object object, var type) {
if (object != null && !checkSubtypeOfRuntimeType(object, type)) {
throw new TypeErrorImplementation(object, runtimeTypeToString(type));
@@ -717,6 +779,12 @@
* constructor of the class, or an array (for generic class types).
*/
bool isSubtype(var s, var t) {
+ return JS_GET_FLAG('STRONG_MODE')
+ ? isSubtypeV2(s, null, t, null)
+ : isSubtypeV1(s, t);
+}
+
+bool isSubtypeV1(var s, var t) {
// Subtyping is reflexive.
if (isIdentical(s, t)) return true;
// If either type is dynamic, [s] is a subtype of [t].
@@ -734,7 +802,7 @@
if (isNullType(s)) return true;
if (isDartFunctionType(t)) {
- return isFunctionSubtype(s, t);
+ return isFunctionSubtypeV1(s, t);
}
// Check function types against the Function class and the Object class.
if (isDartFunctionType(s)) {
@@ -766,17 +834,79 @@
return true;
}
// Recursively check the type arguments.
- return checkArguments(substitution, getArguments(s), getArguments(t));
+ return checkArgumentsV1(substitution, getArguments(s), getArguments(t));
}
-bool isAssignable(var s, var t) {
- return isSubtype(s, t) || isSubtype(t, s);
+bool isSubtypeV2(var s, var sEnv, var t, var tEnv) {
+ // Subtyping is reflexive.
+ if (isIdentical(s, t)) return true;
+
+ // [t] is a top type?
+ if (t == null) return true;
+ if (isDartObjectTypeRti(t)) return true;
+ // TODO(sra): void is a top type.
+
+ // [s] is a top type?
+ if (s == null) return false;
+
+ // Generic function type parameters must match exactly, which would have
+ // exited earlier. The de Bruijn indexing ensures the representation as a
+ // small number can be used for type comparison.
+ if (isGenericFunctionTypeParameter(s)) {
+ // TODO(sra): Use the bound of the type variable.
+ return false;
+ }
+ if (isGenericFunctionTypeParameter(t)) return false;
+
+ if (isNullType(s)) return true;
+
+ if (isDartFunctionType(t)) {
+ return isFunctionSubtypeV2(s, sEnv, t, tEnv);
+ }
+
+ if (isDartFunctionType(s)) {
+ // Check function types against the `Function` class (`Object` is also a
+ // supertype, but is tested above with other 'top' types.).
+ return isDartFunctionTypeRti(t);
+ }
+
+ // Get the object describing the class and check for the subtyping flag
+ // constructed from the type of [t].
+ var typeOfS = isJsArray(s) ? getIndex(s, 0) : s;
+ var typeOfT = isJsArray(t) ? getIndex(t, 0) : t;
+
+ // Check for a subtyping flag.
+ // Get the necessary substitution of the type arguments, if there is one.
+ var substitution;
+ if (isNotIdentical(typeOfT, typeOfS)) {
+ String typeOfTString = runtimeTypeToString(typeOfT);
+ if (!builtinIsSubtype(typeOfS, typeOfTString)) {
+ return false;
+ }
+ var typeOfSPrototype = JS('', '#.prototype', typeOfS);
+ var field = '${JS_GET_NAME(JsGetName.OPERATOR_AS_PREFIX)}${typeOfTString}';
+ substitution = getField(typeOfSPrototype, field);
+ }
+ // The class of [s] is a subclass of the class of [t]. If [s] has no type
+ // arguments and no substitution, it is used as raw type. If [t] has no
+ // type arguments, it used as a raw type. In both cases, [s] is a subtype
+ // of [t].
+ if ((!isJsArray(s) && substitution == null) || !isJsArray(t)) {
+ return true;
+ }
+ // Recursively check the type arguments.
+ return checkArgumentsV2(
+ substitution, getArguments(s), sEnv, getArguments(t), tEnv);
+}
+
+bool isAssignableV1(var s, var t) {
+ return isSubtypeV1(s, t) || isSubtypeV1(t, s);
}
/**
* If [allowShorter] is `true`, [t] is allowed to be shorter than [s].
*/
-bool areAssignable(List s, List t, bool allowShorter) {
+bool areAssignableV1(List s, List t, bool allowShorter) {
// Both lists are empty and thus equal.
if (t == null && s == null) return true;
// [t] is empty (and [s] is not) => only OK if [allowShorter].
@@ -796,14 +926,14 @@
}
for (int i = 0; i < tLength; i++) {
- if (!isAssignable(getIndex(s, i), getIndex(t, i))) {
+ if (!isAssignableV1(getIndex(s, i), getIndex(t, i))) {
return false;
}
}
return true;
}
-bool areAssignableMaps(var s, var t) {
+bool areAssignableMapsV1(var s, var t) {
if (t == null) return true;
if (s == null) return false;
@@ -819,12 +949,20 @@
}
var tType = JS('', '#[#]', t, name);
var sType = JS('', '#[#]', s, name);
- if (!isAssignable(tType, sType)) return false;
+ if (!isAssignableV1(tType, sType)) return false;
}
return true;
}
+/// Top-level function subtype check when [t] is known to be a function type
+/// rti.
bool isFunctionSubtype(var s, var t) {
+ return JS_GET_FLAG('STRONG_MODE')
+ ? isFunctionSubtypeV2(s, null, t, null)
+ : isFunctionSubtypeV1(s, t);
+}
+
+bool isFunctionSubtypeV1(var s, var t) {
assert(isDartFunctionType(t));
if (!isDartFunctionType(s)) return false;
var genericBoundsTag =
@@ -832,19 +970,6 @@
var voidReturnTag = JS_GET_NAME(JsGetName.FUNCTION_TYPE_VOID_RETURN_TAG);
var returnTypeTag = JS_GET_NAME(JsGetName.FUNCTION_TYPE_RETURN_TYPE_TAG);
- // Generic function types must agree on number of type parameters and bounds.
- if (hasField(s, genericBoundsTag)) {
- if (hasNoField(t, genericBoundsTag)) return false;
- var sBounds = getField(s, genericBoundsTag);
- var tBounds = getField(t, genericBoundsTag);
- int sGenericParameters = getLength(sBounds);
- int tGenericParameters = getLength(tBounds);
- if (sGenericParameters != tGenericParameters) return false;
- // TODO(sra): Compare bounds.
- } else if (hasField(t, genericBoundsTag)) {
- return false;
- }
-
if (hasField(s, voidReturnTag)) {
if (hasNoField(t, voidReturnTag) && hasField(t, returnTypeTag)) {
return false;
@@ -852,7 +977,7 @@
} else if (hasNoField(t, voidReturnTag)) {
var sReturnType = getField(s, returnTypeTag);
var tReturnType = getField(t, returnTypeTag);
- if (!isAssignable(sReturnType, tReturnType)) return false;
+ if (!isAssignableV1(sReturnType, tReturnType)) return false;
}
var requiredParametersTag =
JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG);
@@ -883,8 +1008,8 @@
}
if (sParametersLen == tParametersLen) {
// Simple case: Same number of required parameters.
- if (!areAssignable(sParameterTypes, tParameterTypes, false)) return false;
- if (!areAssignable(
+ if (!areAssignableV1(sParameterTypes, tParameterTypes, false)) return false;
+ if (!areAssignableV1(
sOptionalParameterTypes, tOptionalParameterTypes, true)) {
return false;
}
@@ -893,7 +1018,7 @@
int pos = 0;
// Check all required parameters of [s].
for (; pos < sParametersLen; pos++) {
- if (!isAssignable(
+ if (!isAssignableV1(
getIndex(sParameterTypes, pos), getIndex(tParameterTypes, pos))) {
return false;
}
@@ -903,7 +1028,7 @@
// Check the remaining parameters of [t] with the first optional parameters
// of [s].
for (; tPos < tParametersLen; sPos++, tPos++) {
- if (!isAssignable(getIndex(sOptionalParameterTypes, sPos),
+ if (!isAssignableV1(getIndex(sOptionalParameterTypes, sPos),
getIndex(tParameterTypes, tPos))) {
return false;
}
@@ -912,7 +1037,7 @@
// Check the optional parameters of [t] with the remaining optional
// parameters of [s]:
for (; tPos < tOptionalParametersLen; sPos++, tPos++) {
- if (!isAssignable(getIndex(sOptionalParameterTypes, sPos),
+ if (!isAssignableV1(getIndex(sOptionalParameterTypes, sPos),
getIndex(tOptionalParameterTypes, tPos))) {
return false;
}
@@ -923,7 +1048,125 @@
JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAMETERS_TAG);
var sNamedParameters = getField(s, namedParametersTag);
var tNamedParameters = getField(t, namedParametersTag);
- return areAssignableMaps(sNamedParameters, tNamedParameters);
+ return areAssignableMapsV1(sNamedParameters, tNamedParameters);
+}
+
+bool isFunctionSubtypeV2(var s, var sEnv, var t, var tEnv) {
+ assert(isDartFunctionType(t));
+ if (!isDartFunctionType(s)) return false;
+ var genericBoundsTag =
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_GENERIC_BOUNDS_TAG);
+ var voidReturnTag = JS_GET_NAME(JsGetName.FUNCTION_TYPE_VOID_RETURN_TAG);
+ var returnTypeTag = JS_GET_NAME(JsGetName.FUNCTION_TYPE_RETURN_TYPE_TAG);
+
+ // Generic function types must agree on number of type parameters and bounds.
+ if (hasField(s, genericBoundsTag)) {
+ if (hasNoField(t, genericBoundsTag)) return false;
+ var sBounds = getField(s, genericBoundsTag);
+ var tBounds = getField(t, genericBoundsTag);
+ int sGenericParameters = getLength(sBounds);
+ int tGenericParameters = getLength(tBounds);
+ if (sGenericParameters != tGenericParameters) return false;
+ // TODO(sra): Compare bounds, which should be 'equal' trees due to the de
+ // Bruijn numbering of type parameters.
+ // TODO(sra): Extend [sEnv] and [tEnv] with bindings for the [s] and [t]
+ // type parameters to enable checking the bound against non-type-parameter
+ // terms.
+ } else if (hasField(t, genericBoundsTag)) {
+ return false;
+ }
+
+ // 'void' is a top type, so use `null` (dynamic) in its place.
+ // TODO(sra): Create a void type that can be used in all positions.
+ var sReturnType =
+ hasField(s, voidReturnTag) ? null : getField(s, returnTypeTag);
+ var tReturnType =
+ hasField(t, voidReturnTag) ? null : getField(t, returnTypeTag);
+ if (!isSubtypeV2(sReturnType, sEnv, tReturnType, tEnv)) return false;
+
+ var requiredParametersTag =
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG);
+ var sParameterTypes = getField(s, requiredParametersTag);
+ var tParameterTypes = getField(t, requiredParametersTag);
+
+ var optionalParametersTag =
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG);
+ var sOptionalParameterTypes = getField(s, optionalParametersTag);
+ var tOptionalParameterTypes = getField(t, optionalParametersTag);
+
+ int sParametersLen = sParameterTypes != null ? getLength(sParameterTypes) : 0;
+ int tParametersLen = tParameterTypes != null ? getLength(tParameterTypes) : 0;
+
+ int sOptionalParametersLen =
+ sOptionalParameterTypes != null ? getLength(sOptionalParameterTypes) : 0;
+ int tOptionalParametersLen =
+ tOptionalParameterTypes != null ? getLength(tOptionalParameterTypes) : 0;
+
+ if (sParametersLen > tParametersLen) {
+ // Too many required parameters in [s].
+ return false;
+ }
+ if (sParametersLen + sOptionalParametersLen <
+ tParametersLen + tOptionalParametersLen) {
+ // Too few required and optional parameters in [s].
+ return false;
+ }
+
+ int pos = 0;
+ // Check all required parameters of [s].
+ for (; pos < sParametersLen; pos++) {
+ if (!isSubtypeV2(getIndex(tParameterTypes, pos), tEnv,
+ getIndex(sParameterTypes, pos), sEnv)) {
+ return false;
+ }
+ }
+ int sPos = 0;
+ int tPos = pos;
+ // Check the remaining parameters of [t] with the first optional parameters
+ // of [s].
+ for (; tPos < tParametersLen; sPos++, tPos++) {
+ if (!isSubtypeV2(getIndex(tOptionalParameterTypes, tPos), tEnv,
+ getIndex(sParameterTypes, sPos), sEnv)) {
+ return false;
+ }
+ }
+ tPos = 0;
+ // Check the optional parameters of [t] with the remaining optional
+ // parameters of [s]:
+ for (; tPos < tOptionalParametersLen; sPos++, tPos++) {
+ if (!isSubtypeV2(getIndex(tOptionalParameterTypes, tPos), tEnv,
+ getIndex(sOptionalParameterTypes, sPos), sEnv)) {
+ return false;
+ }
+ }
+
+ var namedParametersTag =
+ JS_GET_NAME(JsGetName.FUNCTION_TYPE_NAMED_PARAMETERS_TAG);
+ var sNamedParameters = getField(s, namedParametersTag);
+ var tNamedParameters = getField(t, namedParametersTag);
+ if (tNamedParameters == null) return true;
+ if (sNamedParameters == null) return false;
+ return namedParametersSubtypeCheckV2(
+ sNamedParameters, sEnv, tNamedParameters, tEnv);
+}
+
+bool namedParametersSubtypeCheckV2(var s, var sEnv, var t, var tEnv) {
+ assert(isJsObject(s));
+ assert(isJsObject(t));
+
+ // Each named parameter in [t] must exist in [s] and be a subtype of the type
+ // in [s].
+ List names = JS('JSFixedArray', 'Object.getOwnPropertyNames(#)', t);
+ for (int i = 0; i < names.length; i++) {
+ var name = names[i];
+ if (JS('bool', '!Object.hasOwnProperty.call(#, #)', s, name)) {
+ return false;
+ }
+ var tType = JS('', '#[#]', t, name);
+ var sType = JS('', '#[#]', s, name);
+ if (!isSubtypeV2(tType, tEnv, sType, sEnv)) return false;
+ }
+ return true;
}
/**
diff --git a/tests/co19/co19-dart2js.status b/tests/co19/co19-dart2js.status
index 873634c..10eb24a 100644
--- a/tests/co19/co19-dart2js.status
+++ b/tests/co19/co19-dart2js.status
@@ -6977,6 +6977,9 @@
LibTest/core/Uri/Uri_A06_t03: Slow, Pass # Please triage this failure
LibTest/math/Point/operator_mult_A02_t01: RuntimeError # Issue 1533
+[ $compiler == dart2js && $checked && $fast_startup ]
+Language/Statements/Break/async_loops_t02: RuntimeError
+
[ $compiler == dart2js && !$checked && $enable_asserts ]
Language/Statements/Assert/execution_t01: SkipByDesign # Unspec'd feature.
Language/Statements/Assert/execution_t02: SkipByDesign # Unspec'd feature.
diff --git a/tests/co19/co19-kernel.status b/tests/co19/co19-kernel.status
index e55b34f..d3b5419 100644
--- a/tests/co19/co19-kernel.status
+++ b/tests/co19/co19-kernel.status
@@ -219,6 +219,10 @@
[ $compiler == dartk && $mode == debug ]
LibTest/isolate/Isolate/spawnUri_A01_t04: Pass, Slow, Timeout
+[ $compiler == dartk && $system == windows ]
+Language/Libraries_and_Scripts/top_level_syntax_t06: Pass, Timeout
+Language/Reference/Operator_Precedence/precedence_t03: Pass, Timeout
+
[ $compiler == dartk && $strong ]
*: SkipByDesign
diff --git a/tests/compiler/dart2js/constant_expression_evaluate_test.dart b/tests/compiler/dart2js/constant_expression_evaluate_test.dart
index c485f0b..08a7251 100644
--- a/tests/compiler/dart2js/constant_expression_evaluate_test.dart
+++ b/tests/compiler/dart2js/constant_expression_evaluate_test.dart
@@ -114,6 +114,9 @@
ConstantValue evaluateField(FieldEntity field, ConstantValue evaluate()) {
return _environment.evaluateField(field, evaluate);
}
+
+ @override
+ bool get enableAssertions => true;
}
const List<TestData> DATA = const [
@@ -309,7 +312,7 @@
'y=IntConstant(499),'
'z=IntConstant(99)))'),
]),
- const TestData('errors', '''
+ const TestData('errors', r'''
const integer = const int.fromEnvironment("foo", defaultValue: 5);
const string = const String.fromEnvironment("bar", defaultValue: "baz");
const boolean = const bool.fromEnvironment("baz", defaultValue: false);
@@ -320,6 +323,23 @@
final field;
const Class1() : field = not_string.length;
}
+ class Class2 implements Class3 {
+ const Class2() : assert(false);
+ const Class2.redirect() : this();
+ }
+ class Class3 {
+ const Class3() : assert(false, "Message");
+ const factory Class3.fact() = Class2;
+ }
+ class Class4 extends Class2 {
+ const Class4();
+ }
+ class Class5 {
+ const Class5(a) : assert(a > 0, "$a <= 0");
+ }
+ class Class6 extends Class5 {
+ const Class6(a) : super(a - 1);
+ }
''', const [
const ConstantData(
r'"$integer $string $boolean"', 'StringConstant("5 baz false")'),
@@ -436,11 +456,43 @@
const ConstantData('const Class1()', 'NonConstant',
MessageKind.INVALID_CONSTANT_STRING_LENGTH_TYPE),
const ConstantData('getter', 'NonConstant'),
+ const ConstantData(
+ 'const Class2()', 'NonConstant', MessageKind.INVALID_ASSERT_VALUE),
+ const ConstantData('const Class2.redirect()', 'NonConstant',
+ MessageKind.INVALID_ASSERT_VALUE),
+ const ConstantData('const Class3()', 'NonConstant',
+ MessageKind.INVALID_ASSERT_VALUE_MESSAGE),
+ const ConstantData(
+ 'const Class3.fact()', 'NonConstant', MessageKind.INVALID_ASSERT_VALUE),
+ const ConstantData(
+ 'const Class4()', 'NonConstant', MessageKind.INVALID_ASSERT_VALUE),
+ const ConstantData('const Class5(0)', 'NonConstant',
+ MessageKind.INVALID_ASSERT_VALUE_MESSAGE),
+ const ConstantData('const Class5(1)', 'ConstructedConstant(Class5())'),
+ const ConstantData('const Class6(1)', 'NonConstant',
+ MessageKind.INVALID_ASSERT_VALUE_MESSAGE),
+ const ConstantData('const Class6(2)', 'ConstructedConstant(Class6())'),
+ ]),
+ const TestData('assert', '''
+ class A {
+ const A() : assert(true);
+ }
+ class B {
+ const B() : assert(true, "Message");
+ }
+ ''', const [
+ const ConstantData(r'const A()', 'ConstructedConstant(A())'),
+ const ConstantData(r'const B()', 'ConstructedConstant(B())'),
]),
];
-main() {
- asyncTest(() => Future.forEach(DATA, testData));
+main(List<String> args) {
+ asyncTest(() async {
+ for (TestData data in DATA) {
+ if (args.isNotEmpty && !args.contains(data.name)) continue;
+ await testData(data);
+ }
+ });
}
Future testData(TestData data) async {
@@ -524,6 +576,8 @@
// evaluator which results in different constant expressions for errorneous
// constants.
'errors',
+ // Assert in initializer is not supported by the old frontend.
+ 'assert',
];
const skipKernelList = const [
// TODO(johnniwinther): Investigate why some types of the constructed
diff --git a/tests/compiler/dart2js/constant_expression_test.dart b/tests/compiler/dart2js/constant_expression_test.dart
index 223ba1b..210992a 100644
--- a/tests/compiler/dart2js/constant_expression_test.dart
+++ b/tests/compiler/dart2js/constant_expression_test.dart
@@ -229,7 +229,7 @@
"`${constant.toDartText()}`, expected '${data.type}'.");
}
if (data.fields != null) {
- Map instanceFields = constant.computeInstanceFields(environment);
+ Map instanceFields = constant.computeInstanceData(environment).fieldMap;
Expect.equals(
data.fields.length,
instanceFields.length,
diff --git a/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart b/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart
index dd18bd0..62d2eb1 100644
--- a/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart
+++ b/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart
@@ -190,6 +190,11 @@
ClassEntity cls = env.getClass('C3');
env.elementEnvironment.forEachConstructor(cls,
(ConstructorEntity constructor) {
+ Expect.equals(
+ 0,
+ constructor.parameterStructure.typeParameters,
+ "Type parameters found on constructor $constructor: "
+ "${constructor.parameterStructure}");
List<TypeVariableType> functionTypeVariables =
env.elementEnvironment.getFunctionTypeVariables(constructor);
Expect.isTrue(
diff --git a/tests/compiler/dart2js/helpers/program_lookup.dart b/tests/compiler/dart2js/helpers/program_lookup.dart
index 5b1b8b1..7a92931 100644
--- a/tests/compiler/dart2js/helpers/program_lookup.dart
+++ b/tests/compiler/dart2js/helpers/program_lookup.dart
@@ -2,9 +2,32 @@
// 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';
+import 'package:compiler/src/common_elements.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/elements/entities.dart';
import 'package:compiler/src/js_emitter/model.dart';
+import 'package:compiler/src/js/js.dart' as js;
+
+MemberEntity lookupMember(ElementEnvironment elementEnvironment, String name) {
+ MemberEntity member;
+ int dotIndex = name.indexOf('.');
+ if (dotIndex != -1) {
+ String className = name.substring(0, dotIndex);
+ name = name.substring(dotIndex + 1);
+ ClassEntity cls = elementEnvironment.lookupClass(
+ elementEnvironment.mainLibrary, className);
+ Expect.isNotNull(cls, "No class '$className' found in the main library.");
+ member = elementEnvironment.lookupClassMember(cls, name);
+ member ??= elementEnvironment.lookupConstructor(cls, name);
+ Expect.isNotNull(member, "No member '$name' found in $cls");
+ } else {
+ member = elementEnvironment.lookupLibraryMember(
+ elementEnvironment.mainLibrary, name);
+ Expect.isNotNull(member, "No member '$name' found in the main library.");
+ }
+ return member;
+}
class ProgramLookup {
final Program program;
@@ -50,47 +73,69 @@
class LibraryData {
final Library library;
- Map<ClassEntity, ClassData> _classMap;
- Map<FunctionEntity, StaticMethod> _methodMap;
+ Map<ClassEntity, ClassData> _classMap = <ClassEntity, ClassData>{};
+ Map<FunctionEntity, StaticMethod> _methodMap =
+ <FunctionEntity, StaticMethod>{};
- LibraryData(this.library);
- ClassData getClassData(ClassEntity element) {
- if (_classMap == null) {
- _classMap = <ClassEntity, ClassData>{};
- for (Class cls in library.classes) {
- assert(!_classMap.containsKey(cls.element));
- _classMap[cls.element] = new ClassData(cls);
- }
+ LibraryData(this.library) {
+ for (Class cls in library.classes) {
+ assert(!_classMap.containsKey(cls.element));
+ _classMap[cls.element] = new ClassData(cls);
}
- return _classMap[element];
- }
-
- StaticMethod getMethod(FunctionEntity function) {
- if (_methodMap == null) {
- _methodMap = <FunctionEntity, StaticMethod>{};
- for (StaticMethod method in library.statics) {
+ for (StaticMethod method in library.statics) {
+ ClassEntity enclosingClass = method.element?.enclosingClass;
+ if (enclosingClass != null) {
+ ClassData data =
+ _classMap.putIfAbsent(enclosingClass, () => new ClassData(null));
+ assert(!data._methodMap.containsKey(method.element));
+ data._methodMap[method.element] = method;
+ } else if (method.element != null) {
assert(!_methodMap.containsKey(method.element));
_methodMap[method.element] = method;
}
}
+ }
+
+ ClassData getClassData(ClassEntity element) {
+ return _classMap[element];
+ }
+
+ StaticMethod getMethod(FunctionEntity function) {
return _methodMap[function];
}
}
class ClassData {
final Class cls;
- Map<FunctionEntity, Method> _methodMap;
+ Map<FunctionEntity, Method> _methodMap = <FunctionEntity, Method>{};
- ClassData(this.cls);
-
- Method getMethod(FunctionEntity function) {
- if (_methodMap == null) {
- _methodMap = <FunctionEntity, Method>{};
+ ClassData(this.cls) {
+ if (cls != null) {
for (Method method in cls.methods) {
assert(!_methodMap.containsKey(method.element));
_methodMap[method.element] = method;
}
}
+ }
+
+ Method getMethod(FunctionEntity function) {
return _methodMap[function];
}
}
+
+void forEachCall(js.Node root, void f(js.Call node)) {
+ CallVisitor visitor = new CallVisitor(f);
+ root.accept(visitor);
+}
+
+class CallVisitor extends js.BaseVisitor {
+ final void Function(js.Call) callback;
+
+ CallVisitor(this.callback);
+
+ @override
+ visitCall(js.Call node) {
+ callback(node);
+ super.visitCall(node);
+ }
+}
diff --git a/tests/compiler/dart2js/rti/factory_call_test.dart b/tests/compiler/dart2js/rti/factory_call_test.dart
new file mode 100644
index 0000000..ed72d73
--- /dev/null
+++ b/tests/compiler/dart2js/rti/factory_call_test.dart
@@ -0,0 +1,108 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:async_helper/async_helper.dart';
+import 'package:compiler/src/commandline_options.dart';
+import 'package:compiler/src/common_elements.dart';
+import 'package:compiler/src/compiler.dart';
+import 'package:compiler/src/elements/entities.dart';
+import 'package:compiler/src/js_backend/runtime_types.dart';
+import 'package:compiler/src/js_emitter/model.dart';
+import 'package:compiler/src/js/js.dart' as js;
+import 'package:compiler/src/world.dart';
+import 'package:expect/expect.dart';
+import '../helpers/program_lookup.dart';
+import '../memory_compiler.dart';
+
+const String code = '''
+import 'package:meta/dart2js.dart';
+
+class A<T> {
+ final field;
+
+ @noInline
+ factory A.fact(t) => new A(t);
+
+ @noInline
+ A(t) : field = t is T;
+}
+
+// A call to A.fact.
+@noInline
+callAfact() => new A<int>.fact(0).runtimeType;
+
+main() {
+ callAfact();
+}
+''';
+
+main() {
+ asyncTest(() async {
+ CompilationResult result = await runCompiler(
+ memorySourceFiles: {'main.dart': code},
+ options: [Flags.strongMode, Flags.useKernel]);
+ Expect.isTrue(result.isSuccess);
+ Compiler compiler = result.compiler;
+ ClosedWorld closedWorld = compiler.backendClosedWorldForTesting;
+ RuntimeTypesNeed rtiNeed = closedWorld.rtiNeed;
+ ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
+ ProgramLookup programLookup = new ProgramLookup(compiler);
+
+ js.Name getName(String name) {
+ return compiler.backend.namer
+ .globalPropertyNameForMember(lookupMember(elementEnvironment, name));
+ }
+
+ void checkParameters(String name,
+ {int expectedParameterCount, bool needsTypeArguments}) {
+ FunctionEntity function = lookupMember(elementEnvironment, name);
+
+ Expect.equals(
+ needsTypeArguments,
+ rtiNeed.methodNeedsTypeArguments(function),
+ "Unexpected type argument need for $function.");
+ Method method = programLookup.getMethod(function);
+ Expect.isNotNull(method, "No method found for $function");
+
+ js.Fun fun = method.code;
+ Expect.equals(expectedParameterCount, fun.params.length,
+ "Unexpected parameter count on $function: ${js.nodeToString(fun)}");
+ }
+
+ // The declarations should have type parameters only when needed.
+ checkParameters('A.fact',
+ expectedParameterCount: 2, needsTypeArguments: false);
+ checkParameters('A.', expectedParameterCount: 2, needsTypeArguments: false);
+
+ checkArguments(String name, String targetName,
+ {int expectedTypeArguments}) {
+ FunctionEntity function = lookupMember(elementEnvironment, name);
+ Method method = programLookup.getMethod(function);
+
+ js.Fun fun = method.code;
+
+ js.Name selector = getName(targetName);
+ bool callFound = false;
+ forEachCall(fun, (js.Call node) {
+ js.Expression target = node.target;
+ if (target is js.PropertyAccess && target.selector == selector) {
+ callFound = true;
+ Expect.equals(
+ expectedTypeArguments,
+ node.arguments.length,
+ "Unexpected argument count in $function call to $targetName: "
+ "${js.nodeToString(fun)}");
+ }
+ });
+ Expect.isTrue(
+ callFound,
+ "No call to $targetName in $function found: "
+ "${js.nodeToString(fun)}");
+ }
+
+ // The declarations should have type parameters only when needed by the
+ // selector.
+ checkArguments('callAfact', 'A.fact', expectedTypeArguments: 2);
+ });
+}
diff --git a/tests/compiler/dart2js/rti/instance_call_test.dart b/tests/compiler/dart2js/rti/instance_call_test.dart
index 6c6da99..d27c13e 100644
--- a/tests/compiler/dart2js/rti/instance_call_test.dart
+++ b/tests/compiler/dart2js/rti/instance_call_test.dart
@@ -108,22 +108,6 @@
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
ProgramLookup programLookup = new ProgramLookup(compiler);
- FunctionEntity getFunctionEntity(String name) {
- FunctionEntity function;
- int dotIndex = name.indexOf('.');
- if (dotIndex != -1) {
- String className = name.substring(0, dotIndex);
- name = name.substring(dotIndex + 1);
- ClassEntity cls = elementEnvironment.lookupClass(
- elementEnvironment.mainLibrary, className);
- function = elementEnvironment.lookupClassMember(cls, name);
- } else {
- function = elementEnvironment.lookupLibraryMember(
- elementEnvironment.mainLibrary, name);
- }
- return function;
- }
-
CallStructure callStructure = new CallStructure(1, const <String>[], 1);
js.Name getName(String name) {
@@ -133,7 +117,7 @@
void checkParameters(String name,
{int expectedParameterCount, bool needsTypeArguments}) {
- FunctionEntity function = getFunctionEntity(name);
+ FunctionEntity function = lookupMember(elementEnvironment, name);
Expect.equals(
needsTypeArguments,
@@ -162,7 +146,7 @@
checkArguments(String name, String targetName,
{int expectedTypeArguments}) {
- FunctionEntity function = getFunctionEntity(name);
+ FunctionEntity function = lookupMember(elementEnvironment, name);
Method method = programLookup.getMethod(function);
js.Fun fun = method.code;
@@ -198,20 +182,3 @@
checkArguments('call3b', 'method3', expectedTypeArguments: 2 /*1*/);
});
}
-
-void forEachCall(js.Node root, void f(js.Call node)) {
- CallVisitor visitor = new CallVisitor(f);
- root.accept(visitor);
-}
-
-class CallVisitor extends js.BaseVisitor {
- final void Function(js.Call) callback;
-
- CallVisitor(this.callback);
-
- @override
- visitCall(js.Call node) {
- callback(node);
- super.visitCall(node);
- }
-}
diff --git a/tests/corelib/corelib.status b/tests/corelib/corelib.status
index f1bd513..a4398a5 100644
--- a/tests/corelib/corelib.status
+++ b/tests/corelib/corelib.status
@@ -250,7 +250,6 @@
iterable_return_type_test/01: RuntimeError
iterable_return_type_test/02: RuntimeError
iterable_to_list_test/01: RuntimeError
-map_test: Crash # Issue 27394
nan_infinity_test/01: RuntimeError
string_base_vm_test: RuntimeError
symbol_reserved_word_test/03: RuntimeError
diff --git a/tests/corelib_2/corelib_2.status b/tests/corelib_2/corelib_2.status
index 5047aea..25b3c79 100644
--- a/tests/corelib_2/corelib_2.status
+++ b/tests/corelib_2/corelib_2.status
@@ -208,7 +208,6 @@
[ $compiler == dart2js && $dart2js_with_kernel && $host_checked && $strong ]
apply3_test: CompileTimeError
cast_test: RuntimeError
-collection_length_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
collection_removes_test: RuntimeError
dynamic_nosuchmethod_test: CompileTimeError
error_stack_trace1_test: RuntimeError # Issue 12399
@@ -221,34 +220,25 @@
integer_to_string_test/01: RuntimeError
iterable_empty_test: Crash # 'file:*/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart': Failed assertion: line 391 pos 16: 'receiver.nonCheck() == user.inputs[1].nonCheck()': is not true.
iterable_fold_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
-iterable_generate_test/01: RuntimeError
iterable_reduce_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
-iterable_return_type_test/01: Crash # Assertion failure: Only 2 of 4 arguments have been read from: [HTypeInfoExpression(COMPLETE, int), HTypeInfoExpression(COMPLETE, int), HTypeInfoExpression(COMPLETE, int), HTypeInfoExpression(COMPLETE, int)]
-iterable_return_type_test/02: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-iterable_return_type_test/none: Crash # Assertion failure: Only 2 of 4 arguments have been read from: [HTypeInfoExpression(COMPLETE, int), HTypeInfoExpression(COMPLETE, int), HTypeInfoExpression(COMPLETE, int), HTypeInfoExpression(COMPLETE, int)]
-iterable_to_list_test/01: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-iterable_to_list_test/none: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-iterable_to_set_test: RuntimeError
-json_map_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
+iterable_return_type_test/01: RuntimeError
+iterable_return_type_test/02: RuntimeError
+iterable_to_list_test/01: RuntimeError
list_concurrent_modify_test: RuntimeError
list_insert_all_test: RuntimeError
list_replace_range_test: RuntimeError
list_set_all_test: RuntimeError
list_test/01: RuntimeError
list_test/none: RuntimeError
-list_unmodifiable_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-map_keys2_test: RuntimeError
nan_infinity_test/01: RuntimeError
null_nosuchmethod_test/01: CompileTimeError
null_nosuchmethod_test/none: CompileTimeError
-null_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
queue_test: Crash # 'file:*/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart': Failed assertion: line 391 pos 16: 'receiver.nonCheck() == user.inputs[1].nonCheck()': is not true.
splay_tree_from_iterable_test: RuntimeError
stacktrace_fromstring_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
string_replace_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
string_split_test/checkedstore: RuntimeError
symbol_reserved_word_test/03: RuntimeError
-type_hashcode_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
uri_base_test: RuntimeError
[ $compiler == dart2js && $dart2js_with_kernel && $minified && $strong ]
@@ -267,19 +257,16 @@
integer_to_string_test/01: RuntimeError
iterable_empty_test: RuntimeError
iterable_fold_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
-iterable_generate_test/01: RuntimeError
iterable_reduce_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
iterable_return_type_test/01: RuntimeError
iterable_return_type_test/02: RuntimeError
iterable_to_list_test/01: RuntimeError
-iterable_to_set_test: RuntimeError
list_concurrent_modify_test: RuntimeError
list_insert_all_test: RuntimeError
list_replace_range_test: RuntimeError # Issue 32010
list_set_all_test: RuntimeError # Issue 32010
list_test/01: RuntimeError
list_test/none: RuntimeError
-map_keys2_test: RuntimeError
nan_infinity_test/01: RuntimeError
null_nosuchmethod_test/01: CompileTimeError
null_nosuchmethod_test/none: CompileTimeError
diff --git a/tests/kernel/kernel.status b/tests/kernel/kernel.status
index b74d5fa..d79e280 100644
--- a/tests/kernel/kernel.status
+++ b/tests/kernel/kernel.status
@@ -4,11 +4,14 @@
[ $compiler == dart2js ]
unsorted/invocation_errors_test: Pass
-unsorted/loop_test: Skip
unsorted/nsm_dispatcher_test: Skip # The test uses Symbol without MirrorsUsed
+unsorted/simple_literal_test/01: Skip # The test expects error for large integer literal.
unsorted/super_initializer_test: Skip
unsorted/super_mixin_test: CompileTimeError
+[ !$fasta ]
+unsorted/loop_test: Skip # This test uses optional new/const.
+
[ !$strong ]
unsorted/invocation_errors_test: RuntimeError
@@ -26,8 +29,6 @@
[ $compiler == dart2analyzer && $runtime == none ]
unsorted/invocation_errors_test: StaticWarning
-unsorted/loop_test: CompileTimeError # int64
-unsorted/simple_literal_test: CompileTimeError # int64
unsorted/super_mixin_test: CompileTimeError
[ $compiler == dart2analyzer && $strong ]
@@ -42,7 +43,3 @@
[ $runtime == dart_precompiled && $minified ]
unsorted/symbol_literal_test: Skip # Expects unobfuscated Symbol.toString.
-[ $runtime == dart_precompiled || $runtime == vm || $fasta ]
-unsorted/loop_test: CompileTimeError
-unsorted/simple_literal_test: CompileTimeError
-
diff --git a/tests/kernel/unsorted/loop_test.dart b/tests/kernel/unsorted/loop_test.dart
index b96079d..c9b2617 100644
--- a/tests/kernel/unsorted/loop_test.dart
+++ b/tests/kernel/unsorted/loop_test.dart
@@ -7,9 +7,9 @@
import 'package:expect/expect.dart';
fact(n) {
- var f = 1;
- while (n > 0) {
- f *= n;
+ var f = BigInt.one;
+ while (n > 1) {
+ f *= BigInt.from(n);
--n;
}
return f;
@@ -66,12 +66,12 @@
}
main() {
- Expect.isTrue(fact(0) == 1);
- Expect.isTrue(fact(1) == 1);
- Expect.isTrue(fact(5) == 120);
- Expect
- .isTrue(fact(42) == 1405006117752879898543142606244511569936384000000000);
- Expect.isTrue(fact(3.14159) == 1.0874982674320444);
+ Expect.isTrue(fact(0) == BigInt.one);
+ Expect.isTrue(fact(1) == BigInt.one);
+ Expect.isTrue(fact(5) == BigInt.from(120));
+ Expect.isTrue(fact(42) ==
+ BigInt.parse("1405006117752879898543142606244511569936384000000000"));
+ Expect.isTrue(fact(3.14159) == BigInt.from(6));
Expect.isTrue(fib(0) == 0);
Expect.isTrue(fib(1) == 1);
diff --git a/tests/kernel/unsorted/simple_literal_test.dart b/tests/kernel/unsorted/simple_literal_test.dart
index 9c6d916..c4b8a42 100644
--- a/tests/kernel/unsorted/simple_literal_test.dart
+++ b/tests/kernel/unsorted/simple_literal_test.dart
@@ -30,7 +30,7 @@
}
test6() {
- return 1405006117752879898543142606244511569936384000000000;
+ return 1405006117752879898543142606244511569936384000000000; //# 01: compile-time error
}
main() {
@@ -40,6 +40,6 @@
Expect.isTrue(test3() == 6.022e23);
Expect.isTrue(test4());
Expect.isTrue(test5() == false);
- Expect
- .isTrue(test6() == 1405006117752879898543142606244511569936384000000000);
+ Expect.isTrue(test6() == // //# 01: continued
+ 1405006117752879898543142606244511569936384000000000); //# 01: continued
}
diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status
index f4ca4f4..f757d51 100644
--- a/tests/language/language_dart2js.status
+++ b/tests/language/language_dart2js.status
@@ -7,7 +7,6 @@
# VM specific tests that should not be run by dart2js.
[ $compiler == dart2js ]
-assertion_initializer_test: Crash
local_function_test: RuntimeError # Issue 31879
vm/*: Skip # Issue 12699
@@ -443,10 +442,6 @@
type_variable_bounds3_test/00: Fail # Issue 12702
type_variable_bounds_test/02: Fail # Issue 12702
-[ $compiler == dart2js && !$checked && $dart2js_with_kernel ]
-assertion_initializer_const_error2_test/*: CompileTimeError # Issue #31321
-assertion_initializer_const_error2_test/none: Pass
-
[ $compiler == dart2js && !$checked && !$dart2js_with_kernel ]
assertion_test: RuntimeError
generic_test: RuntimeError, OK
@@ -471,7 +466,6 @@
[ $compiler == dart2js && $dart2js_with_kernel && $fast_startup ]
arithmetic_canonicalization_test: RuntimeError
assertion_initializer_const_error2_test/none: CompileTimeError
-assertion_initializer_test: CompileTimeError
assertion_test: RuntimeError
async_star_cancel_while_paused_test: RuntimeError
bad_override_test/03: MissingCompileTimeError
@@ -772,7 +766,7 @@
type_checks_in_factory_method_test: RuntimeError
[ $compiler == dart2js && $dart2js_with_kernel && $host_checked ]
-assertion_initializer_test: CompileTimeError
+assertion_initializer_const_function_error_test/01: MissingCompileTimeError
assertion_test: RuntimeError
async_star_cancel_while_paused_test: RuntimeError
async_test/setter1: Crash # 'file:*/pkg/compiler/lib/src/kernel/element_map_impl.dart': Failed assertion: line 939 pos 18: 'asyncMarker == AsyncMarker.SYNC': is not true.
@@ -821,7 +815,6 @@
constructor_named_arguments_test/none: RuntimeError
constructor_redirect1_negative_test: Crash # Issue 30856
constructor_redirect2_negative_test: Crash # Issue 30856
-constructor_redirect2_test/01: MissingCompileTimeError
constructor_redirect_test/01: Crash # Assertion failure: Cannot find value Instance of 'ThisLocal' in (local(A.named2#x), local(A.named2#y), local(A.named2#z)) for j:constructor(A.named2).
cyclic_constructor_test/01: Crash # Issue 30856
deferred_constraints_constants_test/none: CompileTimeError
@@ -1080,8 +1073,7 @@
type_variable_conflict2_test/02: MissingCompileTimeError
[ $compiler == dart2js && $dart2js_with_kernel && $minified ]
-assertion_initializer_const_error2_test/none: CompileTimeError
-assertion_initializer_test: CompileTimeError
+assertion_initializer_const_function_error_test/01: MissingCompileTimeError
assertion_test: RuntimeError
async_star_cancel_while_paused_test: RuntimeError
bad_override_test/03: MissingCompileTimeError
@@ -1394,6 +1386,7 @@
assertion_initializer_const_error2_test/none: Pass
assertion_initializer_const_function_error_test/01: Crash
assertion_initializer_const_function_test/01: CompileTimeError
+assertion_initializer_test: Crash
async_star_cancel_while_paused_test: RuntimeError # Issue 22853
bad_constructor_test/05: CompileTimeError # Issue 13639
bad_typedef_test/00: Crash # Issue 28214
@@ -1520,7 +1513,6 @@
assertion_initializer_const_error2_test/none: Pass
assertion_initializer_const_function_error_test/01: Crash
assertion_initializer_const_function_test/01: CompileTimeError
-assertion_initializer_test: Crash
const_evaluation_test/*: Fail # mirrors not supported
deferred_constraints_constants_test: Pass # mirrors not supported, passes for the wrong reason
deferred_constraints_constants_test/none: Fail # mirrors not supported
diff --git a/tests/language_2/language_2_analyzer.status b/tests/language_2/language_2_analyzer.status
index f24119b..086009d 100644
--- a/tests/language_2/language_2_analyzer.status
+++ b/tests/language_2/language_2_analyzer.status
@@ -161,6 +161,7 @@
void_type_usage_test/call_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/call_return: MissingCompileTimeError
+void_type_usage_test/call_void_init: MissingCompileTimeError
void_type_usage_test/conditional2_conditional: MissingCompileTimeError
void_type_usage_test/conditional2_for: MissingCompileTimeError
void_type_usage_test/conditional2_literal_list_init: MissingCompileTimeError
@@ -170,6 +171,7 @@
void_type_usage_test/conditional2_return: MissingCompileTimeError
void_type_usage_test/conditional2_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional2_stmt: MissingCompileTimeError
+void_type_usage_test/conditional2_void_init: MissingCompileTimeError
void_type_usage_test/conditional3_conditional: MissingCompileTimeError
void_type_usage_test/conditional3_for: MissingCompileTimeError
void_type_usage_test/conditional3_literal_list_init: MissingCompileTimeError
@@ -179,6 +181,7 @@
void_type_usage_test/conditional3_return: MissingCompileTimeError
void_type_usage_test/conditional3_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional3_stmt: MissingCompileTimeError
+void_type_usage_test/conditional3_void_init: MissingCompileTimeError
void_type_usage_test/conditional_conditional: MissingCompileTimeError
void_type_usage_test/conditional_for: MissingCompileTimeError
void_type_usage_test/conditional_literal_list_init: MissingCompileTimeError
@@ -188,49 +191,58 @@
void_type_usage_test/conditional_return: MissingCompileTimeError
void_type_usage_test/conditional_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional_stmt: MissingCompileTimeError
+void_type_usage_test/conditional_void_init: MissingCompileTimeError
void_type_usage_test/final_local_conditional: MissingCompileTimeError
void_type_usage_test/final_local_for_in2: MissingCompileTimeError
void_type_usage_test/final_local_literal_list_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/final_local_return: MissingCompileTimeError
+void_type_usage_test/final_local_void_init: MissingCompileTimeError
void_type_usage_test/global_conditional: MissingCompileTimeError
void_type_usage_test/global_literal_list_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/global_return: MissingCompileTimeError
+void_type_usage_test/global_void_init: MissingCompileTimeError
void_type_usage_test/instance2_conditional: MissingCompileTimeError
void_type_usage_test/instance2_for_in2: MissingCompileTimeError
void_type_usage_test/instance2_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance2_return: MissingCompileTimeError
+void_type_usage_test/instance2_void_init: MissingCompileTimeError
void_type_usage_test/instance3_conditional: MissingCompileTimeError
void_type_usage_test/instance3_for_in2: MissingCompileTimeError
void_type_usage_test/instance3_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance3_return: MissingCompileTimeError
+void_type_usage_test/instance3_void_init: MissingCompileTimeError
void_type_usage_test/instance_conditional: MissingCompileTimeError
void_type_usage_test/instance_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance_return: MissingCompileTimeError
+void_type_usage_test/instance_void_init: MissingCompileTimeError
void_type_usage_test/local_conditional: MissingCompileTimeError
void_type_usage_test/local_literal_list_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/local_return: MissingCompileTimeError
+void_type_usage_test/local_void_init: MissingCompileTimeError
void_type_usage_test/param_conditional: MissingCompileTimeError
void_type_usage_test/param_literal_list_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/param_return: MissingCompileTimeError
+void_type_usage_test/param_void_init: MissingCompileTimeError
void_type_usage_test/paren_conditional: MissingCompileTimeError
void_type_usage_test/paren_literal_list_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/paren_return: MissingCompileTimeError
+void_type_usage_test/paren_void_init: MissingCompileTimeError
[ $compiler == dart2analyzer && $runtime == none ]
error_stacktrace_test/00: MissingCompileTimeError
@@ -1213,6 +1225,7 @@
type_promotion_functions_test/10: Pass
vm/lazy_deopt_with_exception_test: CompileTimeError
void_type_callbacks_test/00: MissingCompileTimeError # Issue 30177
+void_type_callbacks_test/01: MissingCompileTimeError # Issue 30177
void_type_function_types_test/none: CompileTimeError # Issue 30177
[ $compiler == dart2analyzer && !$strong ]
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index d7f5dbe..6e4c689 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -34,6 +34,9 @@
assertion_test: RuntimeError
implicit_creation/implicit_new_constructor_generic_test: Pass
+[ $compiler == dart2js && $runtime == d8 && !$dart2js_with_kernel ]
+void_type_function_types_test/none: CompileTimeError # Issue #30515
+
[ $compiler == dart2js && $runtime == drt && $checked && !$dart2js_with_kernel ]
regress_30339_test: RuntimeError # Issue 30393
@@ -569,7 +572,6 @@
issue23244_test: RuntimeError
left_shift_test: RuntimeError
library_env_test/has_mirror_support: RuntimeError
-list_is_test: RuntimeError
list_literal1_test/01: MissingCompileTimeError
list_literal4_test/00: MissingCompileTimeError
list_literal4_test/01: MissingCompileTimeError
@@ -838,7 +840,6 @@
issue31596_super_test/05: RuntimeError
issue31596_tearoff_test: RuntimeError
issue31596_test: RuntimeError
-list_is_test: RuntimeError
nsm5_test: MissingCompileTimeError
override_inheritance_no_such_method_test/05: MissingCompileTimeError
@@ -890,7 +891,6 @@
built_in_identifier_type_annotation_test/68: MissingCompileTimeError # Issue 28815
checked_setter2_test: RuntimeError # Issue 31128
checked_setter_test: RuntimeError # Issue 31128
-closure_param_null_to_object_test: RuntimeError
extract_type_arguments_test: Crash # Issue 31371
generic_test/01: MissingCompileTimeError # front end does not validate `extends`
implicit_downcast_during_constructor_invocation_test: RuntimeError
@@ -1158,7 +1158,6 @@
issue23244_test: RuntimeError
left_shift_test: RuntimeError
library_env_test/has_mirror_support: RuntimeError
-list_is_test: RuntimeError
list_literal1_test/01: MissingCompileTimeError
list_literal4_test/00: MissingCompileTimeError
list_literal4_test/01: MissingCompileTimeError
@@ -1352,7 +1351,11 @@
assertion_initializer_test: CompileTimeError
assertion_test: RuntimeError
async_await_foreign_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_await_syntax_test/a06a: RuntimeError
+async_await_syntax_test/b06a: RuntimeError
+async_await_syntax_test/c06a: RuntimeError
async_await_syntax_test/c10a: MissingCompileTimeError
+async_await_syntax_test/d06a: RuntimeError
async_await_syntax_test/d08b: MissingCompileTimeError
async_await_syntax_test/d10a: MissingCompileTimeError
async_await_test/02: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
@@ -1362,16 +1365,25 @@
async_congruence_method_test/none: RuntimeError
async_congruence_top_level_test: RuntimeError
async_congruence_unnamed_test/none: RuntimeError
+async_error_timing_test: RuntimeError
async_or_generator_return_type_stacktrace_test/01: MissingCompileTimeError
async_or_generator_return_type_stacktrace_test/02: MissingCompileTimeError
async_or_generator_return_type_stacktrace_test/03: MissingCompileTimeError
async_return_types_test/nestedFuture: MissingCompileTimeError
+async_return_types_test/none: RuntimeError
async_return_types_test/tooManyTypeParameters: MissingCompileTimeError
async_return_types_test/wrongReturnType: MissingCompileTimeError
async_star_await_pauses_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_star_cancel_and_throw_in_finally_test: RuntimeError
async_star_cancel_while_paused_test: RuntimeError
+async_star_no_cancel2_test: RuntimeError
+async_star_no_cancel_test: RuntimeError
+async_star_pause_test: RuntimeError
async_star_regression_2238_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_star_regression_23116_test: RuntimeError
+async_star_regression_fisk_test: RuntimeError
async_star_stream_take_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_star_take_reyield_test: RuntimeError
async_star_test/01: Crash # Assertion failure: Unexpected arguments. Expected 1 argument, actual: [invoke dynamic method: selector=Selector(operator, *, arity=1), mask=[subclass=JSUInt32], HTypeInfoReadVariable(ListQueue.E)].
async_star_test/02: Crash # Assertion failure: Unexpected arguments. Expected 1 argument, actual: [invoke dynamic method: selector=Selector(operator, *, arity=1), mask=[subclass=JSUInt32], HTypeInfoReadVariable(ListQueue.E)].
async_star_test/03: Crash # Assertion failure: Unexpected arguments. Expected 1 argument, actual: [invoke dynamic method: selector=Selector(operator, *, arity=1), mask=[subclass=JSUInt32], HTypeInfoReadVariable(ListQueue.E)].
@@ -1379,9 +1391,15 @@
async_star_test/05: Crash # Assertion failure: Unexpected arguments. Expected 1 argument, actual: [invoke dynamic method: selector=Selector(operator, *, arity=1), mask=[subclass=JSUInt32], HTypeInfoReadVariable(ListQueue.E)].
async_star_test/none: Crash # Assertion failure: Unexpected arguments. Expected 1 argument, actual: [invoke dynamic method: selector=Selector(operator, *, arity=1), mask=[subclass=JSUInt32], HTypeInfoReadVariable(ListQueue.E)].
async_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+asyncstar_concat_test: RuntimeError
asyncstar_throw_in_catch_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+asyncstar_yield_test: RuntimeError
+asyncstar_yieldstar_test: RuntimeError
+await_for_cancel_test: RuntimeError
await_for_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+await_for_use_local_test: RuntimeError
await_not_started_immediately_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+await_test: RuntimeError
bad_named_parameters2_test/01: MissingCompileTimeError
bad_named_parameters_test/01: MissingCompileTimeError
bad_named_parameters_test/02: MissingCompileTimeError
@@ -1460,6 +1478,7 @@
const_types_test/39: MissingCompileTimeError
const_types_test/40: MissingCompileTimeError
constants_test/05: MissingCompileTimeError
+constructor12_test: RuntimeError
constructor_named_arguments_test/none: RuntimeError
constructor_redirect1_negative_test/01: Crash # Stack Overflow
constructor_redirect2_negative_test: Crash # Issue 30856
@@ -1469,6 +1488,7 @@
covariance_type_parameter_test/02: RuntimeError
covariance_type_parameter_test/03: RuntimeError
covariant_override/runtime_check_test: RuntimeError
+covariant_override/tear_off_type_test: RuntimeError
covariant_subtyping_tearoff1_test: RuntimeError
covariant_subtyping_tearoff2_test: RuntimeError
covariant_subtyping_tearoff3_test: RuntimeError
@@ -1501,9 +1521,7 @@
duplicate_export_negative_test: Fail
duplicate_implements_test/01: MissingCompileTimeError
duplicate_implements_test/02: MissingCompileTimeError
-dynamic_invoke_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
dynamic_prefix_core_test/none: CompileTimeError
-dynamic_test: RuntimeError
emit_const_fields_test: CompileTimeError
enum_mirror_test: CompileTimeError
example_constructor_test: RuntimeError
@@ -1514,9 +1532,6 @@
external_test/21: CompileTimeError
external_test/24: CompileTimeError
extract_type_arguments_test: RuntimeError
-f_bounded_equality_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-f_bounded_quantification4_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-f_bounded_quantification5_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
f_bounded_quantification_test/01: MissingCompileTimeError
f_bounded_quantification_test/02: MissingCompileTimeError
factory2_test/03: MissingCompileTimeError
@@ -1536,11 +1551,6 @@
field_override4_test/02: MissingCompileTimeError
field_override_test/00: MissingCompileTimeError
field_override_test/01: MissingCompileTimeError
-first_class_types_libraries_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-first_class_types_literals_test/01: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-first_class_types_literals_test/02: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-first_class_types_literals_test/none: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-first_class_types_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
flatten_test/05: MissingRuntimeError
flatten_test/08: MissingRuntimeError
flatten_test/09: MissingRuntimeError
@@ -1549,7 +1559,8 @@
full_stacktrace2_test: RuntimeError
full_stacktrace3_test: RuntimeError
function_propagation_test: CompileTimeError
-function_subtype_bound_closure1_test: RuntimeError
+function_subtype2_test: RuntimeError
+function_subtype3_test: RuntimeError
function_subtype_bound_closure2_test: RuntimeError
function_subtype_bound_closure3_test: RuntimeError
function_subtype_bound_closure4_test: RuntimeError
@@ -1559,52 +1570,43 @@
function_subtype_bound_closure7_test: Crash # Assertion failure: kind=special,memberName=instantiate,callStructure:CallStructure(arity=0, types=1)
function_subtype_call1_test: RuntimeError
function_subtype_call2_test: RuntimeError
+function_subtype_cast0_test: RuntimeError
function_subtype_cast1_test: RuntimeError
-function_subtype_cast2_test: RuntimeError
-function_subtype_cast3_test: RuntimeError
function_subtype_checked0_test: RuntimeError
function_subtype_closure0_test: RuntimeError
function_subtype_closure1_test: RuntimeError
function_subtype_factory1_test: RuntimeError
function_subtype_inline1_test: RuntimeError
function_subtype_inline2_test: RuntimeError
-function_subtype_local1_test: RuntimeError
function_subtype_local2_test: RuntimeError
function_subtype_local5_test: RuntimeError
-function_subtype_named1_test: RuntimeError
-function_subtype_named2_test: RuntimeError
-function_subtype_not0_test: RuntimeError
function_subtype_not1_test: RuntimeError
-function_subtype_not2_test: RuntimeError
-function_subtype_not3_test: RuntimeError
function_subtype_optional1_test: RuntimeError
function_subtype_optional2_test: RuntimeError
function_subtype_regression_ddc_588_test: RuntimeError
function_subtype_setter0_test: RuntimeError
-function_subtype_top_level1_test: RuntimeError
-function_subtype_typearg2_test: RuntimeError
-function_subtype_typearg3_test: RuntimeError
+function_subtype_simple2_test: RuntimeError
function_subtype_typearg5_test: RuntimeError
function_type2_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(B.T) in (local(B.#)) for j:signature(B_closure.$signature).
-function_type_alias10_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
function_type_alias2_test: RuntimeError
-function_type_alias3_test: RuntimeError
function_type_alias4_test: RuntimeError
function_type_alias_test: RuntimeError
function_type_call_getter2_test/none: RuntimeError
function_type_test: RuntimeError
-fuzzy_arrows_test/03: RuntimeError
-generic_closure_test/01: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
+generic_async_star_test: RuntimeError
+generic_closure_test/01: RuntimeError
generic_closure_test/none: RuntimeError
-generic_creation_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
generic_field_mixin6_test/none: RuntimeError
generic_function_bounds_test: Crash # Unsupported operation: Unsupported type parameter type node U.
generic_function_dcall_test: Crash # Unsupported operation: Unsupported type parameter type node T.
generic_function_type_as_type_argument_test/01: MissingCompileTimeError
generic_function_type_as_type_argument_test/02: MissingCompileTimeError
generic_function_type_as_type_argument_test/03: RuntimeError
+generic_function_type_within_type_argument_test: RuntimeError
generic_function_typedef_test/01: RuntimeError
+generic_instanceof2_test: RuntimeError
generic_instanceof_test: RuntimeError
+generic_is_check_test: RuntimeError
generic_method_types_test/02: RuntimeError
generic_method_types_test/03: RuntimeError
generic_methods_bounds_test/01: MissingCompileTimeError
@@ -1612,10 +1614,7 @@
generic_methods_dynamic_test/02: MissingRuntimeError
generic_methods_dynamic_test/04: MissingRuntimeError
generic_methods_generic_class_tearoff_test: RuntimeError
-generic_methods_generic_function_result_test/01: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-generic_methods_generic_function_result_test/none: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-generic_methods_named_parameters_test: RuntimeError
-generic_methods_optional_parameters_test: RuntimeError
+generic_methods_generic_function_result_test/01: MissingCompileTimeError
generic_methods_overriding_test/01: MissingCompileTimeError
generic_methods_recursive_bound_test/02: MissingCompileTimeError
generic_methods_recursive_bound_test/03: Crash # 'file:*/pkg/compiler/lib/src/js_emitter/metadata_collector.dart': Failed assertion: line 100 pos 12: 'isBound': is not true.
@@ -1651,7 +1650,6 @@
initializing_formal_type_annotation_test/01: MissingCompileTimeError
initializing_formal_type_annotation_test/02: MissingCompileTimeError
instance_creation_in_function_annotation_test: CompileTimeError
-instanceof2_test: RuntimeError
instantiate_tearoff_after_contravariance_check_test: Crash # Assertion failure: kind=special,memberName=instantiate,callStructure:CallStructure(arity=0, types=1)
instantiate_tearoff_of_call_test: CompileTimeError
instantiate_tearoff_test: Crash # Assertion failure: kind=special,memberName=instantiate,callStructure:CallStructure(arity=0, types=1)
@@ -1681,18 +1679,21 @@
issue31596_super_test/03: CompileTimeError
issue_25671a_test/01: CompileTimeError
issue_25671b_test/01: CompileTimeError
+known_identifier_usage_error_test/none: RuntimeError
left_shift_test: RuntimeError
library_env_test/has_mirror_support: RuntimeError
library_env_test/has_no_html_support: RuntimeError
library_env_test/has_no_io_support: RuntimeError
library_prefixes_test: CompileTimeError
-list_is_test: RuntimeError
local_function2_test/none: RuntimeError
local_function3_test/none: RuntimeError
local_function_test/01: MissingCompileTimeError
local_function_test/02: MissingCompileTimeError
local_function_test/none: RuntimeError
main_test/03: RuntimeError
+main_test/20: RuntimeError
+main_test/22: RuntimeError
+main_test/44: RuntimeError
malbounded_instantiation_test/01: MissingCompileTimeError
malbounded_instantiation_test/02: MissingCompileTimeError
malbounded_instantiation_test/03: MissingCompileTimeError
@@ -1704,20 +1705,17 @@
malbounded_type_cast_test/00: MissingCompileTimeError
malbounded_type_cast_test/01: MissingCompileTimeError
malbounded_type_cast_test/02: MissingCompileTimeError
-malbounded_type_cast_test/none: RuntimeError
malbounded_type_literal_test/00: MissingCompileTimeError
malbounded_type_test2_test/00: MissingCompileTimeError
malbounded_type_test_test/00: MissingCompileTimeError
malbounded_type_test_test/01: MissingCompileTimeError
malbounded_type_test_test/02: MissingCompileTimeError
-malbounded_type_test_test/none: RuntimeError
many_generic_instanceof_test: RuntimeError
many_overridden_no_such_method_test: CompileTimeError
map_literal11_test/none: MissingRuntimeError
map_literal3_test/01: MissingCompileTimeError
map_literal3_test/02: MissingCompileTimeError
map_literal3_test/03: MissingCompileTimeError
-map_literal7_test: RuntimeError
method_override7_test/00: MissingCompileTimeError
method_override7_test/01: MissingCompileTimeError
method_override7_test/02: MissingCompileTimeError
@@ -1790,7 +1788,6 @@
mixin_invalid_bound_test/09: MissingCompileTimeError
mixin_invalid_bound_test/10: MissingCompileTimeError
mixin_of_mixin_test/none: CompileTimeError
-mixin_regress_13688_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
mixin_super_2_test/none: CompileTimeError
mixin_super_bound_test/01: MissingCompileTimeError
mixin_super_bound_test/02: MissingCompileTimeError
@@ -1826,10 +1823,6 @@
mixin_type_parameters_errors_test/03: MissingCompileTimeError
mixin_type_parameters_errors_test/04: MissingCompileTimeError
mixin_type_parameters_errors_test/05: MissingCompileTimeError
-mixin_type_parameters_mixin_extends_test: RuntimeError
-mixin_type_parameters_mixin_test: RuntimeError
-mixin_type_parameters_super_extends_test: RuntimeError
-mixin_type_parameters_super_test: RuntimeError
modulo_test: RuntimeError
multiline_newline_test/04: MissingCompileTimeError
multiline_newline_test/04r: MissingCompileTimeError
@@ -1839,19 +1832,19 @@
multiline_newline_test/06r: MissingCompileTimeError
named_constructor_test/01: MissingCompileTimeError
named_parameters_default_eq_test/02: MissingCompileTimeError
+named_parameters_default_eq_test/none: RuntimeError
named_parameters_test/02: MissingCompileTimeError
named_parameters_test/04: MissingCompileTimeError
named_parameters_test/06: MissingCompileTimeError
named_parameters_test/08: MissingCompileTimeError
named_parameters_test/10: MissingCompileTimeError
nan_identical_test: RuntimeError
-nested_generic_closure_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
+nested_generic_closure_test: RuntimeError
no_main_test/01: CompileTimeError
no_such_method_mock_test: RuntimeError
no_such_method_test: CompileTimeError
nosuchmethod_forwarding/nosuchmethod_forwarding_test/05: RuntimeError
nosuchmethod_forwarding/nosuchmethod_forwarding_test/06: RuntimeError
-null2_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
null_no_such_method_test: CompileTimeError
null_test/mirrors: CompileTimeError
null_test/none: CompileTimeError
@@ -1924,7 +1917,6 @@
override_method_with_field_test/01: MissingCompileTimeError
parser_quirks_test: CompileTimeError
prefix5_negative_test: Crash # 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart': Failed assertion: line 441 pos 16: 'identical(combiner.arguments.positional[0], rhs)': is not true.
-recursive_generic_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
redirecting_factory_default_values_test/01: MissingCompileTimeError
redirecting_factory_default_values_test/02: MissingCompileTimeError
redirecting_factory_default_values_test/03: MissingCompileTimeError
@@ -1937,7 +1929,9 @@
regress_18535_test: CompileTimeError
regress_23089_test: Crash # Stack Overflow
regress_23408_test: CompileTimeError
+regress_23996_test: RuntimeError
regress_24283_test: RuntimeError
+regress_24935_test/none: RuntimeError
regress_25550_test: CompileTimeError
regress_26175_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
regress_27617_test/1: Crash # Assertion failure: Unexpected constructor j:constructor(Foo._) in ConstructorDataImpl._getConstructorConstant
@@ -1949,9 +1943,7 @@
regress_30339_test: CompileTimeError
regress_31591_test: RuntimeError
regress_32012_test: Crash # Unsupported operation: Unsupported type parameter type node B.
-reify_typevar_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-runtime_type_function_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
-runtime_type_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
+runtime_type_function_test: RuntimeError
setter4_test: MissingCompileTimeError
setter_no_getter_call_test/01: CompileTimeError
setter_no_getter_test/01: CompileTimeError
@@ -1959,6 +1951,7 @@
setter_override_test/01: MissingCompileTimeError
setter_override_test/02: MissingCompileTimeError
setter_override_test/03: MissingCompileTimeError
+shadow_parameter_and_local_test: RuntimeError
stacktrace_demangle_ctors_test: RuntimeError # Issue 12698
stacktrace_rethrow_error_test/none: RuntimeError
stacktrace_rethrow_error_test/withtraceparameter: RuntimeError
@@ -2044,10 +2037,11 @@
type_variable_bounds_test/06: MissingCompileTimeError
type_variable_bounds_test/08: MissingCompileTimeError
type_variable_bounds_test/11: MissingCompileTimeError
-type_variable_nested_test/01: RuntimeError
-type_variable_promotion_test: Crash # Assertion failure: Only 2 of 3 arguments have been read from: [HRef(HForeignCode("# ? Object.keys(#) : []")), literal: NullConstant, literal: NullConstant]
+type_variable_promotion_test: RuntimeError
+typedef_is_test: RuntimeError
typevariable_substitution2_test/02: RuntimeError
vm/async_await_catch_stacktrace_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+vm/await_synchronous_future_test: Crash # Interpolated value #1 is not an Expression or List of Expressions: [VariableUse(f), Instance of 'LiteralNull', null]
vm/causal_async_exception_stack2_test: Crash # Assertion failure: Unexpected arguments. Expected 1 argument, actual: [invoke dynamic method: selector=Selector(operator, *, arity=1), mask=[subclass=JSUInt32], HTypeInfoReadVariable(ListQueue.E)].
vm/causal_async_exception_stack_test: Crash # Assertion failure: Unexpected arguments. Expected 1 argument, actual: [invoke dynamic method: selector=Selector(operator, *, arity=1), mask=[subclass=JSUInt32], HTypeInfoReadVariable(ListQueue.E)].
vm/debug_break_enabled_vm_test/01: CompileTimeError
@@ -2068,9 +2062,6 @@
vm/store_to_load_forwarding_phis_vm_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
vm/type_cast_vm_test: RuntimeError
vm/type_vm_test/28: MissingRuntimeError
-vm/type_vm_test/30: MissingRuntimeError
-vm/type_vm_test/31: MissingRuntimeError
-vm/type_vm_test/32: MissingRuntimeError
vm/uint32_right_shift_test: RuntimeError
vm/uint32_shift_test: RuntimeError
vm/unaligned_integer_access_literal_index_test: RuntimeError
@@ -2081,8 +2072,8 @@
void_type_usage_test/conditional2_dynamic_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional2_for: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional2_literal_list_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
-void_type_usage_test/conditional2_literal_map_value_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional2_literal_map_value_init2: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
+void_type_usage_test/conditional2_literal_map_value_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional2_null_equals2: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional2_parens: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional2_return: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
@@ -2098,8 +2089,8 @@
void_type_usage_test/conditional3_dynamic_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional3_for: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional3_literal_list_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
-void_type_usage_test/conditional3_literal_map_value_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional3_literal_map_value_init2: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
+void_type_usage_test/conditional3_literal_map_value_init: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional3_null_equals2: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional3_parens: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
void_type_usage_test/conditional3_return: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
@@ -2117,6 +2108,7 @@
void_type_usage_test/paren_null_equals2: Crash # 'package:front_end/src/fasta/type_inference/type_schema_environment.dart': Failed assertion: line 214 pos 12: 'false': is not true.
wrong_number_type_arguments_test/01: MissingCompileTimeError
wrong_number_type_arguments_test/none: Pass
+yieldstar_pause_test: RuntimeError
[ $compiler == dart2js && $dart2js_with_kernel && $minified && $strong ]
abstract_factory_constructor_test/00: MissingCompileTimeError
@@ -2134,7 +2126,11 @@
assertion_initializer_test: CompileTimeError
assertion_test: RuntimeError
async_await_foreign_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_await_syntax_test/a06a: RuntimeError
+async_await_syntax_test/b06a: RuntimeError
+async_await_syntax_test/c06a: RuntimeError
async_await_syntax_test/c10a: MissingCompileTimeError
+async_await_syntax_test/d06a: RuntimeError
async_await_syntax_test/d08b: MissingCompileTimeError
async_await_syntax_test/d10a: MissingCompileTimeError
async_await_test/02: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
@@ -2144,17 +2140,25 @@
async_congruence_method_test/none: RuntimeError
async_congruence_top_level_test: RuntimeError
async_congruence_unnamed_test/none: RuntimeError
-async_error_timing_test: Pass
+async_error_timing_test: RuntimeError
async_or_generator_return_type_stacktrace_test/01: MissingCompileTimeError
async_or_generator_return_type_stacktrace_test/02: MissingCompileTimeError
async_or_generator_return_type_stacktrace_test/03: MissingCompileTimeError
async_return_types_test/nestedFuture: MissingCompileTimeError
+async_return_types_test/none: RuntimeError
async_return_types_test/tooManyTypeParameters: MissingCompileTimeError
async_return_types_test/wrongReturnType: MissingCompileTimeError
async_star_await_pauses_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_star_cancel_and_throw_in_finally_test: RuntimeError
async_star_cancel_while_paused_test: RuntimeError
+async_star_no_cancel2_test: RuntimeError
+async_star_no_cancel_test: RuntimeError
+async_star_pause_test: RuntimeError
async_star_regression_2238_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_star_regression_23116_test: RuntimeError
+async_star_regression_fisk_test: RuntimeError
async_star_stream_take_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+async_star_take_reyield_test: RuntimeError
async_star_test/01: Crash # Wrong number of template arguments, given 2, expected 1
async_star_test/02: Crash # Wrong number of template arguments, given 2, expected 1
async_star_test/03: Crash # Wrong number of template arguments, given 2, expected 1
@@ -2162,9 +2166,15 @@
async_star_test/05: Crash # Wrong number of template arguments, given 2, expected 1
async_star_test/none: Crash # Wrong number of template arguments, given 2, expected 1
async_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+asyncstar_concat_test: RuntimeError
asyncstar_throw_in_catch_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+asyncstar_yield_test: RuntimeError
+asyncstar_yieldstar_test: RuntimeError
+await_for_cancel_test: RuntimeError
await_for_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+await_for_use_local_test: RuntimeError
await_not_started_immediately_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+await_test: RuntimeError
bad_named_parameters2_test/01: MissingCompileTimeError
bad_named_parameters_test/01: MissingCompileTimeError
bad_named_parameters_test/02: MissingCompileTimeError
@@ -2241,6 +2251,7 @@
const_types_test/39: MissingCompileTimeError
const_types_test/40: MissingCompileTimeError
constants_test/05: MissingCompileTimeError
+constructor12_test: RuntimeError
constructor_named_arguments_test/none: RuntimeError
constructor_redirect1_negative_test/01: Crash # Stack Overflow
constructor_redirect2_negative_test: Crash # Issue 30856
@@ -2250,6 +2261,7 @@
covariance_type_parameter_test/02: RuntimeError
covariance_type_parameter_test/03: RuntimeError
covariant_override/runtime_check_test: RuntimeError
+covariant_override/tear_off_type_test: RuntimeError
covariant_subtyping_tearoff1_test: RuntimeError
covariant_subtyping_tearoff2_test: RuntimeError
covariant_subtyping_tearoff3_test: RuntimeError
@@ -2283,7 +2295,6 @@
duplicate_implements_test/01: MissingCompileTimeError
duplicate_implements_test/02: MissingCompileTimeError
dynamic_prefix_core_test/none: CompileTimeError
-dynamic_test: RuntimeError
emit_const_fields_test: CompileTimeError
enum_mirror_test: CompileTimeError
example_constructor_test: RuntimeError
@@ -2322,7 +2333,8 @@
full_stacktrace2_test: RuntimeError # Issue 12698
full_stacktrace3_test: RuntimeError # Issue 12698
function_propagation_test: CompileTimeError
-function_subtype_bound_closure1_test: RuntimeError
+function_subtype2_test: RuntimeError
+function_subtype3_test: RuntimeError
function_subtype_bound_closure2_test: RuntimeError
function_subtype_bound_closure3_test: RuntimeError
function_subtype_bound_closure4_test: RuntimeError
@@ -2332,48 +2344,41 @@
function_subtype_bound_closure7_test: RuntimeError
function_subtype_call1_test: RuntimeError
function_subtype_call2_test: RuntimeError
+function_subtype_cast0_test: RuntimeError
function_subtype_cast1_test: RuntimeError
-function_subtype_cast2_test: RuntimeError
-function_subtype_cast3_test: RuntimeError
function_subtype_checked0_test: RuntimeError
function_subtype_closure0_test: RuntimeError
function_subtype_closure1_test: RuntimeError
function_subtype_factory1_test: RuntimeError
function_subtype_inline1_test: RuntimeError
function_subtype_inline2_test: RuntimeError
-function_subtype_local1_test: RuntimeError
function_subtype_local2_test: RuntimeError
function_subtype_local5_test: RuntimeError
-function_subtype_named1_test: RuntimeError
-function_subtype_named2_test: RuntimeError
-function_subtype_not0_test: RuntimeError
function_subtype_not1_test: RuntimeError
-function_subtype_not2_test: RuntimeError
-function_subtype_not3_test: RuntimeError
function_subtype_optional1_test: RuntimeError
function_subtype_optional2_test: RuntimeError
function_subtype_regression_ddc_588_test: RuntimeError
function_subtype_setter0_test: RuntimeError
-function_subtype_top_level1_test: RuntimeError
-function_subtype_typearg2_test: RuntimeError
-function_subtype_typearg3_test: RuntimeError
+function_subtype_simple2_test: RuntimeError
function_subtype_typearg5_test: RuntimeError
function_type2_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(B.T) in (local(B.#)) for j:signature(B_closure.$signature).
function_type_alias2_test: RuntimeError
-function_type_alias3_test: RuntimeError
function_type_alias4_test: RuntimeError
function_type_alias_test: RuntimeError
function_type_call_getter2_test/none: RuntimeError
function_type_test: RuntimeError
-fuzzy_arrows_test/03: RuntimeError
+generic_async_star_test: RuntimeError
generic_field_mixin6_test/none: RuntimeError
generic_function_bounds_test: Crash # Unsupported operation: Unsupported type parameter type node U.
generic_function_dcall_test: RuntimeError
generic_function_type_as_type_argument_test/01: MissingCompileTimeError
generic_function_type_as_type_argument_test/02: MissingCompileTimeError
generic_function_type_as_type_argument_test/03: RuntimeError
+generic_function_type_within_type_argument_test: RuntimeError
generic_function_typedef_test/01: RuntimeError
+generic_instanceof2_test: RuntimeError
generic_instanceof_test: RuntimeError
+generic_is_check_test: RuntimeError
generic_method_types_test/02: RuntimeError
generic_method_types_test/03: RuntimeError
generic_methods_bounds_test/01: MissingCompileTimeError
@@ -2382,8 +2387,6 @@
generic_methods_dynamic_test/04: MissingRuntimeError
generic_methods_generic_class_tearoff_test: RuntimeError
generic_methods_generic_function_result_test/01: MissingCompileTimeError
-generic_methods_named_parameters_test: RuntimeError
-generic_methods_optional_parameters_test: RuntimeError
generic_methods_overriding_test/01: MissingCompileTimeError
generic_methods_recursive_bound_test/02: MissingCompileTimeError
generic_methods_recursive_bound_test/03: Crash # NoSuchMethodError: The method 'markSeen' was called on null.
@@ -2418,7 +2421,6 @@
initializing_formal_type_annotation_test/01: MissingCompileTimeError
initializing_formal_type_annotation_test/02: MissingCompileTimeError
instance_creation_in_function_annotation_test: CompileTimeError
-instanceof2_test: RuntimeError
instantiate_tearoff_of_call_test: CompileTimeError
instantiate_type_variable_test/01: CompileTimeError
int64_literal_test/01: RuntimeError
@@ -2446,18 +2448,21 @@
issue31596_super_test/03: CompileTimeError
issue_25671a_test/01: CompileTimeError
issue_25671b_test/01: CompileTimeError
+known_identifier_usage_error_test/none: RuntimeError
left_shift_test: RuntimeError
library_env_test/has_mirror_support: RuntimeError
library_env_test/has_no_html_support: RuntimeError
library_env_test/has_no_io_support: RuntimeError
library_prefixes_test: CompileTimeError
-list_is_test: RuntimeError
local_function2_test/none: RuntimeError
local_function3_test/none: RuntimeError
local_function_test/01: MissingCompileTimeError
local_function_test/02: MissingCompileTimeError
local_function_test/none: RuntimeError
main_test/03: RuntimeError
+main_test/20: RuntimeError
+main_test/22: RuntimeError
+main_test/44: RuntimeError
malbounded_instantiation_test/01: MissingCompileTimeError
malbounded_instantiation_test/02: MissingCompileTimeError
malbounded_instantiation_test/03: MissingCompileTimeError
@@ -2469,20 +2474,17 @@
malbounded_type_cast_test/00: MissingCompileTimeError
malbounded_type_cast_test/01: MissingCompileTimeError
malbounded_type_cast_test/02: MissingCompileTimeError
-malbounded_type_cast_test/none: RuntimeError
malbounded_type_literal_test/00: MissingCompileTimeError
malbounded_type_test2_test/00: MissingCompileTimeError
malbounded_type_test_test/00: MissingCompileTimeError
malbounded_type_test_test/01: MissingCompileTimeError
malbounded_type_test_test/02: MissingCompileTimeError
-malbounded_type_test_test/none: RuntimeError
many_generic_instanceof_test: RuntimeError
many_overridden_no_such_method_test: CompileTimeError
map_literal11_test/none: MissingRuntimeError
map_literal3_test/01: MissingCompileTimeError
map_literal3_test/02: MissingCompileTimeError
map_literal3_test/03: MissingCompileTimeError
-map_literal7_test: RuntimeError
method_override7_test/00: MissingCompileTimeError
method_override7_test/01: MissingCompileTimeError
method_override7_test/02: MissingCompileTimeError
@@ -2555,6 +2557,7 @@
mixin_invalid_bound_test/08: MissingCompileTimeError
mixin_invalid_bound_test/09: MissingCompileTimeError
mixin_invalid_bound_test/10: MissingCompileTimeError
+mixin_mixin_type_arguments_test: RuntimeError
mixin_of_mixin_test/none: CompileTimeError
mixin_super_2_test/none: CompileTimeError
mixin_super_bound_test/01: MissingCompileTimeError
@@ -2591,10 +2594,6 @@
mixin_type_parameters_errors_test/03: MissingCompileTimeError
mixin_type_parameters_errors_test/04: MissingCompileTimeError
mixin_type_parameters_errors_test/05: MissingCompileTimeError
-mixin_type_parameters_mixin_extends_test: RuntimeError
-mixin_type_parameters_mixin_test: RuntimeError
-mixin_type_parameters_super_extends_test: RuntimeError
-mixin_type_parameters_super_test: RuntimeError
mock_writable_final_field_test: RuntimeError # Issue 30847
mock_writable_final_private_field_test: RuntimeError # Issue 30847
modulo_test: RuntimeError
@@ -2606,6 +2605,7 @@
multiline_newline_test/06r: MissingCompileTimeError
named_constructor_test/01: MissingCompileTimeError
named_parameters_default_eq_test/02: MissingCompileTimeError
+named_parameters_default_eq_test/none: RuntimeError
named_parameters_test/02: MissingCompileTimeError
named_parameters_test/04: MissingCompileTimeError
named_parameters_test/06: MissingCompileTimeError
@@ -2702,7 +2702,9 @@
regress_21795_test: RuntimeError
regress_23089_test: Crash # Stack Overflow
regress_23408_test: CompileTimeError
+regress_23996_test: RuntimeError
regress_24283_test: RuntimeError, OK # Requires 64 bit numbers.
+regress_24935_test/none: RuntimeError
regress_25550_test: CompileTimeError
regress_26175_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
regress_27617_test/1: Crash # Assertion failure: Unexpected constructor j:constructor(Foo._) in ConstructorDataImpl._getConstructorConstant
@@ -2722,6 +2724,7 @@
setter_override_test/01: MissingCompileTimeError
setter_override_test/02: MissingCompileTimeError
setter_override_test/03: MissingCompileTimeError
+shadow_parameter_and_local_test: RuntimeError
stack_trace_test: RuntimeError
stacktrace_demangle_ctors_test: RuntimeError # Issue 12698
stacktrace_rethrow_error_test/none: RuntimeError # Issue 12698
@@ -2785,10 +2788,11 @@
type_variable_bounds_test/06: MissingCompileTimeError
type_variable_bounds_test/08: MissingCompileTimeError
type_variable_bounds_test/11: MissingCompileTimeError
-type_variable_nested_test/01: RuntimeError
type_variable_promotion_test: RuntimeError
+typedef_is_test: RuntimeError
typevariable_substitution2_test/02: RuntimeError
vm/async_await_catch_stacktrace_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
+vm/await_synchronous_future_test: Crash # Interpolated value #1 is not an Expression or List of Expressions: [VariableUse(f), Instance of 'LiteralNull', null]
vm/causal_async_exception_stack2_test: Crash # Wrong number of template arguments, given 2, expected 1
vm/causal_async_exception_stack_test: Crash # Wrong number of template arguments, given 2, expected 1
vm/debug_break_enabled_vm_test/01: CompileTimeError
@@ -2809,9 +2813,6 @@
vm/store_to_load_forwarding_phis_vm_test: Crash # Assertion failure: Runtime type information not available for type_variable_local(bindCallback.R) in (local(_RootZone.bindCallback#)) for j:closure_call(_RootZone_bindCallback_closure.call).
vm/type_cast_vm_test: RuntimeError
vm/type_vm_test/28: MissingRuntimeError
-vm/type_vm_test/30: MissingRuntimeError
-vm/type_vm_test/31: MissingRuntimeError
-vm/type_vm_test/32: MissingRuntimeError
vm/uint32_right_shift_test: RuntimeError
vm/uint32_shift_test: RuntimeError
vm/unaligned_integer_access_literal_index_test: RuntimeError
@@ -2822,6 +2823,7 @@
void_type_usage_test/conditional_return_to_void: MissingCompileTimeError
wrong_number_type_arguments_test/01: MissingCompileTimeError
wrong_number_type_arguments_test/none: Pass
+yieldstar_pause_test: RuntimeError
[ $compiler == dart2js && $dart2js_with_kernel && !$strong ]
*: SkipByDesign
diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status
index e3eb89a..bd10851 100644
--- a/tests/language_2/language_2_dartdevc.status
+++ b/tests/language_2/language_2_dartdevc.status
@@ -136,6 +136,7 @@
type_promotion_functions_test/none: CompileTimeError # Issue 30895
type_variable_scope_test/none: CompileTimeError
void_type_callbacks_test/00: MissingCompileTimeError # Issue 30514
+void_type_callbacks_test/01: MissingCompileTimeError
void_type_function_types_test/none: CompileTimeError # Issue 30514
void_type_override_test/00: MissingCompileTimeError
void_type_override_test/00b: MissingCompileTimeError
@@ -147,6 +148,7 @@
void_type_usage_test/call_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/call_return: MissingCompileTimeError
+void_type_usage_test/call_void_init: MissingCompileTimeError
void_type_usage_test/conditional2_conditional: MissingCompileTimeError
void_type_usage_test/conditional2_for: MissingCompileTimeError
void_type_usage_test/conditional2_literal_list_init: MissingCompileTimeError
@@ -156,6 +158,7 @@
void_type_usage_test/conditional2_return: MissingCompileTimeError
void_type_usage_test/conditional2_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional2_stmt: MissingCompileTimeError
+void_type_usage_test/conditional2_void_init: MissingCompileTimeError
void_type_usage_test/conditional3_conditional: MissingCompileTimeError
void_type_usage_test/conditional3_for: MissingCompileTimeError
void_type_usage_test/conditional3_literal_list_init: MissingCompileTimeError
@@ -165,6 +168,7 @@
void_type_usage_test/conditional3_return: MissingCompileTimeError
void_type_usage_test/conditional3_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional3_stmt: MissingCompileTimeError
+void_type_usage_test/conditional3_void_init: MissingCompileTimeError
void_type_usage_test/conditional_conditional: MissingCompileTimeError
void_type_usage_test/conditional_for: MissingCompileTimeError
void_type_usage_test/conditional_literal_list_init: MissingCompileTimeError
@@ -174,49 +178,58 @@
void_type_usage_test/conditional_return: MissingCompileTimeError
void_type_usage_test/conditional_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional_stmt: MissingCompileTimeError
+void_type_usage_test/conditional_void_init: MissingCompileTimeError
void_type_usage_test/final_local_conditional: MissingCompileTimeError
void_type_usage_test/final_local_for_in2: MissingCompileTimeError
void_type_usage_test/final_local_literal_list_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/final_local_return: MissingCompileTimeError
+void_type_usage_test/final_local_void_init: MissingCompileTimeError
void_type_usage_test/global_conditional: MissingCompileTimeError
void_type_usage_test/global_literal_list_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/global_return: MissingCompileTimeError
+void_type_usage_test/global_void_init: MissingCompileTimeError
void_type_usage_test/instance2_conditional: MissingCompileTimeError
void_type_usage_test/instance2_for_in2: MissingCompileTimeError
void_type_usage_test/instance2_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance2_return: MissingCompileTimeError
+void_type_usage_test/instance2_void_init: MissingCompileTimeError
void_type_usage_test/instance3_conditional: MissingCompileTimeError
void_type_usage_test/instance3_for_in2: MissingCompileTimeError
void_type_usage_test/instance3_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance3_return: MissingCompileTimeError
+void_type_usage_test/instance3_void_init: MissingCompileTimeError
void_type_usage_test/instance_conditional: MissingCompileTimeError
void_type_usage_test/instance_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance_return: MissingCompileTimeError
+void_type_usage_test/instance_void_init: MissingCompileTimeError
void_type_usage_test/local_conditional: MissingCompileTimeError
void_type_usage_test/local_literal_list_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/local_return: MissingCompileTimeError
+void_type_usage_test/local_void_init: MissingCompileTimeError
void_type_usage_test/param_conditional: MissingCompileTimeError
void_type_usage_test/param_literal_list_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/param_return: MissingCompileTimeError
+void_type_usage_test/param_void_init: MissingCompileTimeError
void_type_usage_test/paren_conditional: MissingCompileTimeError
void_type_usage_test/paren_literal_list_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/paren_return: MissingCompileTimeError
+void_type_usage_test/paren_void_init: MissingCompileTimeError
[ $compiler == dartdevk ]
abstract_factory_constructor_test/00: MissingCompileTimeError
diff --git a/tests/language_2/language_2_kernel.status b/tests/language_2/language_2_kernel.status
index ff7baba..9e11913 100644
--- a/tests/language_2/language_2_kernel.status
+++ b/tests/language_2/language_2_kernel.status
@@ -552,7 +552,6 @@
cyclic_type_variable_test/04: Crash
cyclic_type_variable_test/none: Crash
deopt_inlined_function_lazy_test: Skip
-instance_call_wrong_argument_count_negative_test: Crash # Issue(http//dartbug.com/31630)
optional_named_parameters_test/02: Crash # Issue(http://dartbug.com/31630)
optional_named_parameters_test/04: Crash # Issue(http://dartbug.com/31630)
optional_named_parameters_test/06: Crash # Issue(http://dartbug.com/31630)
@@ -900,7 +899,6 @@
cyclic_type_variable_test/04: Crash
cyclic_type_variable_test/none: Crash
external_test/13: Crash
-instance_call_wrong_argument_count_negative_test: Crash # Issue(http://dartbug.com/31630)
optional_named_parameters_test/02: Crash # Issue 31795
optional_named_parameters_test/04: Crash # Issue 31795
optional_named_parameters_test/06: Crash # Issue 31795
@@ -2126,4 +2124,3 @@
[ $compiler == dartk || $compiler == dartkp ]
generic_function_bounds_test: RuntimeError # Issue 32076
generic_test/01: MissingCompileTimeError
-
diff --git a/tests/language_2/void_type_function_types_test.dart b/tests/language_2/void_type_function_types_test.dart
index 9ef5aec..d436c85 100644
--- a/tests/language_2/void_type_function_types_test.dart
+++ b/tests/language_2/void_type_function_types_test.dart
@@ -92,14 +92,14 @@
expectsG(h);
expectsH(h);
- Expect.isTrue(h2 is H2);
+ Expect.isTrue(h2 is F2);
Expect.isTrue(h2 is G2);
Expect.isTrue(h2 is H2);
expectsF2(h2);
expectsG2(h2);
expectsH2(h2);
- Expect.isTrue(h3 is H3);
+ Expect.isTrue(h3 is F3);
Expect.isTrue(h3 is G3);
Expect.isTrue(h3 is H3);
expectsF3(h3);
diff --git a/tests/lib/lib.status b/tests/lib/lib.status
index 9370d97..689a0ba 100644
--- a/tests/lib/lib.status
+++ b/tests/lib/lib.status
@@ -329,6 +329,9 @@
mirrors/invocation_fuzz_test/smi: Pass, Slow
mirrors/variable_is_const_test/01: Crash # Please triage.
+[ $compiler == dartk && $system == windows ]
+mirrors/invocation_fuzz_test/smi: Pass, Timeout # Issue 32137.
+
# Enabling of dartk for sim{arm,arm64,dbc64} revelaed these test failures, which
# are to be triaged. Isolate tests are skipped on purpose due to the usage of
# batch mode.
diff --git a/tests/lib_2/lib_2_kernel.status b/tests/lib_2/lib_2_kernel.status
index 4d36cfb..ec87852 100644
--- a/tests/lib_2/lib_2_kernel.status
+++ b/tests/lib_2/lib_2_kernel.status
@@ -31,6 +31,14 @@
mirrors/invocation_fuzz_test: Skip # Because it times out, issue 29439.
mirrors/variable_is_const_test/01: Crash
+[ $builder_tag == optimization_counter_threshold && $compiler == dartk ]
+isolate/unresolved_ports_test: CompileTimeError, Pass, Timeout # Fails to compile on opt counter builder (#31838)
+mirrors/invocation_fuzz_test/emptyarray: Pass, Crash, RuntimeError # Flaky on vm-kernel-optcounter-threshold-linux-release-x64, bug #31838
+mirrors/invocation_fuzz_test/false: Pass, Crash, RuntimeError # Flaky on vm-kernel-optcounter-threshold-linux-release-x64, bug #31838
+mirrors/invocation_fuzz_test/none: Pass, Crash, RuntimeError # Flaky on vm-kernel-optcounter-threshold-linux-release-x64, bug #31838
+mirrors/invocation_fuzz_test/smi: Crash, RuntimeError, Fail, Pass # Crashes on opt counter builder (#31838)
+mirrors/invocation_fuzz_test/string: Pass, Crash, RuntimeError # Flaky on vm-kernel-optcounter-threshold-linux-release-x64, bug #31838
+
[ $compiler == dartk && $mode == debug && $runtime == vm && $strong ]
isolate/isolate_complex_messages_test: Crash
mirrors/library_exports_shown_test: Crash # 31916
@@ -191,6 +199,9 @@
mirrors/typedef_test: RuntimeError
mirrors/typevariable_mirror_metadata_test: RuntimeError
+[ $compiler == dartk && $system == windows ]
+isolate/ping_pause_test: Skip # Issues 32137 and 32138
+
[ $compiler == dartk && $strong ]
async/future_test/01: RuntimeError
async/future_test/none: RuntimeError
@@ -206,7 +217,6 @@
isolate/ping_pause_test: RuntimeError
isolate/request_reply_test: Pass, Timeout
isolate/stacktrace_message_test: RuntimeError
-isolate/unresolved_ports_test: CompileTimeError, Pass, Timeout # Fails to compile on opt counter builder (#31838)
mirrors/class_mirror_type_variables_test: RuntimeError
mirrors/constructor_optional_args_test: Crash
mirrors/constructors_test: RuntimeError
@@ -229,7 +239,6 @@
mirrors/instance_members_unimplemented_interface_test: RuntimeError
mirrors/instance_members_with_override_test: RuntimeError
mirrors/instantiate_abstract_class_test: RuntimeError
-mirrors/invocation_fuzz_test/smi: Crash, Pass # Crashes on opt counter builder (#31838)
mirrors/invoke_closurization2_test: RuntimeError
mirrors/invoke_throws_test: Crash
mirrors/library_imports_bad_metadata_test/none: RuntimeError
diff --git a/tests/standalone_2/io/web_socket_test.dart b/tests/standalone_2/io/web_socket_test.dart
index 531d62b..c65434f 100644
--- a/tests/standalone_2/io/web_socket_test.dart
+++ b/tests/standalone_2/io/web_socket_test.dart
@@ -535,6 +535,23 @@
});
}
+ void testShouldSetUserAgent() {
+ asyncStart();
+ createServer().then((server) {
+ server.transform(new WebSocketTransformer()).listen((webSocket) {
+ Expect.equals('Custom User Agent', WebSocket.userAgent);
+ server.close();
+ webSocket.close();
+ asyncEnd();
+ });
+
+ WebSocket.userAgent = 'Custom User Agent';
+ createClient(server.port).then((webSocket) {
+ webSocket.close();
+ });
+ });
+ }
+
void runTests() {
testRequestResponseClientCloses(2, null, null, 1);
testRequestResponseClientCloses(2, 3001, null, 2);
@@ -562,6 +579,7 @@
testFromUpgradedSocket();
testAdditionalHeaders();
testBasicAuthentication();
+ testShouldSetUserAgent();
}
}
diff --git a/tests/standalone_2/standalone_2_kernel.status b/tests/standalone_2/standalone_2_kernel.status
index 83359910..f2594fa 100644
--- a/tests/standalone_2/standalone_2_kernel.status
+++ b/tests/standalone_2/standalone_2_kernel.status
@@ -22,6 +22,9 @@
package/scenarios/invalid/invalid_utf8_test: CompileTimeError # Issue 32085
package/scenarios/invalid/non_existent_packages_file_test: CompileTimeError # Issue 32085
+[ $builder_tag == optimization_counter_threshold && $compiler == dartk ]
+map_insert_remove_oom_test: Pass, Crash # Flaky on vm-kernel-optcounter-threshold-linux-release-x64, bug #31838
+
[ $compiler == dartk && $mode == debug && $runtime == vm && $strong ]
io/file_lock_test: Slow, Pass
io/raw_socket_test: Crash
@@ -44,6 +47,12 @@
regress_29350_test: MissingCompileTimeError
regress_29350_test/none: Pass # Issue 31537
+[ $compiler == dartk && $system == windows ]
+io/secure_builtin_roots_test: Skip # Issues 32137 and 32138.
+io/test_extension_fail_test: RuntimeError, Pass # Issue 32137.
+io/test_extension_test: RuntimeError, Pass # Issue 32137.
+io/wait_for_event_isolate_test: Skip # Issues 32137 and 32138.
+
[ $compiler == dartk && $system == windows && $strong ]
io/compile_all_test: Fail
io/file_stream_test: RuntimeError # Issue 31904
@@ -59,6 +68,7 @@
io/directory_list_sync_test: Timeout, Pass # Please triage.
io/file_blocking_lock_test: Pass, Crash # Please triage.
io/file_lock_test: RuntimeError # Please triage.
+io/platform_resolved_executable_test/05: Pass, RuntimeError # Issue 32134
io/platform_test: RuntimeError # Please triage.
io/test_extension_fail_test: RuntimeError # Please traige.
io/test_extension_test: RuntimeError # Please traige.
diff --git a/tools/VERSION b/tools/VERSION
index f6a0fd2..4fa6039 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 0
PATCH 0
-PRERELEASE 24
+PRERELEASE 25
PRERELEASE_PATCH 0
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index 6efea6f..fda892d 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -618,6 +618,7 @@
{
"name": "vm tests",
"arguments": [
+ "--builder-tag=optimization_counter_threshold",
"--compiler=dartk",
"--vm-options=--optimization-counter-threshold=5"
],
@@ -627,6 +628,7 @@
{
"name": "strong vm tests",
"arguments": [
+ "--builder-tag=optimization_counter_threshold",
"--compiler=dartk",
"--strong",
"--vm-options=--optimization-counter-threshold=5"
diff --git a/tools/gn.py b/tools/gn.py
index d727fbc..2b5ebc6 100755
--- a/tools/gn.py
+++ b/tools/gn.py
@@ -172,9 +172,8 @@
# Don't use the wheezy sysroot if we're given another sysroot.
if TargetSysroot(args):
return False
- # The clang toolchain we pull from Fuchsia doesn't have arm and arm64
- # sysroots, so use the wheezy/jesse ones.
- return gn_args['is_clang'] and gn_args['target_cpu'].startswith('arm')
+ # Use the downloaded sysroot unless it is explicitly disabled.
+ return not args.no_wheezy and not UseSanitizer(args)
def ToGnArgs(args, mode, arch, target_os):
@@ -444,8 +443,9 @@
action='store_true')
other_group.add_argument('--no-wheezy',
help='Disable the Debian wheezy sysroot on Linux',
- dest='wheezy',
- action='store_false')
+ default=False,
+ dest='no_wheezy',
+ action='store_true')
other_group.add_argument('--workers', '-w',
type=int,
help='Number of simultaneous GN invocations',
diff --git a/tools/testing/dart/command.dart b/tools/testing/dart/command.dart
index b2680ca..30ec729 100644
--- a/tools/testing/dart/command.dart
+++ b/tools/testing/dart/command.dart
@@ -365,6 +365,17 @@
}
return "$buffer";
}
+
+ @override
+ void _buildHashCode(HashCodeBuilder builder) {
+ super._buildHashCode(builder);
+ builder.addJson(_compilerLocation);
+ }
+
+ @override
+ bool _equal(FastaCompilationCommand other) {
+ return super._equal(other) && _compilerLocation == other._compilerLocation;
+ }
}
class VMKernelCompilationCommand extends CompilationCommand {
diff --git a/tools/testing/dart/compiler_configuration.dart b/tools/testing/dart/compiler_configuration.dart
index ac20f0b..5501b92 100644
--- a/tools/testing/dart/compiler_configuration.dart
+++ b/tools/testing/dart/compiler_configuration.dart
@@ -121,8 +121,12 @@
throw new UnsupportedError("$this does not support createCommand().");
}
- CommandArtifact computeCompilationArtifact(String tempDir,
- List<String> arguments, Map<String, String> environmentOverrides) {
+ CommandArtifact computeCompilationArtifact(
+
+ /// Each test has its own temporary directory to avoid name collisions.
+ String tempDir,
+ List<String> arguments,
+ Map<String, String> environmentOverrides) {
return new CommandArtifact([], null, null);
}
@@ -1095,7 +1099,7 @@
FastaCompilerConfiguration(Configuration configuration)
: this._(
- Uri.base.resolve("pkg/front_end/tool/_fasta/compile.dart"),
+ Repository.uri.resolve("pkg/front_end/tool/_fasta/compile.dart"),
Uri.base
.resolveUri(new Uri.directory(configuration.buildDirectory)),
!configuration.isStrong,
@@ -1145,12 +1149,18 @@
if (Platform.isWindows) {
vmPath += ".exe";
}
- List<String> compilerArguments = <String>[
- "-o",
- outputFileName,
- "--platform",
- _plaformDill.toFilePath(),
- ]..addAll(arguments);
+ List<String> compilerArguments = <String>[];
+ if (!_isLegacy) {
+ compilerArguments.add("--strong-mode");
+ }
+ compilerArguments
+ ..addAll(<String>[
+ "-o",
+ outputFileName,
+ "--platform",
+ _plaformDill.toFilePath(),
+ ])
+ ..addAll(arguments);
return new CommandArtifact(
[
@@ -1161,7 +1171,7 @@
_vmExecutable,
compilerArguments,
environmentOverrides,
- Uri.base,
+ Repository.uri,
)
],
outputFileName,
@@ -1192,6 +1202,9 @@
List<String> sharedOptions,
List<String> originalArguments,
CommandArtifact artifact) {
+ if (runtimeConfiguration is! NoneRuntimeConfiguration) {
+ throw "--compiler=fasta only supports --runtime=none";
+ }
return <String>[];
}
}
diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart
index 5c743b3..ccbf1fd 100644
--- a/tools/testing/dart/test_runner.dart
+++ b/tools/testing/dart/test_runner.dart
@@ -574,7 +574,7 @@
class BatchRunnerProcess {
/// When true, the command line is passed to the test runner as a
/// JSON-encoded list of strings.
- final bool _jsonCommandLine;
+ final bool _useJson;
Completer<CommandOutput> _completer;
ProcessCommand _command;
@@ -597,7 +597,7 @@
Timer _timer;
int _testCount = 0;
- BatchRunnerProcess(this._jsonCommandLine);
+ BatchRunnerProcess({bool useJson: true}) : _useJson = useJson;
Future<CommandOutput> runCommand(String runnerType, ProcessCommand command,
int timeout, List<String> arguments) {
@@ -670,7 +670,7 @@
}
String _createArgumentsLine(List<String> arguments, int timeout) {
- if (_jsonCommandLine) {
+ if (_useJson) {
return "${JSON.encode(arguments)}\n";
} else {
return arguments.join(' ') + '\n';
@@ -1280,7 +1280,7 @@
if (runners == null) {
runners = new List<BatchRunnerProcess>(maxProcesses);
for (int i = 0; i < maxProcesses; i++) {
- runners[i] = new BatchRunnerProcess(identifier == "fasta");
+ runners[i] = new BatchRunnerProcess(useJson: identifier == "fasta");
}
_batchProcesses[identifier] = runners;
}