Version 1.23.0-dev.11.1
Cherry-pick 37330be1b9b631baa3d426c9484d5e9714ad1a9b to dev
Cherry-pick ad54733d46759c422f055119b689881a9c4922b7 to dev
Cherry-pick 4d4441a868d6d65f5579641b78d5f0d3f30b6867 to dev
Cherry-pick d9e7a366169a7513af17df5ef5769d708fc6c815 to dev
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b12aaa9..9d292a6b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,32 +4,43 @@
* Allow using URI strings in `part of` declarations to refer to the
importing library.
-### Core library changes
+#### Strong Mode
-* `dart:core`
- * Added `Uri.isScheme` function to check the scheme of a URI.
- Example: `uri.isScheme("http")`. Ignores case when comparing.
- * Make `UriData.parse` validate its input better.
- If the data is base-64 encoded, the data is normalized wrt.
- alphabet and padding, and it contains invalid base-64 data,
- parsing fails. Also normalizes non-base-64 data.
-* `dart:io`
- * Added functions `File.lastAccessed`, `File.lastAccessedSync`,
- `File.setLastModified`, `File.setLastModifiedSync`, `File.setLastAccessed`,
- and `File.setLastAccessedSync`.
- * Added `{Stdin,Stdout}.supportsAnsiEscapes`.
+* Breaking change - it is now a strong mode error if a mixin causes a name
+ conflict between two private members (field/getter/setter/method) from a
+ different library. (SDK
+ issue [28809](https://github.com/dart-lang/sdk/issues/28809)).
-### Dart VM
+lib1.dart:
-* Calls to `print()` and `Stdout.write*()` now correctly print unicode
- characters to the console on Windows. Calls to `Stdout.add*()` behave as
- before.
-### Strong Mode
+```dart
+class A {
+ int _x;
+}
-* Strong mode will prefer the expected type to infer generic types,
- functions, and methods
- (SDK issue [27586](https://github.com/dart-lang/sdk/issues/27586)).
+class B {
+ int _x;
+}
+```
+
+lib2.dart:
+
+
+```dart
+import 'lib1.dart';
+
+class C extends A with B {}
+```
+
+```
+ error • The private name _x, defined by B, conflicts with the same name defined by A at tmp/lib2.dart:3:24 • private_collision_in_mixin_application
+```
+
+
+* Breaking change - strong mode will prefer the expected type to infer generic
+ types, functions, and methods (SDK
+ issue [27586](https://github.com/dart-lang/sdk/issues/27586)).
```dart
main() {
@@ -75,6 +86,49 @@
}
```
+* Strong mode down cast composite warnings are no longer issued by default.
+ (SDK issue [28588](https://github.com/dart-lang/sdk/issues/28588)).
+
+```dart
+void test() {
+ List untyped = [];
+ List<int> typed = untyped; // No down cast composite warning
+}
+```
+
+To opt back into the warnings, add the following to
+the
+[.analysis_options](https://www.dartlang.org/guides/language/analysis-options)
+file for your project.
+
+```
+analyzer:
+ errors:
+ strong_mode_down_cast_composite: warning
+```
+
+
+### Core library changes
+
+* `dart:core`
+ * Added `Uri.isScheme` function to check the scheme of a URI.
+ Example: `uri.isScheme("http")`. Ignores case when comparing.
+ * Make `UriData.parse` validate its input better.
+ If the data is base-64 encoded, the data is normalized wrt.
+ alphabet and padding, and it contains invalid base-64 data,
+ parsing fails. Also normalizes non-base-64 data.
+* `dart:io`
+ * Added functions `File.lastAccessed`, `File.lastAccessedSync`,
+ `File.setLastModified`, `File.setLastModifiedSync`, `File.setLastAccessed`,
+ and `File.setLastAccessedSync`.
+ * Added `{Stdin,Stdout}.supportsAnsiEscapes`.
+
+### Dart VM
+
+* Calls to `print()` and `Stdout.write*()` now correctly print unicode
+ characters to the console on Windows. Calls to `Stdout.add*()` behave as
+ before.
+
### Tool changes
* Analysis
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 853cf84..b348a15 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -1329,10 +1329,26 @@
/**
* The pseudo-declaration that defines a generic function type.
+ *
+ * Clients may not extend, implement, or mix-in this class.
*/
abstract class GenericFunctionTypeElement implements FunctionTypedElement {}
/**
+ * A [FunctionTypeAliasElement] whose returned function type has a [type]
+ * parameter.
+ *
+ * Clients may not extend, implement, or mix-in this class.
+ */
+abstract class GenericTypeAliasElement implements FunctionTypeAliasElement {
+ /**
+ * Return the generic function type element representing the generic function
+ * type on the right side of the equals.
+ */
+ GenericFunctionTypeElement get function;
+}
+
+/**
* A combinator that causes some of the names in a namespace to be hidden when
* being imported.
*
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 7ce5826..ea9a428 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -5029,7 +5029,7 @@
*/
class GenericTypeAliasElementImpl extends ElementImpl
with TypeParameterizedElementMixin
- implements FunctionTypeAliasElement {
+ implements GenericTypeAliasElement {
/**
* The unlinked representation of the type in the summary.
*/
@@ -5097,10 +5097,7 @@
CompilationUnitElementImpl get enclosingUnit =>
_enclosingElement as CompilationUnitElementImpl;
- /**
- * Return the generic function type element representing the generic function
- * type on the right side of the equals.
- */
+ @override
GenericFunctionTypeElement get function {
if (_function == null && _unlinkedTypedef != null) {
DartType type = enclosingUnit.resynthesizerContext.resolveTypeRef(
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index f650d54..df5e5ee 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -4951,46 +4951,51 @@
"Type parameter bound types must be instantiated.",
"Try adding type arguments.");
+ /*
+ * TODO(brianwilkerson) Make the TOP_LEVEL_ error codes be errors rather than
+ * hints and then clean up the function _errorSeverity in
+ * test/src/task/strong/strong_test_helper.dart.
+ */
static const StrongModeCode TOP_LEVEL_CYCLE = const StrongModeCode(
- ErrorType.COMPILE_TIME_ERROR,
+ ErrorType.HINT,
'TOP_LEVEL_CYCLE',
"The type of '{0}' can't be inferred because it depends on itself through the cycle: {1}.",
"Try adding an explicit type to one or more of the variables in the cycle in order to break the cycle.");
static const StrongModeCode TOP_LEVEL_FUNCTION_LITERAL_BLOCK =
const StrongModeCode(
- ErrorType.COMPILE_TIME_ERROR,
+ ErrorType.HINT,
'TOP_LEVEL_FUNCTION_LITERAL_BLOCK',
"The type of the function literal can't be inferred because the literal has a block as its body.",
"Try adding an explicit type to the variable.");
static const StrongModeCode TOP_LEVEL_FUNCTION_LITERAL_PARAMETER =
const StrongModeCode(
- ErrorType.COMPILE_TIME_ERROR,
+ ErrorType.HINT,
'TOP_LEVEL_FUNCTION_LITERAL_PARAMETER',
"The type of '{0}' can't be inferred because the parameter '{1}' does not have an explicit type.",
"Try adding an explicit type to the parameter '{1}', or add an explicit type for '{0}'.");
static const StrongModeCode TOP_LEVEL_IDENTIFIER_NO_TYPE = const StrongModeCode(
- ErrorType.COMPILE_TIME_ERROR,
+ ErrorType.HINT,
'TOP_LEVEL_IDENTIFIER_NO_TYPE',
"The type of '{0}' can't be inferred because the type of '{1}' couldn't be inferred.",
"Try adding an explicit type to either the variable '{0}' or the variable '{1}'.");
static const StrongModeCode TOP_LEVEL_INSTANCE_GETTER = const StrongModeCode(
- ErrorType.COMPILE_TIME_ERROR,
+ ErrorType.HINT,
'TOP_LEVEL_INSTANCE_GETTER',
"The type of '{0}' can't be inferred because of the use of the instance getter '{1}'.",
"Try removing the use of the instance getter {1}, or add an explicit type for '{0}'.");
static const StrongModeCode TOP_LEVEL_TYPE_ARGUMENTS = const StrongModeCode(
- ErrorType.COMPILE_TIME_ERROR,
+ ErrorType.HINT,
'TOP_LEVEL_TYPE_ARGUMENTS',
"The type of '{0}' can't be inferred because type arguments were not given for '{1}'.",
"Try adding type arguments for '{1}', or add an explicit type for '{0}'.");
static const StrongModeCode TOP_LEVEL_UNSUPPORTED = const StrongModeCode(
- ErrorType.COMPILE_TIME_ERROR,
+ ErrorType.HINT,
'TOP_LEVEL_UNSUPPORTED',
"The type of '{0}' can't be inferred because {1} expressions aren't supported.",
"Try adding an explicit type for '{0}'.");
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart
index 463a5c2..91134c2 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -1047,7 +1047,13 @@
var severity =
(processor != null) ? processor.severity : errorCode.errorSeverity;
- if (severity == ErrorSeverity.ERROR) _failure = true;
+ if (severity == ErrorSeverity.ERROR) {
+ _failure = true;
+ }
+ if (errorCode.type == ErrorType.HINT &&
+ errorCode.name.startsWith('STRONG_MODE_TOP_LEVEL_')) {
+ severity = ErrorSeverity.ERROR;
+ }
if (severity != ErrorSeverity.INFO || _options.strongModeHints) {
int begin = node is AnnotatedNode
? node.firstTokenAfterCommentAndMetadata.offset
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart
index fd3bf9d..93ea7b3 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -2499,22 +2499,6 @@
verify([source]);
}
- test_strongMode_downCastCompositeNoHint() async {
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
- options.strongMode = true;
- options.strongModeHints = false;
- resetWith(options: options);
- Source source = addSource(r'''
-main() {
- List dynamicList = [ ];
- List<int> list = dynamicList;
- print(list);
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
test_strongMode_downCastCompositeHint() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.strongMode = true;
@@ -2531,6 +2515,22 @@
verify([source]);
}
+ test_strongMode_downCastCompositeNoHint() async {
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ options.strongMode = true;
+ options.strongModeHints = false;
+ resetWith(options: options);
+ Source source = addSource(r'''
+main() {
+ List dynamicList = [ ];
+ List<int> list = dynamicList;
+ print(list);
+}''');
+ await computeAnalysisResult(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
test_strongMode_downCastCompositeWarn() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
applyToAnalysisOptions(options, {
@@ -2554,6 +2554,20 @@
verify([source]);
}
+ test_strongMode_topLevelInstanceGetter() async {
+ resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
+ Source source = addSource(r'''
+class A {
+ int get g => 0;
+}
+var a = new A();
+var b = a.g;
+''');
+ await computeAnalysisResult(source);
+ assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+ verify([source]);
+ }
+
test_typeCheck_type_is_Null() async {
Source source = addSource(r'''
m(i) {
diff --git a/pkg/analyzer/test/src/task/strong/strong_test_helper.dart b/pkg/analyzer/test/src/task/strong/strong_test_helper.dart
index dddce07..77f38a3 100644
--- a/pkg/analyzer/test/src/task/strong/strong_test_helper.dart
+++ b/pkg/analyzer/test/src/task/strong/strong_test_helper.dart
@@ -67,6 +67,11 @@
ErrorSeverity _errorSeverity(
AnalysisOptions analysisOptions, AnalysisError error) {
+ // TODO(brianwilkerson) Remove the if when top-level inference is made an
+ // error again.
+ if (error.errorCode.name.startsWith('STRONG_MODE_TOP_LEVEL_')) {
+ return ErrorSeverity.ERROR;
+ }
return ErrorProcessor.getProcessor(analysisOptions, error)?.severity ??
error.errorCode.errorSeverity;
}
diff --git a/tests/corelib_strong/corelib_strong.status b/tests/corelib_strong/corelib_strong.status
index 5e5c511..04e0e1a 100644
--- a/tests/corelib_strong/corelib_strong.status
+++ b/tests/corelib_strong/corelib_strong.status
@@ -56,4 +56,4 @@
uri_query_test: Skip
[ $compiler == dart2analyzer && $strong ]
-error_stack_trace2_test: CompileTimeError
+# error_stack_trace2_test: CompileTimeError
diff --git a/tests/language_strong/language_strong.status b/tests/language_strong/language_strong.status
index 52448d8..03fe136 100644
--- a/tests/language_strong/language_strong.status
+++ b/tests/language_strong/language_strong.status
@@ -682,20 +682,20 @@
wrong_number_type_arguments_test: Skip
[ $compiler == dart2analyzer && $strong ]
-async_await_test/02: CompileTimeError # Issue 28823
-async_await_test/03: CompileTimeError # Issue 28823
-async_await_test/none: CompileTimeError # Issue 28823
-async_star_test/01: CompileTimeError # Issue 28823
-async_star_test/02: CompileTimeError # Issue 28823
-async_star_test/03: CompileTimeError # Issue 28823
-async_star_test/04: CompileTimeError # Issue 28823
-async_star_test/05: CompileTimeError # Issue 28823
-async_star_test/none: CompileTimeError # Issue 28823
+# async_await_test/02: CompileTimeError # Issue 28823
+# async_await_test/03: CompileTimeError # Issue 28823
+# async_await_test/none: CompileTimeError # Issue 28823
+# async_star_test/01: CompileTimeError # Issue 28823
+# async_star_test/02: CompileTimeError # Issue 28823
+# async_star_test/03: CompileTimeError # Issue 28823
+# async_star_test/04: CompileTimeError # Issue 28823
+# async_star_test/05: CompileTimeError # Issue 28823
+# async_star_test/none: CompileTimeError # Issue 28823
bit_operations_test/01: MissingStaticWarning # Issue 28823
bit_operations_test/02: MissingStaticWarning # Issue 28823
bit_operations_test/03: MissingStaticWarning # Issue 28823
bit_operations_test/04: MissingStaticWarning # Issue 28823
-closure_side_effect_test: CompileTimeError # Issue 28823
+# closure_side_effect_test: CompileTimeError # Issue 28823
constant_type_literal_test/01: MissingCompileTimeError # Issue 28823
field3a_negative_test: StaticWarning # Issue 28823
generic_methods_overriding_test/01: MissingCompileTimeError # Issue 29070
@@ -704,7 +704,7 @@
generic_methods_closure_test: CompileTimeError # Issue 29070
generic_methods_simple_is_expression_test: CompileTimeError # Issue 29070
generic_methods_local_variable_declaration_test: CompileTimeError # Issue 29070
-inferrer_constructor3_test: CompileTimeError
+# inferrer_constructor3_test: CompileTimeError
interface_inherit_field_test: StaticWarning # Issue 28823
internal_library_test/02: MissingStaticWarning # Issue 28823
main_not_a_function_test/01: MissingStaticWarning # Issue 28823
diff --git a/tests/lib_strong/lib_strong.status b/tests/lib_strong/lib_strong.status
index 8ada277..ea25758 100644
--- a/tests/lib_strong/lib_strong.status
+++ b/tests/lib_strong/lib_strong.status
@@ -138,6 +138,6 @@
html/custom/document_register_type_extensions_test: CompileTimeError # Issue 28969
html/custom/element_upgrade_test: CompileTimeError # Issue 28969
html/debugger_test: CompileTimeError # Issue 28969
-html/input_element_test: CompileTimeError
+# html/input_element_test: CompileTimeError
html/js_typed_interop_default_arg_test/default_value: MissingCompileTimeError # Issue 28969
mirrors/deferred_mirrors_metadata_test: StaticWarning # Issue 28969
diff --git a/tools/VERSION b/tools/VERSION
index fa7e810..4c6934a 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
MINOR 23
PATCH 0
PRERELEASE 11
-PRERELEASE_PATCH 0
+PRERELEASE_PATCH 1