Version 2.11.0-276.0.dev
Merge commit 'f506071e34f0d29b9028811d25a891bd7971de69' into 'dev'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2611829..36ad29f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,17 +31,6 @@
Updated the Linter to `0.1.121`, which includes:
-#### Pub
-
-* New commands `pub add` and `pub remove` that adds and remove new dependencies
- to your `pubspec.yaml`.
-* New option `pub outdated mode=null-safety` that will analyze your dependencies
- for null-safety.
-* `pub publish` will check your pubspec keys for likely typos.
-* `pub get` will print a warning if the resolution is mixed mode.
-
-# 0.1.121
-
* Performance improvements to `always_use_package_imports`,
`avoid_renaming_method_parameters`, `prefer_relative_imports` and
`public_member_api_docs`.
@@ -56,6 +45,17 @@
* Fixed `unawaited_futures` to handle `Future` subtypes.
* New lint: `avoid_type_to_string`.
+#### Pub
+
+* The top level `pub` executable has been deprecated. Use `dart pub` instead.
+* New commands `dart pub add` and `dart pub remove` that adds and removes new
+ dependencies to your `pubspec.yaml`.
+* New option `dart pub outdated mode=null-safety` that will analyze your
+ dependencies for null-safety.
+* `dart pub publish` will now check your pubspec keys for likely typos.
+* `pub get` will print a warning if the resolution is in mixed-mode requiring
+ the code to run with `dart --no-sound-null-safety`.
+
## 2.10.3 - 2020-10-29
This is a patch release that fixes the following issues:
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 2656b09..4e47272 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -1155,24 +1155,20 @@
/// A function type alias (`typedef`).
///
+/// This class models a type alias whose body specifies a function type, as
+/// is the only possible kind of type alias before the generalization that
+/// allows the body to be an arbitrary type.
+///
+/// This class will be deprecated and [TypeAliasElement] will replace it
+/// when non-function type aliases are enabled by default.
+///
/// Clients may not extend, implement or mix-in this class.
-abstract class FunctionTypeAliasElement
- implements TypeParameterizedElement, TypeDefiningElement {
- @override
- CompilationUnitElement get enclosingElement;
-
+abstract class FunctionTypeAliasElement implements TypeAliasElement {
/// Return the generic function type element representing the generic function
/// type on the right side of the equals.
GenericFunctionTypeElement get function;
- /// Produces the function type resulting from instantiating this typedef with
- /// the given [typeArguments] and [nullabilitySuffix].
- ///
- /// Note that this always instantiates the typedef itself, so for a
- /// [FunctionTypeAliasElement] the returned [FunctionType] might still be a
- /// generic function, with type formals. For example, if the typedef is:
- /// typedef F<T> = void Function<U>(T, U);
- /// then `F<int>` will produce `void Function<U>(int, U)`.
+ @override
FunctionType instantiate({
@required List<DartType> typeArguments,
@required NullabilitySuffix nullabilitySuffix,
@@ -1664,6 +1660,28 @@
bool get isExternal;
}
+/// A type alias (`typedef`).
+///
+/// Clients may not extend, implement or mix-in this class.
+abstract class TypeAliasElement
+ implements TypeParameterizedElement, TypeDefiningElement {
+ @override
+ CompilationUnitElement get enclosingElement;
+
+ /// Produces the type resulting from instantiating this typedef with the given
+ /// [typeArguments] and [nullabilitySuffix].
+ ///
+ /// Note that this always instantiates the typedef itself, so for a
+ /// [TypeAliasElement] the returned [DartType] might still be a generic
+ /// type, with type formals. For example, if the typedef is:
+ /// typedef F<T> = void Function<U>(T, U);
+ /// then `F<int>` will produce `void Function<U>(int, U)`.
+ DartType instantiate({
+ @required List<DartType> typeArguments,
+ @required NullabilitySuffix nullabilitySuffix,
+ });
+}
+
/// An element that defines a type.
///
/// Clients may not extend, implement or mix-in this class.
diff --git a/pkg/analyzer/lib/dart/element/type.dart b/pkg/analyzer/lib/dart/element/type.dart
index 326b7a8..e7c04af 100644
--- a/pkg/analyzer/lib/dart/element/type.dart
+++ b/pkg/analyzer/lib/dart/element/type.dart
@@ -29,6 +29,14 @@
///
/// Clients may not extend, implement or mix-in this class.
abstract class DartType {
+ /// If this type is an instantiation of a type alias, return the type
+ /// arguments used for the instantiation. Otherwise return `null`.
+ List<DartType> get aliasArguments;
+
+ /// If this type is an instantiation of a type alias, return it.
+ /// Otherwise return `null`.
+ TypeAliasElement get aliasElement;
+
/// Return the name of this type as it should appear when presented to users
/// in contexts such as error messages.
///
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index f0be482..20211b6 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -1602,12 +1602,18 @@
/// The abstract class `TypeImpl` implements the behavior common to objects
/// representing the declared type of elements in the element model.
abstract class TypeImpl implements DartType {
+ @override
+ final List<DartType> aliasArguments;
+
+ @override
+ final TypeAliasElement aliasElement;
+
/// The element representing the declaration of this type, or `null` if the
/// type has not, or cannot, be associated with an element.
final Element _element;
/// Initialize a newly created type to be declared by the given [element].
- TypeImpl(this._element);
+ TypeImpl(this._element, {this.aliasElement, this.aliasArguments});
@deprecated
@override
diff --git a/pkg/nnbd_migration/lib/migration_cli.dart b/pkg/nnbd_migration/lib/migration_cli.dart
index 7fc65a7..34e70b7 100644
--- a/pkg/nnbd_migration/lib/migration_cli.dart
+++ b/pkg/nnbd_migration/lib/migration_cli.dart
@@ -470,7 +470,14 @@
throw _BadArgException(
'Invalid value for --${CommandLineOptions.previewPortOption}');
}
- var webPreview = argResults[CommandLineOptions.webPreviewFlag] as bool;
+ bool webPreview;
+ if (argResults.wasParsed(CommandLineOptions.webPreviewFlag)) {
+ webPreview = argResults[CommandLineOptions.webPreviewFlag] as bool;
+ } else {
+ // If the `webPreviewFlag` wasn't explicitly passed, then the value of
+ // this option is based on the value of the [applyChanges] option.
+ webPreview = !applyChanges;
+ }
if (applyChanges && webPreview) {
throw _BadArgException('--apply-changes requires --no-web-preview');
}
diff --git a/pkg/nnbd_migration/test/migration_cli_test.dart b/pkg/nnbd_migration/test/migration_cli_test.dart
index 27af5aa..e27e23b 100644
--- a/pkg/nnbd_migration/test/migration_cli_test.dart
+++ b/pkg/nnbd_migration/test/migration_cli_test.dart
@@ -455,8 +455,8 @@
foo: 1
''');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -474,8 +474,8 @@
foo: 1
''');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -495,8 +495,8 @@
bar: 1
''');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -517,8 +517,8 @@
var projectContents =
simpleProject(analysisOptionsText: analysisOptionsText);
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -530,8 +530,8 @@
test_analysis_options_does_not_exist() async {
var projectContents = simpleProject();
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -552,8 +552,8 @@
var projectContents =
simpleProject(analysisOptionsText: analysisOptionsText);
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -570,8 +570,8 @@
var projectContents =
simpleProject(analysisOptionsText: analysisOptionsText);
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -589,8 +589,8 @@
var projectContents =
simpleProject(analysisOptionsText: analysisOptionsText);
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -611,8 +611,8 @@
var projectContents =
simpleProject(analysisOptionsText: analysisOptionsText);
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -629,8 +629,8 @@
name: test
''');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -648,8 +648,8 @@
test_analysis_options_is_not_a_map() async {
var projectContents = simpleProject(analysisOptionsText: 'not-a-map');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
expect(() async => await cliRunner.run(), throwsUnsupportedError);
}
@@ -702,6 +702,7 @@
test_flag_apply_changes_default() {
expect(assertParseArgsSuccess([]).applyChanges, isFalse);
+ expect(assertParseArgsSuccess([]).webPreview, isTrue);
}
test_flag_apply_changes_disable() async {
@@ -710,6 +711,12 @@
}
test_flag_apply_changes_enable() {
+ var options = assertParseArgsSuccess(['--apply-changes']);
+ expect(options.applyChanges, isTrue);
+ expect(options.webPreview, isFalse);
+ }
+
+ test_flag_apply_changes_enable_with_no_web_preview() {
expect(
assertParseArgsSuccess(['--no-web-preview', '--apply-changes'])
.applyChanges,
@@ -806,8 +813,7 @@
var projectContents = createProject();
var projectDir = createProjectDir(projectContents);
var cliRunner = _createCli(nullSafePackages: ['test'])
- .decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
assertNormalExit(cliRunner);
// Check that a summary was printed
@@ -828,8 +834,8 @@
var projectContents = simpleProject();
var projectDir = createProjectDir(projectContents);
var cli = _createCli();
- var cliRunner = cli.decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner =
+ cli.decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
bool applyHookCalled = false;
cli._onApplyHook = () {
expect(applyHookCalled, false);
@@ -1731,12 +1737,11 @@
if (dartVersionIsNullSafeByDefault) {
// The lack of a package config file means the test file is already opted
// in.
- await assertRunFailure(
- ['--no-web-preview', '--apply-changes', projectDir]);
+ await assertRunFailure(['--apply-changes', projectDir]);
_expectErrorIndicatingCodeIsAlreadyOptedIn();
} else {
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -1765,12 +1770,11 @@
if (dartVersionIsNullSafeByDefault) {
// An omitted languageVersion field means the code is opted in to null
// safety.
- await assertRunFailure(
- ['--no-web-preview', '--apply-changes', projectDir]);
+ await assertRunFailure(['--apply-changes', projectDir]);
_expectErrorIndicatingCodeIsAlreadyOptedIn();
} else {
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(projectDir,
@@ -1792,12 +1796,11 @@
if (dartVersionIsNullSafeByDefault) {
// An omitted entry in the package config means the code is opted in to null
// safety.
- await assertRunFailure(
- ['--no-web-preview', '--apply-changes', projectDir]);
+ await assertRunFailure(['--apply-changes', projectDir]);
_expectErrorIndicatingCodeIsAlreadyOptedIn();
} else {
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(projectDir,
@@ -1824,12 +1827,11 @@
if (dartVersionIsNullSafeByDefault) {
// An unreadable package config means the code is opted in to null safety.
- await assertRunFailure(
- ['--no-web-preview', '--apply-changes', projectDir]);
+ await assertRunFailure(['--apply-changes', projectDir]);
_expectErrorIndicatingCodeIsAlreadyOptedIn();
} else {
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(projectDir,
@@ -1968,8 +1970,8 @@
test_pubspec_does_not_exist() async {
var projectContents = simpleProject()..remove('pubspec.yaml');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -1988,8 +1990,8 @@
foo: 1
''');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -2008,8 +2010,8 @@
''';
var projectContents = simpleProject(pubspecText: pubspecText);
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -2024,8 +2026,8 @@
''';
var projectContents = simpleProject(pubspecText: pubspecText);
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(
@@ -2042,8 +2044,8 @@
name: test
''');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
await cliRunner.run();
// The Dart source code should still be migrated.
assertProjectContents(projectDir, simpleProject(migrated: true, pubspecText:
@@ -2059,8 +2061,8 @@
test_pubspec_is_not_a_map() async {
var projectContents = simpleProject(pubspecText: 'not-a-map');
var projectDir = createProjectDir(projectContents);
- var cliRunner = _createCli().decodeCommandLineArgs(
- _parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
+ var cliRunner = _createCli()
+ .decodeCommandLineArgs(_parseArgs(['--apply-changes', projectDir]));
expect(() async => await cliRunner.run(), throwsUnsupportedError);
}
diff --git a/tests/language/constants_2018/potential_const_dynamic_test.dart b/tests/language/constants_2018/potential_const_dynamic_test.dart
index 90de32f..63f031a 100644
--- a/tests/language/constants_2018/potential_const_dynamic_test.dart
+++ b/tests/language/constants_2018/potential_const_dynamic_test.dart
@@ -20,7 +20,7 @@
T.test10(c, c); //# sh3: ok
T.test11(c, c);
T.test12(c, c);
- T .test13(c, c);
+ T.test13(c, c);
T.test14(c);
T.test15(c, c);
T.test16(c, c);
@@ -73,4 +73,4 @@
dynamic operator <=(dynamic other) => this;
dynamic operator >=(dynamic other) => this;
dynamic get length => this;
-}
\ No newline at end of file
+}
diff --git a/tests/language/constants_2018/potential_const_test.dart b/tests/language/constants_2018/potential_const_test.dart
new file mode 100644
index 0000000..ad516a9
--- /dev/null
+++ b/tests/language/constants_2018/potential_const_test.dart
@@ -0,0 +1,100 @@
+// Copyright (c) 2019, 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 the correct places allows, and requires, potentially constant
+// expressions.
+
+bool get nonConst => true;
+
+class C {
+ final v;
+ const C(this.v);
+
+ // Redirecting generative constructor invocation parameters,
+ // must be potenentially constant.
+ const C.r1() : this(const C(null));
+
+ // Only evaluates the true branch when passed `true` as argument.
+ const C.r2(bool b) : this(b ? null : 1 ~/ 0);
+
+ const C.rn1() : this(nonConst);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ const C.rn2(bool b) : this(b ? null : nonConst);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ // Initializer list expressions must be potentially constant.
+ const C.g1() : v = const C(null);
+
+ const C.g2(bool b) : v = b ? null : 1 ~/ 0;
+
+ const C.gn3() : v = nonConst;
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ const C.gn4(bool b) : v = b ? null : nonConst;
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ // Constant constructor initializer list assert expressions
+ // must be potentially constant (and boolean).
+ const C.a1()
+ : assert(const C(null) != null),
+ v = null;
+
+ const C.a2(bool b)
+ : assert(b ? const C(null) != null : ((1 ~/ 0) as bool)),
+ v = null;
+
+ const C.an1()
+ : assert(nonConst),
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+ v = null;
+
+ const C.an2(bool b)
+ : assert(b ? true : nonConst),
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+ v = null;
+}
+
+main() {
+ var c = const C(null);
+ var cc = const C(C(null));
+
+ var r1 = const C.r1();
+ var r2 = const C.r2(true);
+
+ /// Const constructor invocation which would throw.
+ /**/ const C.r2(false);
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+ // ^^^^^^^^^^^
+ // [cfe] Constant evaluation error:
+
+ var g1 = const C.g1();
+ var g2 = const C.g2(true);
+ /**/ const C.g2(false);
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+ // ^^^^^^^^^^^
+ // [cfe] Constant evaluation error:
+
+ var a1 = const C.a1();
+ var a2 = const C.a2(true);
+ /**/ const C.a2(false);
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+ // ^^^^^^^^^^^
+ // [cfe] Constant evaluation error:
+}
diff --git a/tests/language/constants_2018/potential_const_type_test.dart b/tests/language/constants_2018/potential_const_type_test.dart
index 0f06507..e4a26ee 100644
--- a/tests/language/constants_2018/potential_const_type_test.dart
+++ b/tests/language/constants_2018/potential_const_type_test.dart
@@ -92,4 +92,4 @@
C operator <=(C other) => this;
C operator >=(C other) => this;
C get length => this;
-}
\ No newline at end of file
+}
diff --git a/tests/language/language.status b/tests/language/language.status
index 09e7d9e..65bbb77 100644
--- a/tests/language/language.status
+++ b/tests/language/language.status
@@ -2,11 +2,13 @@
# 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.
+[ $compiler == dart2analyzer ]
+nonfunction_type_aliases/*: Skip # github.com/dart-lang/language/issues/115
+
[ $compiler != dart2analyzer ]
switch/case_warn_test: Skip # Analyzer only, see language_analyzer2.status
[ $compiler != fasta ]
-nonfunction_type_aliases/*: Skip # github.com/dart-lang/language/issues/115
value_class/*: Skip # Internship, jlcontreras
[ $compiler == none ]
diff --git a/tests/language_2/constants_2018/potential_const_dynamic_test.dart b/tests/language_2/constants_2018/potential_const_dynamic_test.dart
index 90de32f..63f031a 100644
--- a/tests/language_2/constants_2018/potential_const_dynamic_test.dart
+++ b/tests/language_2/constants_2018/potential_const_dynamic_test.dart
@@ -20,7 +20,7 @@
T.test10(c, c); //# sh3: ok
T.test11(c, c);
T.test12(c, c);
- T .test13(c, c);
+ T.test13(c, c);
T.test14(c);
T.test15(c, c);
T.test16(c, c);
@@ -73,4 +73,4 @@
dynamic operator <=(dynamic other) => this;
dynamic operator >=(dynamic other) => this;
dynamic get length => this;
-}
\ No newline at end of file
+}
diff --git a/tests/language_2/constants_2018/potential_const_test.dart b/tests/language_2/constants_2018/potential_const_test.dart
new file mode 100644
index 0000000..ad516a9
--- /dev/null
+++ b/tests/language_2/constants_2018/potential_const_test.dart
@@ -0,0 +1,100 @@
+// Copyright (c) 2019, 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 the correct places allows, and requires, potentially constant
+// expressions.
+
+bool get nonConst => true;
+
+class C {
+ final v;
+ const C(this.v);
+
+ // Redirecting generative constructor invocation parameters,
+ // must be potenentially constant.
+ const C.r1() : this(const C(null));
+
+ // Only evaluates the true branch when passed `true` as argument.
+ const C.r2(bool b) : this(b ? null : 1 ~/ 0);
+
+ const C.rn1() : this(nonConst);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ const C.rn2(bool b) : this(b ? null : nonConst);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ // Initializer list expressions must be potentially constant.
+ const C.g1() : v = const C(null);
+
+ const C.g2(bool b) : v = b ? null : 1 ~/ 0;
+
+ const C.gn3() : v = nonConst;
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ const C.gn4(bool b) : v = b ? null : nonConst;
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+
+ // Constant constructor initializer list assert expressions
+ // must be potentially constant (and boolean).
+ const C.a1()
+ : assert(const C(null) != null),
+ v = null;
+
+ const C.a2(bool b)
+ : assert(b ? const C(null) != null : ((1 ~/ 0) as bool)),
+ v = null;
+
+ const C.an1()
+ : assert(nonConst),
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+ v = null;
+
+ const C.an2(bool b)
+ : assert(b ? true : nonConst),
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+ v = null;
+}
+
+main() {
+ var c = const C(null);
+ var cc = const C(C(null));
+
+ var r1 = const C.r1();
+ var r2 = const C.r2(true);
+
+ /// Const constructor invocation which would throw.
+ /**/ const C.r2(false);
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+ // ^^^^^^^^^^^
+ // [cfe] Constant evaluation error:
+
+ var g1 = const C.g1();
+ var g2 = const C.g2(true);
+ /**/ const C.g2(false);
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+ // ^^^^^^^^^^^
+ // [cfe] Constant evaluation error:
+
+ var a1 = const C.a1();
+ var a2 = const C.a2(true);
+ /**/ const C.a2(false);
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+ // ^^^^^^^^^^^
+ // [cfe] Constant evaluation error:
+}
diff --git a/tests/language_2/constants_2018/potential_const_type_test.dart b/tests/language_2/constants_2018/potential_const_type_test.dart
index 0f06507..e4a26ee 100644
--- a/tests/language_2/constants_2018/potential_const_type_test.dart
+++ b/tests/language_2/constants_2018/potential_const_type_test.dart
@@ -92,4 +92,4 @@
C operator <=(C other) => this;
C operator >=(C other) => this;
C get length => this;
-}
\ No newline at end of file
+}
diff --git a/tests/language_2/language_2.status b/tests/language_2/language_2.status
index 80846fb..c2b53ebb 100644
--- a/tests/language_2/language_2.status
+++ b/tests/language_2/language_2.status
@@ -2,12 +2,12 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
+[ $compiler == dart2analyzer ]
+nonfunction_type_aliases/*: Skip # github.com/dart-lang/language/issues/115
+
[ $compiler != dart2analyzer ]
switch/case_warn_test: Skip # Analyzer only, see language_analyzer2.status
-[ $compiler != fasta ]
-nonfunction_type_aliases/*: Skip # github.com/dart-lang/language/issues/115
-
[ $compiler == none ]
invalid_returns/*: Skip # https://github.com/dart-lang/sdk/issues/34013
void/*: Skip # https://github.com/dart-lang/sdk/issues/34013
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_class_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_class_test.dart
index 33ec568..5ed9e00 100644
--- a/tests/language_2/nonfunction_type_aliases/generic_usage_class_test.dart
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_class_test.dart
@@ -54,7 +54,7 @@
X foo<X>(X x) => x;
-T<Type> Function(T<Type>) id;
+T<Object> Function(T<Object>) id = (x) => x;
main() {
var v8 = <T<C>>[];
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_test.dart
index f812ca2..c1208a5 100644
--- a/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_test.dart
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_test.dart
@@ -44,7 +44,7 @@
X foo<X>(X x) => x;
-T<Type> Function(T<Type>) id;
+T<Object> Function(T<Object>) id = (x) => x;
main() {
var v8 = <T<C>>[];
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_function_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_function_test.dart
index 20049ea..33bac17 100644
--- a/tests/language_2/nonfunction_type_aliases/generic_usage_function_test.dart
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_function_test.dart
@@ -48,10 +48,6 @@
T<dynamic> foo(T<dynamic> t) => t;
}
-X foo<X>(X x) => x;
-
-T<Type> Function(T<Type>) id;
-
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_test.dart
index 8b9f4e1..a81fad2 100644
--- a/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_test.dart
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_test.dart
@@ -43,9 +43,7 @@
T<dynamic> foo(T<dynamic> t) => t;
}
-X foo<X>(X x) => x;
-
-T<Type> Function(T<Type>) id;
+T<Object> Function(T<Object>) id = (x) => x;
main() {
var v8 = <T<C>>[];
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_null_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_null_test.dart
index 48e8721..6101801 100644
--- a/tests/language_2/nonfunction_type_aliases/generic_usage_null_test.dart
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_null_test.dart
@@ -43,9 +43,7 @@
T<dynamic> foo(T<dynamic> t) => t;
}
-X foo<X>(X x) => x;
-
-T<Type> Function(T<Type>) id;
+T<Object> Function(T<Object>) id = (x) => x;
main() {
var v8 = <T<C>>[];
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_object_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_object_test.dart
index 71a3461..f6f9b24 100644
--- a/tests/language_2/nonfunction_type_aliases/generic_usage_object_test.dart
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_object_test.dart
@@ -47,10 +47,10 @@
T<dynamic> foo(T<dynamic> t) => t;
}
-T<Type> Function(T<Type>) id;
-
X foo<X>(X x) => x;
+T<Object> Function(T<Object>) id = (x) => x;
+
main() {
var v8 = <T<C>>[];
var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
@@ -60,4 +60,5 @@
v10 = v11;
T<Null>();
T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_void_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_void_test.dart
index c867206..6456366 100644
--- a/tests/language_2/nonfunction_type_aliases/generic_usage_void_test.dart
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_void_test.dart
@@ -43,9 +43,7 @@
T<dynamic> foo(T<dynamic> t) => t;
}
-X foo<X>(X x) => x;
-
-T<Type> Function(T<Type>) id;
+T<Object> Function(T<Object>) id = (x) => x;
main() {
var v8 = <T<C>>[];
diff --git a/tools/VERSION b/tools/VERSION
index d9154c3..e61b6da 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 11
PATCH 0
-PRERELEASE 275
+PRERELEASE 276
PRERELEASE_PATCH 0
\ No newline at end of file