Version 2.17.0-100.0.dev
Merge commit '49990c3e6970f9b9fb9f43e25670dd0c1d5ce23c' into 'dev'
diff --git a/pkg/dev_compiler/analysis_options.yaml b/pkg/dev_compiler/analysis_options.yaml
index f93da08..f591c75 100644
--- a/pkg/dev_compiler/analysis_options.yaml
+++ b/pkg/dev_compiler/analysis_options.yaml
@@ -22,6 +22,7 @@
rules:
# Not enforced by lints at any version.
- always_declare_return_types
+ - depend_on_referenced_packages
- directives_ordering
- omit_local_variable_types
- prefer_single_quotes
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index f6fc3a2..6f81197 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -10,7 +10,6 @@
import 'package:args/args.dart';
import 'package:build_integration/file_system/multi_root.dart';
-import 'package:cli_util/cli_util.dart' show getSdkPath;
import 'package:front_end/src/api_unstable/ddc.dart' as fe;
import 'package:kernel/binary/ast_to_binary.dart' as kernel show BinaryPrinter;
import 'package:kernel/class_hierarchy.dart';
@@ -837,6 +836,9 @@
final defaultLibrarySpecPath = p.join(getSdkPath(), 'lib', 'libraries.json');
+/// Return the path to the runtime Dart SDK.
+String getSdkPath() => p.dirname(p.dirname(Platform.resolvedExecutable));
+
/// Returns the absolute path to the default `package_config.json` file, or
/// `null` if one could not be found.
///
diff --git a/pkg/dev_compiler/pubspec.yaml b/pkg/dev_compiler/pubspec.yaml
index 0d15516..acd4d9d 100644
--- a/pkg/dev_compiler/pubspec.yaml
+++ b/pkg/dev_compiler/pubspec.yaml
@@ -14,7 +14,6 @@
bazel_worker: any
build_integration:
path: ../build_integration
- cli_util: any
collection: ^1.15.0
front_end:
path: ../front_end
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
index 90f0eef..461cf17 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
@@ -9,9 +9,9 @@
import 'dart:io' show Directory, File, Platform;
import 'package:browser_launcher/browser_launcher.dart' as browser;
-import 'package:cli_util/cli_util.dart';
import 'package:dev_compiler/dev_compiler.dart';
import 'package:dev_compiler/src/compiler/module_builder.dart';
+import 'package:dev_compiler/src/kernel/command.dart';
import 'package:dev_compiler/src/kernel/module_metadata.dart';
import 'package:front_end/src/api_unstable/ddc.dart' as fe;
import 'package:front_end/src/compute_platform_binaries_location.dart' as fe;
diff --git a/pkg/dev_compiler/test/shared_test_options.dart b/pkg/dev_compiler/test/shared_test_options.dart
index 88013a3..7edff24 100644
--- a/pkg/dev_compiler/test/shared_test_options.dart
+++ b/pkg/dev_compiler/test/shared_test_options.dart
@@ -4,8 +4,8 @@
// @dart = 2.9
-import 'package:cli_util/cli_util.dart';
import 'package:dev_compiler/dev_compiler.dart';
+import 'package:dev_compiler/src/kernel/command.dart';
import 'package:front_end/src/api_unstable/ddc.dart';
import 'package:front_end/src/compute_platform_binaries_location.dart';
import 'package:front_end/src/fasta/incremental_serializer.dart';
diff --git a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
index 65085dc..1e51ffb 100644
--- a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
@@ -28,6 +28,9 @@
@override
TypeDeclarationBuilder get origin;
+ /// Return `true` if this type declaration is an enum.
+ bool get isEnum;
+
/// Creates the [DartType] corresponding to this declaration applied with
/// [arguments] in [library] with the syntactical nullability defined by
/// [nullabilityBuilder].
@@ -75,6 +78,9 @@
bool get isTypeDeclaration => true;
@override
+ bool get isEnum => false;
+
+ @override
String get fullNameForErrors => name;
@override
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart
index 18b8478..d8e6d6a 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart
@@ -47,6 +47,9 @@
cls.fileOffset);
@override
+ bool get isEnum => cls.isEnum;
+
+ @override
DillClassBuilder get origin => this;
@override
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 422afdf..b2ab970 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -5371,7 +5371,7 @@
} else {
target = b.member;
}
- if (type is SourceEnumBuilder &&
+ if (type.isEnum &&
!(libraryBuilder.enableEnhancedEnumsInLibrary &&
target is Procedure &&
target.kind == ProcedureKind.Factory)) {
diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
index 2e8000f..7c41343 100644
--- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
@@ -1111,6 +1111,7 @@
TreeNode parent = variable.parent!;
Expression implicitDowncast = inferrer.ensureAssignable(
variable.type, inferredType, variableGet,
+ isVoidAllowed: true,
fileOffset: parent.fileOffset,
errorTemplate: templateForInLoopElementTypeNotAssignable,
nullabilityErrorTemplate:
diff --git a/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart b/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart
index b6a5104..d23c72b 100644
--- a/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_enum_builder.dart
@@ -456,6 +456,9 @@
}
@override
+ bool get isEnum => true;
+
+ @override
TypeBuilder? get mixedInTypeBuilder => null;
@override
@@ -614,7 +617,7 @@
// be built via a body builder to detect potential errors.
bodyBuilder = library.loader.createBodyBuilderForOutlineExpression(
library, this, this, scope, fileUri);
- bodyBuilder.constantContext = ConstantContext.required;
+ bodyBuilder.constantContext = ConstantContext.inferred;
}
if (enumConstantInfo.argumentsBeginToken != null) {
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart b/pkg/front_end/testcases/enhanced_enums/issue48232.dart
new file mode 100644
index 0000000..633928f
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+enum E {
+ v([]); // No error.
+ const E(_);
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart.strong.expect b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.strong.expect
new file mode 100644
index 0000000..d829c61
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.strong.expect
@@ -0,0 +1,28 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class E extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::E> values = #C4;
+ static const field self::E v = #C3;
+ const constructor •(core::int index, core::String name, dynamic _) → self::E
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "E.${this.{core::_Enum::_name}{core::String}}";
+}
+static method main() → dynamic {}
+
+constants {
+ #C1 = 0
+ #C2 = "v"
+ #C3 = self::E {index:#C1, _name:#C2}
+ #C4 = <self::E>[#C3]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue48232.dart:
+- E. (from org-dartlang-testcase:///issue48232.dart:7:9)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart.strong.transformed.expect b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.strong.transformed.expect
new file mode 100644
index 0000000..d829c61
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.strong.transformed.expect
@@ -0,0 +1,28 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class E extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::E> values = #C4;
+ static const field self::E v = #C3;
+ const constructor •(core::int index, core::String name, dynamic _) → self::E
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "E.${this.{core::_Enum::_name}{core::String}}";
+}
+static method main() → dynamic {}
+
+constants {
+ #C1 = 0
+ #C2 = "v"
+ #C3 = self::E {index:#C1, _name:#C2}
+ #C4 = <self::E>[#C3]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue48232.dart:
+- E. (from org-dartlang-testcase:///issue48232.dart:7:9)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart.textual_outline.expect b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.textual_outline.expect
new file mode 100644
index 0000000..1f73072
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.textual_outline.expect
@@ -0,0 +1,2 @@
+enum E { v([]); const E(_); }
+main() {}
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.expect b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.expect
new file mode 100644
index 0000000..018ab8b
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.expect
@@ -0,0 +1,28 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class E extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::E> values = #C4;
+ static const field self::E v = #C3;
+ const constructor •(core::int index, core::String name, dynamic _) → self::E
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "E.${this.{core::_Enum::_name}{core::String}}";
+}
+static method main() → dynamic {}
+
+constants {
+ #C1 = 0
+ #C2 = "v"
+ #C3 = self::E {index:#C1, _name:#C2}
+ #C4 = <self::E*>[#C3]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue48232.dart:
+- E. (from org-dartlang-testcase:///issue48232.dart:7:9)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.modular.expect b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.modular.expect
new file mode 100644
index 0000000..018ab8b
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.modular.expect
@@ -0,0 +1,28 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class E extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::E> values = #C4;
+ static const field self::E v = #C3;
+ const constructor •(core::int index, core::String name, dynamic _) → self::E
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "E.${this.{core::_Enum::_name}{core::String}}";
+}
+static method main() → dynamic {}
+
+constants {
+ #C1 = 0
+ #C2 = "v"
+ #C3 = self::E {index:#C1, _name:#C2}
+ #C4 = <self::E*>[#C3]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue48232.dart:
+- E. (from org-dartlang-testcase:///issue48232.dart:7:9)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.outline.expect b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.outline.expect
new file mode 100644
index 0000000..b2e8953
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.outline.expect
@@ -0,0 +1,21 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class E extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::E> values = const <self::E>[self::E::v];
+ static const field self::E v = const self::E::•(0, "v", const <dynamic>[]);
+ const constructor •(core::int index, core::String name, dynamic _) → self::E
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "E.${this.{core::_Enum::_name}{core::String}}";
+}
+static method main() → dynamic
+ ;
+
+
+Extra constant evaluation status:
+Evaluated: ListLiteral @ org-dartlang-testcase:///issue48232.dart:5:6 -> ListConstant(const <E*>[const E{_Enum.index: 0, _Enum._name: "v"}])
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///issue48232.dart:6:5 -> InstanceConstant(const E{_Enum.index: 0, _Enum._name: "v"})
+Extra constant evaluation: evaluated: 7, effectively constant: 2
diff --git a/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.transformed.expect b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.transformed.expect
new file mode 100644
index 0000000..018ab8b
--- /dev/null
+++ b/pkg/front_end/testcases/enhanced_enums/issue48232.dart.weak.transformed.expect
@@ -0,0 +1,28 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class E extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::E> values = #C4;
+ static const field self::E v = #C3;
+ const constructor •(core::int index, core::String name, dynamic _) → self::E
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "E.${this.{core::_Enum::_name}{core::String}}";
+}
+static method main() → dynamic {}
+
+constants {
+ #C1 = 0
+ #C2 = "v"
+ #C3 = self::E {index:#C1, _name:#C2}
+ #C4 = <self::E*>[#C3]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue48232.dart:
+- E. (from org-dartlang-testcase:///issue48232.dart:7:9)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/expression/instantiate_enum.expression.yaml b/pkg/front_end/testcases/expression/instantiate_enum.expression.yaml
new file mode 100644
index 0000000..b6739e7
--- /dev/null
+++ b/pkg/front_end/testcases/expression/instantiate_enum.expression.yaml
@@ -0,0 +1,9 @@
+# Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+entry_point: "main.dart"
+definitions: []
+position: "main.dart"
+expression: |
+ En(123, 'foo')
diff --git a/pkg/front_end/testcases/expression/instantiate_enum.expression.yaml.expect b/pkg/front_end/testcases/expression/instantiate_enum.expression.yaml.expect
new file mode 100644
index 0000000..447cbd7
--- /dev/null
+++ b/pkg/front_end/testcases/expression/instantiate_enum.expression.yaml.expect
@@ -0,0 +1,7 @@
+Errors: {
+ org-dartlang-debug:synthetic_debug_expression:1:1: Error: Enums can't be instantiated.
+ En(123, 'foo')
+ ^^
+}
+method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
+ return invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:1: Error: Enums can't be instantiated.\nEn(123, 'foo')\n^^";
diff --git a/pkg/front_end/testcases/expression/main.dart b/pkg/front_end/testcases/expression/main.dart
index 59f53f0..35045e1 100644
--- a/pkg/front_end/testcases/expression/main.dart
+++ b/pkg/front_end/testcases/expression/main.dart
@@ -127,3 +127,5 @@
.fold<int>(0, (previousValue, element) => previousValue + element.length);
print("xCombinedLength = $xCombinedLength");
}
+
+enum En { a, b, c }
diff --git a/pkg/front_end/testcases/general/inferred_void.dart b/pkg/front_end/testcases/general/inferred_void.dart
new file mode 100644
index 0000000..5a39d07
--- /dev/null
+++ b/pkg/front_end/testcases/general/inferred_void.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+void method() {}
+
+void v1 = method();
+var v2 = method();
+List<void> l1 = [method()];
+var l2 = [method()];
+
+test(Iterable<void> iterable, Stream<void> stream) async {
+ void v1 = method();
+ var v2 = method();
+ for (var v3 in iterable) {}
+ for (void v4 in iterable) {}
+ await for (var v5 in stream) {}
+ await for (void v6 in stream) {}
+ List<void> l1 = [method()];
+ var l2 = [method()];
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/inferred_void.dart.textual_outline.expect b/pkg/front_end/testcases/general/inferred_void.dart.textual_outline.expect
new file mode 100644
index 0000000..258ee94
--- /dev/null
+++ b/pkg/front_end/testcases/general/inferred_void.dart.textual_outline.expect
@@ -0,0 +1,7 @@
+void method() {}
+void v1 = method();
+var v2 = method();
+List<void> l1 = [method()];
+var l2 = [method()];
+test(Iterable<void> iterable, Stream<void> stream) async {}
+main() {}
diff --git a/pkg/front_end/testcases/general/inferred_void.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/inferred_void.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..f8f634b
--- /dev/null
+++ b/pkg/front_end/testcases/general/inferred_void.dart.textual_outline_modelled.expect
@@ -0,0 +1,7 @@
+List<void> l1 = [method()];
+main() {}
+test(Iterable<void> iterable, Stream<void> stream) async {}
+var l2 = [method()];
+var v2 = method();
+void method() {}
+void v1 = method();
diff --git a/pkg/front_end/testcases/general/inferred_void.dart.weak.expect b/pkg/front_end/testcases/general/inferred_void.dart.weak.expect
new file mode 100644
index 0000000..c8d8b7d
--- /dev/null
+++ b/pkg/front_end/testcases/general/inferred_void.dart.weak.expect
@@ -0,0 +1,25 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+static field void v1 = self::method();
+static field void v2 = self::method();
+static field core::List<void> l1 = <void>[self::method()];
+static field core::List<void> l2 = <void>[self::method()];
+static method method() → void {}
+static method test(core::Iterable<void> iterable, asy::Stream<void> stream) → dynamic async {
+ void v1 = self::method();
+ void v2 = self::method();
+ for (void v3 in iterable) {
+ }
+ for (void v4 in iterable) {
+ }
+ await for (void v5 in stream) {
+ }
+ await for (void v6 in stream) {
+ }
+ core::List<void> l1 = <void>[self::method()];
+ core::List<void> l2 = <void>[self::method()];
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/inferred_void.dart.weak.modular.expect b/pkg/front_end/testcases/general/inferred_void.dart.weak.modular.expect
new file mode 100644
index 0000000..c8d8b7d
--- /dev/null
+++ b/pkg/front_end/testcases/general/inferred_void.dart.weak.modular.expect
@@ -0,0 +1,25 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+static field void v1 = self::method();
+static field void v2 = self::method();
+static field core::List<void> l1 = <void>[self::method()];
+static field core::List<void> l2 = <void>[self::method()];
+static method method() → void {}
+static method test(core::Iterable<void> iterable, asy::Stream<void> stream) → dynamic async {
+ void v1 = self::method();
+ void v2 = self::method();
+ for (void v3 in iterable) {
+ }
+ for (void v4 in iterable) {
+ }
+ await for (void v5 in stream) {
+ }
+ await for (void v6 in stream) {
+ }
+ core::List<void> l1 = <void>[self::method()];
+ core::List<void> l2 = <void>[self::method()];
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/inferred_void.dart.weak.outline.expect b/pkg/front_end/testcases/general/inferred_void.dart.weak.outline.expect
new file mode 100644
index 0000000..c0d467d
--- /dev/null
+++ b/pkg/front_end/testcases/general/inferred_void.dart.weak.outline.expect
@@ -0,0 +1,15 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "dart:async" as asy;
+
+static field void v1;
+static field void v2;
+static field core::List<void> l1;
+static field core::List<void> l2;
+static method method() → void
+ ;
+static method test(core::Iterable<void> iterable, asy::Stream<void> stream) → dynamic async
+ ;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/inferred_void.dart.weak.transformed.expect b/pkg/front_end/testcases/general/inferred_void.dart.weak.transformed.expect
new file mode 100644
index 0000000..6528bab
--- /dev/null
+++ b/pkg/front_end/testcases/general/inferred_void.dart.weak.transformed.expect
@@ -0,0 +1,101 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "dart:async" as asy;
+import "dart:_internal" as _in;
+
+static field void v1 = self::method();
+static field void v2 = self::method();
+static field core::List<void> l1 = core::_GrowableList::_literal1<void>(self::method());
+static field core::List<void> l2 = core::_GrowableList::_literal1<void>(self::method());
+static method method() → void {}
+static method test(core::Iterable<void> iterable, asy::Stream<void> stream) → dynamic /* originally async */ {
+ final asy::_Future<dynamic> :async_future = new asy::_Future::•<dynamic>();
+ core::bool* :is_sync = false;
+ dynamic :return_value;
+ (dynamic) → dynamic :async_op_then;
+ (core::Object, core::StackTrace) → dynamic :async_op_error;
+ core::int :await_jump_var = 0;
+ dynamic :await_ctx_var;
+ dynamic :saved_try_context_var0;
+ dynamic :saved_try_context_var1;
+ dynamic :exception0;
+ dynamic :stack_trace0;
+ function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
+ try {
+ #L1:
+ {
+ void v1 = self::method();
+ void v2 = self::method();
+ {
+ core::Iterator<void> :sync-for-iterator = iterable.{core::Iterable::iterator}{core::Iterator<void>};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) {
+ void v3 = :sync-for-iterator.{core::Iterator::current}{void};
+ {}
+ }
+ }
+ {
+ core::Iterator<void> :sync-for-iterator = iterable.{core::Iterable::iterator}{core::Iterator<void>};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) {
+ void v4 = :sync-for-iterator.{core::Iterator::current}{void};
+ {}
+ }
+ }
+ {
+ asy::Stream<void> :stream = stream;
+ asy::_StreamIterator<void>? :for-iterator = new asy::_StreamIterator::•<void>(:stream);
+ try
+ #L2:
+ while (true) {
+ dynamic #t1 = asy::_asyncStarMoveNextHelper(:stream);
+ [yield] let dynamic #t2 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}, :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool>(:result)) {
+ void v5 = :for-iterator.{asy::_StreamIterator::current}{void};
+ {}
+ }
+ else
+ break #L2;
+ }
+ finally
+ if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<void>?} == null)) {
+ [yield] let dynamic #t3 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::cancel}(){() → asy::Future<dynamic>}, :async_op_then, :async_op_error, :async_op) in null;
+ :result;
+ }
+ }
+ {
+ asy::Stream<void> :stream = stream;
+ asy::_StreamIterator<void>? :for-iterator = new asy::_StreamIterator::•<void>(:stream);
+ try
+ #L3:
+ while (true) {
+ dynamic #t4 = asy::_asyncStarMoveNextHelper(:stream);
+ [yield] let dynamic #t5 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}, :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool>(:result)) {
+ void v6 = :for-iterator.{asy::_StreamIterator::current}{void};
+ {}
+ }
+ else
+ break #L3;
+ }
+ finally
+ if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<void>?} == null)) {
+ [yield] let dynamic #t6 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::cancel}(){() → asy::Future<dynamic>}, :async_op_then, :async_op_error, :async_op) in null;
+ :result;
+ }
+ }
+ core::List<void> l1 = core::_GrowableList::_literal1<void>(self::method());
+ core::List<void> l2 = core::_GrowableList::_literal1<void>(self::method());
+ }
+ asy::_completeWithNoFutureOnAsyncReturn(:async_future, :return_value, :is_sync);
+ return;
+ }
+ on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
+ asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+ }
+ :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+ :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+ :async_op(){() → dynamic};
+ :is_sync = true;
+ return :async_future;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main.dart b/pkg/front_end/testcases/general/instantiate_enum/main.dart
new file mode 100644
index 0000000..85515b3
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'main_lib.dart';
+
+enum Enum1 { a, b, c }
+
+typedef Alias1 = Enum1;
+
+test() {
+ Enum1(123, 'foo');
+ Enum2(123, 'foo');
+ Alias1(123, 'foo');
+ Alias2(123, 'foo');
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline.expect b/pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline.expect
new file mode 100644
index 0000000..9e362fc
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline.expect
@@ -0,0 +1,6 @@
+import 'main_lib.dart';
+
+enum Enum1 { a, b, c }
+typedef Alias1 = Enum1;
+test() {}
+main() {}
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..596d8b2
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline_modelled.expect
@@ -0,0 +1,6 @@
+import 'main_lib.dart';
+
+enum Enum1 { a, b, c }
+main() {}
+test() {}
+typedef Alias1 = Enum1;
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.expect b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.expect
new file mode 100644
index 0000000..2976547
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.expect
@@ -0,0 +1,98 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated.
+// Enum1(123, 'foo');
+// ^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated.
+// Enum2(123, 'foo');
+// ^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated.
+// Alias1(123, 'foo');
+// ^^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated.
+// Alias2(123, 'foo');
+// ^^^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///main_lib.dart";
+
+typedef Alias1 = self::Enum1;
+class Enum1 extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::Enum1> values = #C10;
+ static const field self::Enum1 a = #C3;
+ static const field self::Enum1 b = #C6;
+ static const field self::Enum1 c = #C9;
+ const constructor •(core::int index, core::String name) → self::Enum1
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "Enum1.${this.{core::_Enum::_name}{core::String}}";
+}
+static method test() → dynamic {
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated.
+ Enum1(123, 'foo');
+ ^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated.
+ Enum2(123, 'foo');
+ ^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated.
+ Alias1(123, 'foo');
+ ^^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated.
+ Alias2(123, 'foo');
+ ^^^^^^";
+}
+static method main() → dynamic {}
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+typedef Alias2 = self2::Enum2;
+class Enum2 extends core::_Enum /*isEnum*/ {
+ static const field core::List<self2::Enum2> values = #C14;
+ static const field self2::Enum2 a = #C11;
+ static const field self2::Enum2 b = #C12;
+ static const field self2::Enum2 c = #C13;
+ const constructor •(core::int index, core::String name) → self2::Enum2
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "Enum2.${this.{core::_Enum::_name}{core::String}}";
+}
+
+constants {
+ #C1 = 0
+ #C2 = "a"
+ #C3 = self::Enum1 {index:#C1, _name:#C2}
+ #C4 = 1
+ #C5 = "b"
+ #C6 = self::Enum1 {index:#C4, _name:#C5}
+ #C7 = 2
+ #C8 = "c"
+ #C9 = self::Enum1 {index:#C7, _name:#C8}
+ #C10 = <self::Enum1*>[#C3, #C6, #C9]
+ #C11 = self2::Enum2 {index:#C1, _name:#C2}
+ #C12 = self2::Enum2 {index:#C4, _name:#C5}
+ #C13 = self2::Enum2 {index:#C7, _name:#C8}
+ #C14 = <self2::Enum2*>[#C11, #C12, #C13]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///main_lib.dart:
+- Enum2. (from org-dartlang-testcase:///main_lib.dart:5:6)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
+
+org-dartlang-testcase:///main.dart:
+- Enum1. (from org-dartlang-testcase:///main.dart:7:6)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.modular.expect b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.modular.expect
new file mode 100644
index 0000000..8b09079
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.modular.expect
@@ -0,0 +1,72 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated.
+// Enum1(123, 'foo');
+// ^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated.
+// Enum2(123, 'foo');
+// ^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated.
+// Alias1(123, 'foo');
+// ^^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated.
+// Alias2(123, 'foo');
+// ^^^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///main_lib.dart";
+
+typedef Alias1 = self::Enum1;
+class Enum1 extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::Enum1> values = #C10;
+ static const field self::Enum1 a = #C3;
+ static const field self::Enum1 b = #C6;
+ static const field self::Enum1 c = #C9;
+ const constructor •(core::int index, core::String name) → self::Enum1
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "Enum1.${this.{core::_Enum::_name}{core::String}}";
+}
+static method test() → dynamic {
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated.
+ Enum1(123, 'foo');
+ ^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated.
+ Enum2(123, 'foo');
+ ^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated.
+ Alias1(123, 'foo');
+ ^^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated.
+ Alias2(123, 'foo');
+ ^^^^^^";
+}
+static method main() → dynamic {}
+
+constants {
+ #C1 = 0
+ #C2 = "a"
+ #C3 = self::Enum1 {index:#C1, _name:#C2}
+ #C4 = 1
+ #C5 = "b"
+ #C6 = self::Enum1 {index:#C4, _name:#C5}
+ #C7 = 2
+ #C8 = "c"
+ #C9 = self::Enum1 {index:#C7, _name:#C8}
+ #C10 = <self::Enum1*>[#C3, #C6, #C9]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///main.dart:
+- Enum1. (from org-dartlang-testcase:///main.dart:7:6)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.outline.expect b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.outline.expect
new file mode 100644
index 0000000..cc966f8
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.outline.expect
@@ -0,0 +1,66 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///main_lib.dart";
+
+typedef Alias1 = self::Enum1;
+class Enum1 extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::Enum1> values = const <self::Enum1>[self::Enum1::a, self::Enum1::b, self::Enum1::c];
+ static const field self::Enum1 a = const self::Enum1::•(0, "a");
+ static const field self::Enum1 b = const self::Enum1::•(1, "b");
+ static const field self::Enum1 c = const self::Enum1::•(2, "c");
+ const constructor •(core::int index, core::String name) → self::Enum1
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "Enum1.${this.{core::_Enum::_name}{core::String}}";
+}
+static method test() → dynamic
+ ;
+static method main() → dynamic
+ ;
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+typedef Alias2 = self2::Enum2;
+class Enum2 extends core::_Enum /*isEnum*/ {
+ static const field core::List<self2::Enum2> values = #C10;
+ static const field self2::Enum2 a = #C3;
+ static const field self2::Enum2 b = #C6;
+ static const field self2::Enum2 c = #C9;
+ const constructor •(core::int index, core::String name) → self2::Enum2
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "Enum2.${this.{core::_Enum::_name}{core::String}}";
+}
+
+constants {
+ #C1 = 0
+ #C2 = "a"
+ #C3 = self2::Enum2 {index:#C1, _name:#C2}
+ #C4 = 1
+ #C5 = "b"
+ #C6 = self2::Enum2 {index:#C4, _name:#C5}
+ #C7 = 2
+ #C8 = "c"
+ #C9 = self2::Enum2 {index:#C7, _name:#C8}
+ #C10 = <self2::Enum2*>[#C3, #C6, #C9]
+}
+
+Extra constant evaluation status:
+Evaluated: ListLiteral @ org-dartlang-testcase:///main.dart:7:6 -> ListConstant(const <Enum1*>[const Enum1{_Enum.index: 0, _Enum._name: "a"}, const Enum1{_Enum.index: 1, _Enum._name: "b"}, const Enum1{_Enum.index: 2, _Enum._name: "c"}])
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///main.dart:7:14 -> InstanceConstant(const Enum1{_Enum.index: 0, _Enum._name: "a"})
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///main.dart:7:17 -> InstanceConstant(const Enum1{_Enum.index: 1, _Enum._name: "b"})
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///main.dart:7:20 -> InstanceConstant(const Enum1{_Enum.index: 2, _Enum._name: "c"})
+Extra constant evaluation: evaluated: 14, effectively constant: 4
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///main_lib.dart:
+- Enum2. (from org-dartlang-testcase:///main_lib.dart:5:6)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.transformed.expect b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.transformed.expect
new file mode 100644
index 0000000..2976547
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.transformed.expect
@@ -0,0 +1,98 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated.
+// Enum1(123, 'foo');
+// ^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated.
+// Enum2(123, 'foo');
+// ^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated.
+// Alias1(123, 'foo');
+// ^^^^^^
+//
+// pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated.
+// Alias2(123, 'foo');
+// ^^^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///main_lib.dart";
+
+typedef Alias1 = self::Enum1;
+class Enum1 extends core::_Enum /*isEnum*/ {
+ static const field core::List<self::Enum1> values = #C10;
+ static const field self::Enum1 a = #C3;
+ static const field self::Enum1 b = #C6;
+ static const field self::Enum1 c = #C9;
+ const constructor •(core::int index, core::String name) → self::Enum1
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "Enum1.${this.{core::_Enum::_name}{core::String}}";
+}
+static method test() → dynamic {
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated.
+ Enum1(123, 'foo');
+ ^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated.
+ Enum2(123, 'foo');
+ ^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated.
+ Alias1(123, 'foo');
+ ^^^^^^";
+ invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated.
+ Alias2(123, 'foo');
+ ^^^^^^";
+}
+static method main() → dynamic {}
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+typedef Alias2 = self2::Enum2;
+class Enum2 extends core::_Enum /*isEnum*/ {
+ static const field core::List<self2::Enum2> values = #C14;
+ static const field self2::Enum2 a = #C11;
+ static const field self2::Enum2 b = #C12;
+ static const field self2::Enum2 c = #C13;
+ const constructor •(core::int index, core::String name) → self2::Enum2
+ : super core::_Enum::•(index, name)
+ ;
+ method toString() → core::String
+ return "Enum2.${this.{core::_Enum::_name}{core::String}}";
+}
+
+constants {
+ #C1 = 0
+ #C2 = "a"
+ #C3 = self::Enum1 {index:#C1, _name:#C2}
+ #C4 = 1
+ #C5 = "b"
+ #C6 = self::Enum1 {index:#C4, _name:#C5}
+ #C7 = 2
+ #C8 = "c"
+ #C9 = self::Enum1 {index:#C7, _name:#C8}
+ #C10 = <self::Enum1*>[#C3, #C6, #C9]
+ #C11 = self2::Enum2 {index:#C1, _name:#C2}
+ #C12 = self2::Enum2 {index:#C4, _name:#C5}
+ #C13 = self2::Enum2 {index:#C7, _name:#C8}
+ #C14 = <self2::Enum2*>[#C11, #C12, #C13]
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///main_lib.dart:
+- Enum2. (from org-dartlang-testcase:///main_lib.dart:5:6)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
+
+org-dartlang-testcase:///main.dart:
+- Enum1. (from org-dartlang-testcase:///main.dart:7:6)
+- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/instantiate_enum/main_lib.dart b/pkg/front_end/testcases/general/instantiate_enum/main_lib.dart
new file mode 100644
index 0000000..f59f17d
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/main_lib.dart
@@ -0,0 +1,7 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+enum Enum2 { a, b, c }
+
+typedef Alias2 = Enum2;
diff --git a/pkg/front_end/testcases/general/instantiate_enum/test.options b/pkg/front_end/testcases/general/instantiate_enum/test.options
new file mode 100644
index 0000000..bfe6dc8
--- /dev/null
+++ b/pkg/front_end/testcases/general/instantiate_enum/test.options
@@ -0,0 +1 @@
+main_lib.dart
\ No newline at end of file
diff --git a/pkg/front_end/testcases/general/issue48347.dart b/pkg/front_end/testcases/general/issue48347.dart
new file mode 100644
index 0000000..8b9e1ab
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48347.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+test(StreamController<void> _eventStreamController) async {
+ await for (final _ in _eventStreamController.stream) {}
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/issue48347.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue48347.dart.textual_outline.expect
new file mode 100644
index 0000000..0278a37
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48347.dart.textual_outline.expect
@@ -0,0 +1,4 @@
+import 'dart:async';
+
+test(StreamController<void> _eventStreamController) async {}
+main() {}
diff --git a/pkg/front_end/testcases/general/issue48347.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue48347.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..50c55af
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48347.dart.textual_outline_modelled.expect
@@ -0,0 +1,4 @@
+import 'dart:async';
+
+main() {}
+test(StreamController<void> _eventStreamController) async {}
diff --git a/pkg/front_end/testcases/general/issue48347.dart.weak.expect b/pkg/front_end/testcases/general/issue48347.dart.weak.expect
new file mode 100644
index 0000000..555e190
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48347.dart.weak.expect
@@ -0,0 +1,11 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:async" as asy;
+
+import "dart:async";
+
+static method test(asy::StreamController<void> _eventStreamController) → dynamic async {
+ await for (final void _ in _eventStreamController.{asy::StreamController::stream}{asy::Stream<void>}) {
+ }
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue48347.dart.weak.modular.expect b/pkg/front_end/testcases/general/issue48347.dart.weak.modular.expect
new file mode 100644
index 0000000..555e190
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48347.dart.weak.modular.expect
@@ -0,0 +1,11 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:async" as asy;
+
+import "dart:async";
+
+static method test(asy::StreamController<void> _eventStreamController) → dynamic async {
+ await for (final void _ in _eventStreamController.{asy::StreamController::stream}{asy::Stream<void>}) {
+ }
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue48347.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue48347.dart.weak.outline.expect
new file mode 100644
index 0000000..3f670be
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48347.dart.weak.outline.expect
@@ -0,0 +1,10 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:async" as asy;
+
+import "dart:async";
+
+static method test(asy::StreamController<void> _eventStreamController) → dynamic async
+ ;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/issue48347.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue48347.dart.weak.transformed.expect
new file mode 100644
index 0000000..b10bc16
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48347.dart.weak.transformed.expect
@@ -0,0 +1,59 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:async" as asy;
+import "dart:core" as core;
+import "dart:_internal" as _in;
+
+import "dart:async";
+
+static method test(asy::StreamController<void> _eventStreamController) → dynamic /* originally async */ {
+ final asy::_Future<dynamic> :async_future = new asy::_Future::•<dynamic>();
+ core::bool* :is_sync = false;
+ dynamic :return_value;
+ (dynamic) → dynamic :async_op_then;
+ (core::Object, core::StackTrace) → dynamic :async_op_error;
+ core::int :await_jump_var = 0;
+ dynamic :await_ctx_var;
+ dynamic :saved_try_context_var0;
+ dynamic :saved_try_context_var1;
+ dynamic :exception0;
+ dynamic :stack_trace0;
+ function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
+ try {
+ #L1:
+ {
+ {
+ asy::Stream<void> :stream = _eventStreamController.{asy::StreamController::stream}{asy::Stream<void>};
+ asy::_StreamIterator<void>? :for-iterator = new asy::_StreamIterator::•<void>(:stream);
+ try
+ #L2:
+ while (true) {
+ dynamic #t1 = asy::_asyncStarMoveNextHelper(:stream);
+ [yield] let dynamic #t2 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}, :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool>(:result)) {
+ final void _ = :for-iterator.{asy::_StreamIterator::current}{void};
+ {}
+ }
+ else
+ break #L2;
+ }
+ finally
+ if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<void>?} == null)) {
+ [yield] let dynamic #t3 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::cancel}(){() → asy::Future<dynamic>}, :async_op_then, :async_op_error, :async_op) in null;
+ :result;
+ }
+ }
+ }
+ asy::_completeWithNoFutureOnAsyncReturn(:async_future, :return_value, :is_sync);
+ return;
+ }
+ on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
+ asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+ }
+ :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+ :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+ :async_op(){() → dynamic};
+ :is_sync = true;
+ return :async_future;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/textual_outline.status b/pkg/front_end/testcases/textual_outline.status
index bb12aa2..f762981 100644
--- a/pkg/front_end/testcases/textual_outline.status
+++ b/pkg/front_end/testcases/textual_outline.status
@@ -35,6 +35,7 @@
enhanced_enums/instantiated_generic_enum_types: FormatterCrash
enhanced_enums/issue48084: FormatterCrash
enhanced_enums/issue48181: FormatterCrash
+enhanced_enums/issue48232: FormatterCrash
enhanced_enums/malformed_constructors: FormatterCrash
enhanced_enums/members: FormatterCrash
enhanced_enums/named_arguments: FormatterCrash
diff --git a/runtime/bin/run_vm_tests.cc b/runtime/bin/run_vm_tests.cc
index 58d16b6..994f542 100644
--- a/runtime/bin/run_vm_tests.cc
+++ b/runtime/bin/run_vm_tests.cc
@@ -373,20 +373,19 @@
TesterState::argv = dart_argv;
TesterState::argc = dart_argc;
- error = Dart::Init(
- dart::bin::vm_snapshot_data, dart::bin::vm_snapshot_instructions,
- /*create_group=*/CreateIsolateAndSetup,
- /*initialize_isolate=*/nullptr,
- /*shutdown_isolate=*/nullptr,
- /*cleanup_isolate=*/nullptr,
- /*cleanup_group=*/CleanupIsolateGroup,
- /*thread_start=*/nullptr,
- /*thread_exit=*/nullptr, dart::bin::DartUtils::OpenFile,
- dart::bin::DartUtils::ReadFile, dart::bin::DartUtils::WriteFile,
- dart::bin::DartUtils::CloseFile, /*entropy_source=*/nullptr,
- /*get_service_assets=*/nullptr, start_kernel_isolate,
- /*code_observer=*/nullptr, /*post_task=*/nullptr,
- /*post_task_data*/ nullptr);
+ Dart_InitializeParams init_params;
+ memset(&init_params, 0, sizeof(init_params));
+ init_params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION;
+ init_params.vm_snapshot_data = dart::bin::vm_snapshot_data;
+ init_params.vm_snapshot_instructions = dart::bin::vm_snapshot_instructions;
+ init_params.create_group = CreateIsolateAndSetup;
+ init_params.cleanup_group = CleanupIsolateGroup;
+ init_params.file_open = dart::bin::DartUtils::OpenFile;
+ init_params.file_read = dart::bin::DartUtils::ReadFile;
+ init_params.file_write = dart::bin::DartUtils::WriteFile;
+ init_params.file_close = dart::bin::DartUtils::CloseFile;
+ init_params.start_kernel_isolate = start_kernel_isolate;
+ error = Dart::Init(&init_params);
if (error != nullptr) {
Syslog::PrintErr("Failed to initialize VM: %s\n", error);
free(error);
diff --git a/runtime/bin/secure_socket_filter.cc b/runtime/bin/secure_socket_filter.cc
index efaa417..57c5829 100644
--- a/runtime/bin/secure_socket_filter.cc
+++ b/runtime/bin/secure_socket_filter.cc
@@ -728,6 +728,13 @@
if (SSL_LOG_DATA) {
Syslog::Print("SSL_read returned error %d\n", error);
}
+ switch (error) {
+ case SSL_ERROR_SYSCALL:
+ case SSL_ERROR_SSL:
+ return -1;
+ default:
+ break;
+ }
bytes_processed = 0;
}
}
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index e4e2869..ad53435 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -246,25 +246,7 @@
#endif // !defined(IS_SIMARM_X64)
}
-char* Dart::DartInit(const uint8_t* vm_isolate_snapshot,
- const uint8_t* instructions_snapshot,
- Dart_IsolateGroupCreateCallback create_group,
- Dart_InitializeIsolateCallback initialize_isolate,
- Dart_IsolateShutdownCallback shutdown,
- Dart_IsolateCleanupCallback cleanup,
- Dart_IsolateGroupCleanupCallback cleanup_group,
- Dart_ThreadStartCallback thread_start,
- Dart_ThreadExitCallback thread_exit,
- Dart_FileOpenCallback file_open,
- Dart_FileReadCallback file_read,
- Dart_FileWriteCallback file_write,
- Dart_FileCloseCallback file_close,
- Dart_EntropySource entropy_source,
- Dart_GetVMServiceAssetsArchive get_service_assets,
- bool start_kernel_isolate,
- Dart_CodeObserver* observer,
- Dart_PostTaskCallback post_task,
- void* post_task_data) {
+char* Dart::DartInit(const Dart_InitializeParams* params) {
CheckOffsets();
if (!Flags::Initialized()) {
@@ -275,8 +257,8 @@
}
const Snapshot* snapshot = nullptr;
- if (vm_isolate_snapshot != nullptr) {
- snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot);
+ if (params->vm_snapshot_data != nullptr) {
+ snapshot = Snapshot::SetupFromBuffer(params->vm_snapshot_data);
if (snapshot == nullptr) {
return Utils::StrDup("Invalid vm isolate snapshot seen");
}
@@ -296,16 +278,17 @@
UntaggedFrame::Init();
- set_thread_start_callback(thread_start);
- set_thread_exit_callback(thread_exit);
- SetFileCallbacks(file_open, file_read, file_write, file_close);
- set_entropy_source_callback(entropy_source);
- set_post_task_callback(post_task);
- set_post_task_data(post_task_data);
+ set_thread_start_callback(params->thread_start);
+ set_thread_exit_callback(params->thread_exit);
+ SetFileCallbacks(params->file_open, params->file_read, params->file_write,
+ params->file_close);
+ set_entropy_source_callback(params->entropy_source);
+ set_post_task_callback(params->post_task);
+ set_post_task_data(params->post_task_data);
OS::Init();
NOT_IN_PRODUCT(CodeObservers::Init());
- if (observer != nullptr) {
- NOT_IN_PRODUCT(CodeObservers::RegisterExternal(*observer));
+ if (params->code_observer != nullptr) {
+ NOT_IN_PRODUCT(CodeObservers::RegisterExternal(*params->code_observer));
}
start_time_micros_ = OS::GetCurrentMonotonicMicros();
VirtualMemory::Init();
@@ -364,8 +347,8 @@
// really an isolate itself - it acts more as a container for VM-global
// objects.
std::unique_ptr<IsolateGroupSource> source(new IsolateGroupSource(
- kVmIsolateName, kVmIsolateName, vm_isolate_snapshot,
- instructions_snapshot, nullptr, -1, api_flags));
+ kVmIsolateName, kVmIsolateName, params->vm_snapshot_data,
+ params->vm_snapshot_instructions, nullptr, -1, api_flags));
// ObjectStore should be created later, after null objects are initialized.
auto group = new IsolateGroup(std::move(source), /*embedder_data=*/nullptr,
/*object_store=*/nullptr, api_flags);
@@ -392,7 +375,7 @@
ArgumentsDescriptor::Init();
ICData::Init();
SubtypeTestCache::Init();
- if (vm_isolate_snapshot != NULL) {
+ if (params->vm_snapshot_data != nullptr) {
#if defined(SUPPORT_TIMELINE)
TimelineBeginEndScope tbes(Timeline::GetVMStream(), "ReadVMSnapshot");
#endif
@@ -405,7 +388,7 @@
return Utils::StrDup("JIT runtime cannot run a precompiled snapshot");
#endif
}
- if (instructions_snapshot == NULL) {
+ if (params->vm_snapshot_instructions == nullptr) {
return Utils::StrDup("Missing instructions snapshot");
}
} else if (Snapshot::IsFull(vm_snapshot_kind_)) {
@@ -426,7 +409,7 @@
} else {
return Utils::StrDup("Invalid vm isolate snapshot seen");
}
- FullSnapshotReader reader(snapshot, instructions_snapshot, T);
+ FullSnapshotReader reader(snapshot, params->vm_snapshot_instructions, T);
const Error& error = Error::Handle(reader.ReadVMSnapshot());
if (!error.IsNull()) {
// Must copy before leaving the zone.
@@ -496,15 +479,15 @@
Api::InitHandles();
Thread::ExitIsolate(); // Unregister the VM isolate from this thread.
- Isolate::SetCreateGroupCallback(create_group);
- Isolate::SetInitializeCallback_(initialize_isolate);
- Isolate::SetShutdownCallback(shutdown);
- Isolate::SetCleanupCallback(cleanup);
- Isolate::SetGroupCleanupCallback(cleanup_group);
+ Isolate::SetCreateGroupCallback(params->create_group);
+ Isolate::SetInitializeCallback_(params->initialize_isolate);
+ Isolate::SetShutdownCallback(params->shutdown_isolate);
+ Isolate::SetCleanupCallback(params->cleanup_isolate);
+ Isolate::SetGroupCleanupCallback(params->cleanup_group);
#ifndef PRODUCT
const bool support_service = true;
- Service::SetGetServiceAssetsCallback(get_service_assets);
+ Service::SetGetServiceAssetsCallback(params->get_service_assets);
#else
const bool support_service = false;
#endif
@@ -518,7 +501,7 @@
}
#ifndef DART_PRECOMPILED_RUNTIME
- if (start_kernel_isolate) {
+ if (params->start_kernel_isolate) {
KernelIsolate::InitializeState();
}
#endif // DART_PRECOMPILED_RUNTIME
@@ -526,37 +509,14 @@
return NULL;
}
-char* Dart::Init(const uint8_t* vm_isolate_snapshot,
- const uint8_t* instructions_snapshot,
- Dart_IsolateGroupCreateCallback create_group,
- Dart_InitializeIsolateCallback initialize_isolate,
- Dart_IsolateShutdownCallback shutdown,
- Dart_IsolateCleanupCallback cleanup,
- Dart_IsolateGroupCleanupCallback cleanup_group,
- Dart_ThreadStartCallback thread_start,
- Dart_ThreadExitCallback thread_exit,
- Dart_FileOpenCallback file_open,
- Dart_FileReadCallback file_read,
- Dart_FileWriteCallback file_write,
- Dart_FileCloseCallback file_close,
- Dart_EntropySource entropy_source,
- Dart_GetVMServiceAssetsArchive get_service_assets,
- bool start_kernel_isolate,
- Dart_CodeObserver* observer,
- Dart_PostTaskCallback post_task,
- void* post_task_data) {
+char* Dart::Init(const Dart_InitializeParams* params) {
if (!init_state_.SetInitializing()) {
return Utils::StrDup(
"Bad VM initialization state, "
"already initialized or "
"multiple threads initializing the VM.");
}
- char* retval =
- DartInit(vm_isolate_snapshot, instructions_snapshot, create_group,
- initialize_isolate, shutdown, cleanup, cleanup_group,
- thread_start, thread_exit, file_open, file_read, file_write,
- file_close, entropy_source, get_service_assets,
- start_kernel_isolate, observer, post_task, post_task_data);
+ char* retval = DartInit(params);
if (retval != NULL) {
init_state_.ResetInitializing();
return retval;
diff --git a/runtime/vm/dart.h b/runtime/vm/dart.h
index 5a170c2..9b88af1 100644
--- a/runtime/vm/dart.h
+++ b/runtime/vm/dart.h
@@ -29,25 +29,7 @@
public:
// Returns null if initialization succeeds, otherwise returns an error message
// (caller owns error message and has to free it).
- static char* Init(const uint8_t* vm_snapshot_data,
- const uint8_t* vm_snapshot_instructions,
- Dart_IsolateGroupCreateCallback create_group,
- Dart_InitializeIsolateCallback initialize_isolate,
- Dart_IsolateShutdownCallback shutdown,
- Dart_IsolateCleanupCallback cleanup,
- Dart_IsolateGroupCleanupCallback cleanup_group,
- Dart_ThreadStartCallback thread_start,
- Dart_ThreadExitCallback thread_exit,
- Dart_FileOpenCallback file_open,
- Dart_FileReadCallback file_read,
- Dart_FileWriteCallback file_write,
- Dart_FileCloseCallback file_close,
- Dart_EntropySource entropy_source,
- Dart_GetVMServiceAssetsArchive get_service_assets,
- bool start_kernel_isolate,
- Dart_CodeObserver* observer,
- Dart_PostTaskCallback post_task,
- void* post_task_data);
+ static char* Init(const Dart_InitializeParams* params);
// Returns null if cleanup succeeds, otherwise returns an error message
// (caller owns error message and has to free it).
@@ -176,25 +158,7 @@
static Dart_GCEventCallback gc_event_callback() { return gc_event_callback_; }
private:
- static char* DartInit(const uint8_t* vm_snapshot_data,
- const uint8_t* vm_snapshot_instructions,
- Dart_IsolateGroupCreateCallback create_group,
- Dart_InitializeIsolateCallback initialize_isolate,
- Dart_IsolateShutdownCallback shutdown,
- Dart_IsolateCleanupCallback cleanup,
- Dart_IsolateGroupCleanupCallback cleanup_group,
- Dart_ThreadStartCallback thread_start,
- Dart_ThreadExitCallback thread_exit,
- Dart_FileOpenCallback file_open,
- Dart_FileReadCallback file_read,
- Dart_FileWriteCallback file_write,
- Dart_FileCloseCallback file_close,
- Dart_EntropySource entropy_source,
- Dart_GetVMServiceAssetsArchive get_service_assets,
- bool start_kernel_isolate,
- Dart_CodeObserver* observer,
- Dart_PostTaskCallback post_task,
- void* post_task_data);
+ static char* DartInit(const Dart_InitializeParams* params);
static constexpr const char* kVmIsolateName = "vm-isolate";
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index b421ddc..d7d2208 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1204,15 +1204,7 @@
"Invalid Dart_InitializeParams version.");
}
- return Dart::Init(params->vm_snapshot_data, params->vm_snapshot_instructions,
- params->create_group, params->initialize_isolate,
- params->shutdown_isolate, params->cleanup_isolate,
- params->cleanup_group, params->thread_start,
- params->thread_exit, params->file_open, params->file_read,
- params->file_write, params->file_close,
- params->entropy_source, params->get_service_assets,
- params->start_kernel_isolate, params->code_observer,
- params->post_task, params->post_task_data);
+ return Dart::Init(params);
}
DART_EXPORT char* Dart_Cleanup() {
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
index 89c90d5..9c9e4b9 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
@@ -836,7 +836,7 @@
if (!savedLocals) {
// Record the field on first execution so we can reset it later if
// needed (hot restart).
- $_resetFields.push(() => {
+ $resetFields.push(() => {
init = initializer;
value = null;
savedLocals = false;
@@ -860,9 +860,17 @@
$desc.configurable = true;
if ($desc.set != null) {
$desc.set = function(x) {
+ if (!savedLocals) {
+ $resetFields.push(() => {
+ init = initializer;
+ value = null;
+ savedLocals = false;
+ initialized = false;
+ });
+ savedLocals = true;
+ }
init = null;
value = x;
- // savedLocals and initialized are dead since init is set to null
};
}
return ${defineProperty(to, name, desc)};
@@ -873,6 +881,9 @@
const initializer = $desc.get;
let init = initializer;
let value = null;
+ // Tracks if these local variables have been saved so they can be restored
+ // after a hot restart.
+ let savedLocals = false;
$desc.get = function() {
if (init == null) return value;
let f = init;
@@ -881,10 +892,14 @@
// On the first (non-cyclic) execution, record the field so we can reset it
// later if needed (hot restart).
- $_resetFields.push(() => {
- init = initializer;
- value = null;
- });
+ if (!savedLocals) {
+ $resetFields.push(() => {
+ init = initializer;
+ value = null;
+ savedLocals = false;
+ });
+ savedLocals = true;
+ }
// Try to evaluate the field, using try+catch to ensure we implement the
// correct Dart error semantics.
@@ -901,6 +916,14 @@
$desc.configurable = true;
if ($desc.set != null) {
$desc.set = function(x) {
+ if (!savedLocals) {
+ $resetFields.push(() => {
+ init = initializer;
+ value = null;
+ savedLocals = false;
+ });
+ savedLocals = true;
+ }
init = null;
value = x;
};
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart
index af599c3..8b677f1 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart
@@ -183,7 +183,7 @@
/// This is populated by [defineLazyField] and only contains fields that have
/// been initialized.
@notNull
-final List<void Function()> _resetFields = JS('', '[]');
+final List<void Function()> resetFields = JS('', '[]');
/// A counter to track each time [hotRestart] is invoked. This is used to ensure
/// that pending callbacks that were created on a previous iteration (e.g. a
@@ -199,8 +199,8 @@
void hotRestart() {
// TODO(sigmund): prevent DOM callbacks from firing.
hotRestartIteration++;
- for (var f in _resetFields) f();
- _resetFields.clear();
+ for (var f in resetFields) f();
+ resetFields.clear();
for (var m in _cacheMaps) JS('', '#.clear()', m);
_cacheMaps.clear();
JS('', '#.clear()', _nullComparisonSet);
diff --git a/tests/dartdevc/hot_restart_late_test.dart b/tests/dartdevc/hot_restart_late_test.dart
index ab37cbc..32a31d7 100644
--- a/tests/dartdevc/hot_restart_late_test.dart
+++ b/tests/dartdevc/hot_restart_late_test.dart
@@ -6,35 +6,120 @@
// Requirements=nnbd
-import 'package:expect/expect.dart';
-import 'dart:_runtime' as dart;
+import 'dart:_runtime' as dart show hotRestart, resetFields;
-late double l;
+import 'package:expect/expect.dart';
+
+late String noInitializer;
+late int withInitializer = 1;
class Lates {
- static late String s;
+ static late String noInitializer;
+ static late int withInitializer = 2;
+}
+
+class LatesGeneric<T> {
+ static late String noInitializer;
+ static late int withInitializer = 3;
}
main() {
- Expect.throws(() => Lates.s);
- Expect.throws(() => l);
- Lates.s = "set";
- l = 1.62;
- Expect.equals(Lates.s, "set");
- Expect.equals(l, 1.62);
+ // Read this static field first to avoid interference with other reset counts.
+ var weakNullSafety = hasUnsoundNullSafety;
+
+ // TODO(42495) `Expect.throws` contains the use of a const that triggers an
+ // extra field reset but consts are not correctly reset on hot restart so the
+ // extra reset only appears once. Perform an initial Expect.throws here to
+ // avoid confusion with the reset counts later.
+ Expect.throws(() => throw 'foo');
+
+ var resetFieldCount = dart.resetFields.length;
+
+ // Set uninitialized static late fields. Avoid calling getters for these
+ // statics to ensure they are reset even if they are never accessed.
+ noInitializer = 'set via setter';
+ Lates.noInitializer = 'Lates set via setter';
+ LatesGeneric.noInitializer = 'LatesGeneric set via setter';
+
+ // Initialized statics should contain their values.
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Lates.withInitializer);
+ Expect.equals(3, LatesGeneric.withInitializer);
+
+ // In weak null safety the late field lowering introduces a second static
+ // field that tracks if late field has been initialized thus doubling the
+ // number of expected resets.
+ //
+ // In sound null safety non-nullable fields don't require the extra static to
+ // track initialization because null is used as a sentinel value.
+ //
+ // Weak Null Safety - 12 total field resets
+ // - 3 isSet write/resets for uninitialized field writes.
+ // - 3 write/resets for the actual uninitialized field writes.
+ // - 3 isSet reads/resets for initialized field reads.
+ // - 3 reads/resets for the actual initialized field reads.
+ //
+ // Sound Null Safety - 6 total field resets:
+ // - 3 write/resets for the actual uninitialized field writes.
+ // - 3 reads/resets for the actual initialized field reads.
+ var expectedResets =
+ weakNullSafety ? resetFieldCount + 12 : resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
dart.hotRestart();
+ resetFieldCount = dart.resetFields.length;
- Expect.throws(() => Lates.s);
- Expect.throws(() => l);
- Lates.s = "set";
- Expect.equals(Lates.s, "set");
- l = 1.62;
- Expect.equals(l, 1.62);
+ // Late statics should throw on get when not initialized.
+ Expect.throws(() => noInitializer);
+ Expect.throws(() => Lates.noInitializer);
+ Expect.throws(() => LatesGeneric.noInitializer);
+
+ // Set uninitialized static late fields again.
+ noInitializer = 'set via setter';
+ Lates.noInitializer = 'Lates set via setter';
+ LatesGeneric.noInitializer = 'LatesGeneric set via setter';
+
+ // All statics should contain their set values.
+ Expect.equals('set via setter', noInitializer);
+ Expect.equals('Lates set via setter', Lates.noInitializer);
+ Expect.equals('LatesGeneric set via setter', LatesGeneric.noInitializer);
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Lates.withInitializer);
+ Expect.equals(3, LatesGeneric.withInitializer);
+
+ // Weak Null Safety - 12 total field resets
+ // - 3 isSet write/resets for uninitialized field writes.
+ // - 3 write/resets for the actual uninitialized field writes.
+ // - 3 isSet reads/resets for initialized field reads.
+ // - 3 reads/resets for the actual initialized field reads.
+ // Sound Null Safety - 6 total field resets:
+ // - 3 write/resets for the actual uninitialized field writes.
+ // - 3 reads/resets for the actual initialized field reads.
+ expectedResets = weakNullSafety ? resetFieldCount + 12 : resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
dart.hotRestart();
dart.hotRestart();
+ resetFieldCount = dart.resetFields.length;
- Expect.throws(() => Lates.s);
- Expect.throws(() => l);
+ // Late statics should throw on get when not initialized.
+ Expect.throws(() => noInitializer);
+ Expect.throws(() => Lates.noInitializer);
+ Expect.throws(() => LatesGeneric.noInitializer);
+
+ // Initialized statics should contain their values.
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Lates.withInitializer);
+ Expect.equals(3, LatesGeneric.withInitializer);
+
+ // Weak Null Safety - 9 total field resets:
+ // - 3 isSet reads/resets for uninitialized field reads.
+ // - 3 isSet reads/resets for initialized field reads.
+ // - 3 reads/resets for the actual initialized field reads.
+ //
+ // Sound Null Safety - 6 total field resets:
+ // - 3 reads/resets for actual uninitialized field reads.
+ // - 3 reads/resets for the actual initialized field reads.
+ expectedResets = weakNullSafety ? resetFieldCount + 9 : resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
}
diff --git a/tests/dartdevc/hot_restart_static_test.dart b/tests/dartdevc/hot_restart_static_test.dart
new file mode 100644
index 0000000..c26c298
--- /dev/null
+++ b/tests/dartdevc/hot_restart_static_test.dart
@@ -0,0 +1,84 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Tests that static fields are properly reset after hot restarts.
+
+// Requirements=nnbd
+
+import 'dart:_runtime' as dart show hotRestart, resetFields;
+
+import 'package:expect/expect.dart';
+
+String? noInitializer;
+int withInitializer = 1;
+
+class Statics {
+ static String? noInitializer;
+ static int withInitializer = 2;
+}
+
+class StaticsGeneric<T> {
+ static String? noInitializer;
+ static int withInitializer = 3;
+}
+
+main() {
+ var resetFieldCount = dart.resetFields.length;
+
+ // Set static fields without explicit initializers. Avoid calling getters for
+ // these statics to ensure they are reset even if they are never accessed.
+ noInitializer = 'set via setter';
+ Statics.noInitializer = 'Statics set via setter';
+ StaticsGeneric.noInitializer = 'StaticsGeneric set via setter';
+
+ // Initialized statics should contain their values.
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Statics.withInitializer);
+ Expect.equals(3, StaticsGeneric.withInitializer);
+
+ // Six new field resets from 3 setter calls and 3 getter calls.
+ var expectedResets = resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
+
+ dart.hotRestart();
+ resetFieldCount = dart.resetFields.length;
+
+ // Uninitialized statics have been reset to their implicit null initial state.
+ Expect.equals(null, noInitializer);
+ Expect.equals(null, Statics.noInitializer);
+ Expect.equals(null, StaticsGeneric.noInitializer);
+
+ noInitializer = 'set via setter';
+ Statics.noInitializer = 'Statics set via setter';
+ StaticsGeneric.noInitializer = 'StaticsGeneric set via setter';
+
+ // All statics should contain their set values.
+ Expect.equals('set via setter', noInitializer);
+ Expect.equals('Statics set via setter', Statics.noInitializer);
+ Expect.equals('StaticsGeneric set via setter', StaticsGeneric.noInitializer);
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Statics.withInitializer);
+ Expect.equals(3, StaticsGeneric.withInitializer);
+
+ // Six total new field resets despite getter and setter calls on the same
+ // static fields.
+ expectedResets = resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
+
+ dart.hotRestart();
+ dart.hotRestart();
+ resetFieldCount = dart.resetFields.length;
+
+ // All statics should contain their initial values.
+ Expect.equals(null, noInitializer);
+ Expect.equals(null, Statics.noInitializer);
+ Expect.equals(null, StaticsGeneric.noInitializer);
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Statics.withInitializer);
+ Expect.equals(3, StaticsGeneric.withInitializer);
+
+ // Six new field resets from 6 getter calls.
+ expectedResets = resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
+}
diff --git a/tests/dartdevc_2/hot_restart_static_test.dart b/tests/dartdevc_2/hot_restart_static_test.dart
new file mode 100644
index 0000000..73e93d1
--- /dev/null
+++ b/tests/dartdevc_2/hot_restart_static_test.dart
@@ -0,0 +1,84 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// @dart = 2.9
+
+// Tests that static fields are properly reset after hot restarts.
+
+import 'dart:_runtime' as dart show hotRestart, resetFields;
+
+import 'package:expect/expect.dart';
+
+String noInitializer;
+int withInitializer = 1;
+
+class Statics {
+ static String noInitializer;
+ static int withInitializer = 2;
+}
+
+class StaticsGeneric<T> {
+ static String noInitializer;
+ static int withInitializer = 3;
+}
+
+main() {
+ var resetFieldCount = dart.resetFields.length;
+
+ // Set static fields without explicit initializers. Avoid calling getters for
+ // these statics to ensure they are reset even if they are never accessed.
+ noInitializer = 'set via setter';
+ Statics.noInitializer = 'Statics set via setter';
+ StaticsGeneric.noInitializer = 'StaticsGeneric set via setter';
+
+ // Initialized statics should contain their values.
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Statics.withInitializer);
+ Expect.equals(3, StaticsGeneric.withInitializer);
+
+ // Six new field resets from 3 setter calls and 3 getter calls.
+ var expectedResets = resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
+
+ dart.hotRestart();
+ resetFieldCount = dart.resetFields.length;
+
+ // Uninitialized statics have been reset to their implicit null initial state.
+ Expect.equals(null, noInitializer);
+ Expect.equals(null, Statics.noInitializer);
+ Expect.equals(null, StaticsGeneric.noInitializer);
+
+ noInitializer = 'set via setter';
+ Statics.noInitializer = 'Statics set via setter';
+ StaticsGeneric.noInitializer = 'StaticsGeneric set via setter';
+
+ // All statics should contain their set values.
+ Expect.equals('set via setter', noInitializer);
+ Expect.equals('Statics set via setter', Statics.noInitializer);
+ Expect.equals('StaticsGeneric set via setter', StaticsGeneric.noInitializer);
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Statics.withInitializer);
+ Expect.equals(3, StaticsGeneric.withInitializer);
+
+ // Six total new field resets despite getter and setter calls on the same
+ // static fields.
+ expectedResets = resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
+
+ dart.hotRestart();
+ dart.hotRestart();
+ resetFieldCount = dart.resetFields.length;
+
+ // All statics should contain their initial values.
+ Expect.equals(null, noInitializer);
+ Expect.equals(null, Statics.noInitializer);
+ Expect.equals(null, StaticsGeneric.noInitializer);
+ Expect.equals(1, withInitializer);
+ Expect.equals(2, Statics.withInitializer);
+ Expect.equals(3, StaticsGeneric.withInitializer);
+
+ // Six new field resets from 6 getter calls.
+ expectedResets = resetFieldCount + 6;
+ Expect.equals(expectedResets, dart.resetFields.length);
+}
diff --git a/tests/standalone/io/raw_secure_socket_ssl_read_error_test.dart b/tests/standalone/io/raw_secure_socket_ssl_read_error_test.dart
new file mode 100644
index 0000000..251a748
--- /dev/null
+++ b/tests/standalone/io/raw_secure_socket_ssl_read_error_test.dart
@@ -0,0 +1,69 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// VMOptions=
+// VMOptions=--short_socket_read
+// VMOptions=--short_socket_write
+// VMOptions=--short_socket_read --short_socket_write
+// OtherResources=certificates/server_chain.pem
+// OtherResources=certificates/server_key.pem
+// OtherResources=certificates/trusted_certs.pem
+// OtherResources=certificates/untrusted_server_chain.pem
+// OtherResources=certificates/untrusted_server_key.pem
+
+import "dart:io";
+
+import "package:async_helper/async_helper.dart";
+import "package:expect/expect.dart";
+
+late InternetAddress HOST;
+String localFile(path) => Platform.script.resolve(path).toFilePath();
+
+SecurityContext serverContext = new SecurityContext()
+ ..useCertificateChain(localFile('certificates/server_chain.pem'))
+ ..usePrivateKey(localFile('certificates/server_key.pem'),
+ password: 'dartdart');
+
+SecurityContext clientContext = new SecurityContext()
+ ..setTrustedCertificates(localFile('certificates/trusted_certs.pem'));
+
+testSslReadError() async {
+ // This test provokes an error in the BoringSSL `SSL_read` function by
+ // sending unencrypted bytes through a secure connection.
+ // See https://github.com/dart-lang/sdk/issues/48311
+ final serverSocket = await RawServerSocket.bind(HOST, 0);
+ serverSocket.forEach((socket) async {
+ final secureSocket = await RawSecureSocket.secureServer(
+ socket, serverContext,
+ subscription: socket.listen((event) {}));
+ secureSocket.write([1, 2, 3]);
+ // Send content using the original unencrypted connection to provoke a
+ // TtsException in the client.
+ socket.write([1, 2, 3]);
+ secureSocket.close();
+ serverSocket.close();
+ });
+
+ final Socket clientSocket = await Socket.connect(HOST, serverSocket.port);
+ final secureClientSocket =
+ await SecureSocket.secure(clientSocket, context: clientContext);
+ secureClientSocket.listen((data) {
+ Expect.fail("expected TlsException");
+ }, onError: (err) {
+ Expect.isTrue(err is TlsException, "unexpected error: $err");
+ secureClientSocket.close();
+ clientSocket.close();
+ });
+}
+
+main() {
+ print("asyncStart main");
+ asyncStart();
+ InternetAddress.lookup("localhost").then((hosts) async {
+ HOST = hosts.first;
+ await testSslReadError();
+ print("asyncEnd main");
+ asyncEnd();
+ });
+}
diff --git a/tests/standalone_2/io/raw_secure_socket_ssl_read_error_test.dart b/tests/standalone_2/io/raw_secure_socket_ssl_read_error_test.dart
new file mode 100644
index 0000000..e91f9e2
--- /dev/null
+++ b/tests/standalone_2/io/raw_secure_socket_ssl_read_error_test.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// VMOptions=
+// VMOptions=--short_socket_read
+// VMOptions=--short_socket_write
+// VMOptions=--short_socket_read --short_socket_write
+// OtherResources=certificates/server_chain.pem
+// OtherResources=certificates/server_key.pem
+// OtherResources=certificates/trusted_certs.pem
+// OtherResources=certificates/untrusted_server_chain.pem
+// OtherResources=certificates/untrusted_server_key.pem
+
+// @dart = 2.9
+
+import "dart:io";
+
+import "package:async_helper/async_helper.dart";
+import "package:expect/expect.dart";
+
+InternetAddress HOST;
+String localFile(path) => Platform.script.resolve(path).toFilePath();
+
+SecurityContext serverContext = new SecurityContext()
+ ..useCertificateChain(localFile('certificates/server_chain.pem'))
+ ..usePrivateKey(localFile('certificates/server_key.pem'),
+ password: 'dartdart');
+
+SecurityContext clientContext = new SecurityContext()
+ ..setTrustedCertificates(localFile('certificates/trusted_certs.pem'));
+
+testSslReadError() async {
+ // This test provokes an error in the BoringSSL `SSL_read` function by
+ // sending unencrypted bytes through a secure connection.
+ // See https://github.com/dart-lang/sdk/issues/48311
+ final serverSocket = await RawServerSocket.bind(HOST, 0);
+ serverSocket.forEach((socket) async {
+ final secureSocket = await RawSecureSocket.secureServer(
+ socket, serverContext,
+ subscription: socket.listen((event) {}));
+ secureSocket.write([1, 2, 3]);
+ // Send content using the original unencrypted connection to provoke a
+ // TtsException in the client.
+ socket.write([1, 2, 3]);
+ secureSocket.close();
+ serverSocket.close();
+ });
+
+ final Socket clientSocket = await Socket.connect(HOST, serverSocket.port);
+ final secureClientSocket =
+ await SecureSocket.secure(clientSocket, context: clientContext);
+ secureClientSocket.listen((data) {
+ Expect.fail("expected TlsException");
+ }, onError: (err) {
+ Expect.isTrue(err is TlsException, "unexpected error: $err");
+ secureClientSocket.close();
+ clientSocket.close();
+ });
+}
+
+main() {
+ print("asyncStart main");
+ asyncStart();
+ InternetAddress.lookup("localhost").then((hosts) async {
+ HOST = hosts.first;
+ await testSslReadError();
+ print("asyncEnd main");
+ asyncEnd();
+ });
+}
diff --git a/tools/VERSION b/tools/VERSION
index d52241c..754897b 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 99
+PRERELEASE 100
PRERELEASE_PATCH 0
\ No newline at end of file