diff --git a/analysis_options.yaml b/analysis_options.yaml
index 51ab358a96..a41a74dafd 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -14,8 +14,21 @@ analyzer:
- 'lib/src/third_party/pkg/**'
- 'lib/templates/*.html'
- 'pub.dartlang.org/**'
- - 'testing/**'
+ # These have a lot of lint.
+ - 'testing/test_package/**'
+ - 'testing/test_package_custom_templates/**'
+ - 'testing/test_package_experiments/**'
+ - 'testing/test_package_export_error/**'
+ - 'testing/test_package_extensions/**'
+ - 'testing/test_package_import_export_error/**'
+ - 'testing/test_package_imported/**'
+ - 'testing/test_package_options/**'
+ # This package imports flutter, which is perhaps not found by the base `dart analyze` tool.
- 'testing/flutter_packages/test_package_flutter_plugin/**'
+ # This package is meant to mock the sky_engine package.
+ - 'testing/sky_engine/**'
+ # These packages have compile-time errors.
+ - 'testing/test_package_bad/**'
- 'testing/test_package_export_error/**'
linter:
rules:
diff --git a/analysis_options_presubmit.yaml b/analysis_options_presubmit.yaml
index 8b33a961ff..d8a57b0241 100644
--- a/analysis_options_presubmit.yaml
+++ b/analysis_options_presubmit.yaml
@@ -19,9 +19,21 @@ analyzer:
- 'lib/src/third_party/pkg/**'
- 'lib/templates/*.html'
- 'pub.dartlang.org/**'
- - 'testing/**'
- - 'testing/flutter_packages/test_package_flutter_plugin/**'
+ # These have a lot of lint.
+ - 'testing/test_package/**'
+ - 'testing/test_package_custom_templates/**'
+ - 'testing/test_package_experiments/**'
- 'testing/test_package_export_error/**'
+ - 'testing/test_package_extensions/**'
+ - 'testing/test_package_import_export_error/**'
+ - 'testing/test_package_imported/**'
+ - 'testing/test_package_options/**'
+ # This package imports flutter, which is perhaps not found by the base `dart analyze` tool.
+ - 'testing/flutter_packages/test_package_flutter_plugin/**'
+ # This package is meant to mock the sky_engine package.
+ - 'testing/sky_engine/**'
+ # These packages have compile-time errors.
+ - 'testing/test_package_bad/**'
linter:
rules:
- always_declare_return_types
diff --git a/test/end2end/model_test.dart b/test/end2end/model_test.dart
index 8a41f48592..9f79076529 100644
--- a/test/end2end/model_test.dart
+++ b/test/end2end/model_test.dart
@@ -936,7 +936,9 @@ void main() {
});
test('does not have a null safety label if not null safe', () {
- expect(exLibrary.isNullSafety, isFalse);
+ var optOutLibrary = packageGraph.libraries
+ .firstWhere((lib) => lib.name == 'opt_out_of_nnbd');
+ expect(optOutLibrary.isNullSafety, isFalse);
});
test('has a line number and column', () {
@@ -3381,7 +3383,7 @@ void main() {
expect(
thisIsFutureOrT.modelType.returnType.linkedName,
equals(
- 'FutureOr<T>'));
+ 'FutureOr<T>?'));
});
test('function with a parameter having type FutureOr', () {
@@ -3417,7 +3419,7 @@ void main() {
test('has source code', () {
expect(topLevelFunction.sourceCode, startsWith('@deprecated'));
expect(topLevelFunction.sourceCode, endsWith('''
-String topLevelFunction(int param1, bool param2, Cool coolBeans,
+String? topLevelFunction(int param1, bool param2, Cool coolBeans,
[double optionalPositional = 0.0]) {
return null;
}'''));
@@ -3486,15 +3488,19 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
test('parameterized type from field is correctly displayed', () {
var aField = TemplatedInterface.instanceFields
.singleWhere((f) => f.name == 'aField');
- expect(aField.modelType.linkedName,
- 'AnotherParameterizedClass<Stream<List<int>>>');
+ expect(
+ aField.modelType.linkedName,
+ 'AnotherParameterizedClass'
+ '<Stream<List<int>>>?');
});
test('parameterized type from inherited field is correctly displayed', () {
var aInheritedField = TemplatedInterface.inheritedFields
.singleWhere((f) => f.name == 'aInheritedField');
- expect(aInheritedField.modelType.linkedName,
- 'AnotherParameterizedClass<List<int>>');
+ expect(
+ aInheritedField.modelType.linkedName,
+ 'AnotherParameterizedClass'
+ '<List<int>>?');
});
test(
@@ -3751,7 +3757,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
test('method source code indents correctly', () {
expect(convertToMap.sourceCode,
- 'Map<X, Y> convertToMap() => null;');
+ 'Map<X, Y>? convertToMap() => null;');
});
});
@@ -4283,7 +4289,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
expect(
genericTypedefCombo.modelType.linkedName,
equals(
- 'NewGenericTypedef'));
+ 'NewGenericTypedef?'));
});
test('Verify that final and late show up (or not) appropriately', () {
@@ -4323,7 +4329,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
expect(
complicatedReturn.modelType.linkedName,
equals(
- 'ATypeTakingClass<String Function(int)>'));
+ 'ATypeTakingClass'
+ '<String Function(int)>?'));
});
test('@nodoc on simple property works', () {
@@ -4878,7 +4885,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
test('param with annotations', () {
var method =
- fakeLibrary.functions.firstWhere((f) => f.name == 'paintImage1');
+ fakeLibrary.functions.firstWhere((f) => f.name == 'paintImage2');
var params =
ParameterRendererHtml().renderLinkedParams(method.parameters);
expect(
@@ -5104,16 +5111,18 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
});
test('Property fields are terminated with semicolon', () {
- expect(finalProperty.sourceCode.trim(), endsWith('List<int>();'));
- expect(simpleProperty.sourceCode.trim(), endsWith('List<int>();'));
+ expect(finalProperty.sourceCode.trim(),
+ endsWith('List<int>.filled(1, 1);'));
+ expect(simpleProperty.sourceCode.trim(),
+ endsWith('List<int>.filled(1, 1);'));
expect(forInheriting.sourceCode.trim(), endsWith('forInheriting;'));
});
test('Arrow accessors are terminated with semicolon', () {
expect(explicitGetterImplicitSetter.getter.sourceCode.trim(),
- endsWith('List<int>();'));
+ endsWith('List<int>.filled(1, 1);'));
expect(explicitGetterSetter.getter.sourceCode.trim(),
- endsWith('List<int>();'));
+ endsWith('List<int>.filled(1, 1);'));
});
test('Traditional accessors are not terminated with semicolon', () {
@@ -5124,7 +5133,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
test('Whole declaration is visible when declaration spans many lines', () {
expect(ensureWholeDeclarationIsVisible.sourceCode,
- contains('List<int> '));
+ contains('List<int>? '));
});
});
diff --git a/testing/test_package/bin/drill.dart b/testing/test_package/bin/drill.dart
index a05daee47c..8217cbfa44 100644
--- a/testing/test_package/bin/drill.dart
+++ b/testing/test_package/bin/drill.dart
@@ -2,8 +2,6 @@
// 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
-
// This is a sample "tool" used to test external tool integration into dartdoc.
// It has no practical purpose other than that.
diff --git a/testing/test_package/bin/print_macro.dart b/testing/test_package/bin/print_macro.dart
index 4d5dd754f8..9b4cd5c9d1 100644
--- a/testing/test_package/bin/print_macro.dart
+++ b/testing/test_package/bin/print_macro.dart
@@ -2,8 +2,6 @@
// 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
-
// This is a sample "tool" used to test external tool integration into dartdoc.
// It has no other purpose.
diff --git a/testing/test_package/bin/setup.dart b/testing/test_package/bin/setup.dart
index d7e5619c21..a04713df33 100644
--- a/testing/test_package/bin/setup.dart
+++ b/testing/test_package/bin/setup.dart
@@ -2,8 +2,6 @@
// 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
-
// This is a sample setup "tool" used to test external tool integration into
// dartdoc. It has no practical purpose other than that.
diff --git a/testing/test_package/lib/anonymous_library.dart b/testing/test_package/lib/anonymous_library.dart
index 4312679443..bf450a8392 100644
--- a/testing/test_package/lib/anonymous_library.dart
+++ b/testing/test_package/lib/anonymous_library.dart
@@ -1,5 +1,3 @@
// DO NOT give this library a name
-// @dart=2.9
-
String doesStuff() => 'hi';
diff --git a/testing/test_package/lib/another_anonymous_lib.dart b/testing/test_package/lib/another_anonymous_lib.dart
index 94f1d0cbfc..9c52189194 100644
--- a/testing/test_package/lib/another_anonymous_lib.dart
+++ b/testing/test_package/lib/another_anonymous_lib.dart
@@ -1,5 +1,3 @@
// DO NOT give this library a name
-// @dart=2.9
-
String greeting() => "Hello";
diff --git a/testing/test_package/lib/base_class.dart b/testing/test_package/lib/base_class.dart
index 8913dd5b09..d35825e83e 100644
--- a/testing/test_package/lib/base_class.dart
+++ b/testing/test_package/lib/base_class.dart
@@ -1,5 +1,3 @@
-// @dart=2.9
-
library base_class;
/// Abstract class Constraints
diff --git a/testing/test_package/lib/code_in_comments.dart b/testing/test_package/lib/code_in_comments.dart
index 4a6831af4a..f82cf1b34d 100644
--- a/testing/test_package/lib/code_in_comments.dart
+++ b/testing/test_package/lib/code_in_comments.dart
@@ -11,6 +11,4 @@
/// - 3.14
/// ```
-// @dart=2.9
-
library code_in_comments;
diff --git a/testing/test_package/lib/completely_empty_lib.dart b/testing/test_package/lib/completely_empty_lib.dart
index fdc4933219..8b13789179 100644
--- a/testing/test_package/lib/completely_empty_lib.dart
+++ b/testing/test_package/lib/completely_empty_lib.dart
@@ -1 +1 @@
-// @dart=2.9
+
diff --git a/testing/test_package/lib/css.dart b/testing/test_package/lib/css.dart
index 8aef383f2f..abe9048d39 100644
--- a/testing/test_package/lib/css.dart
+++ b/testing/test_package/lib/css.dart
@@ -2,8 +2,6 @@
/// with directories created by dartdoc.
/// {@category Other}
-// @dart=2.9
-
library css;
String theOnlyThingInTheLibrary = 'hello';
diff --git a/testing/test_package/lib/csspub.dart b/testing/test_package/lib/csspub.dart
index 0c142ff522..ce018e93a3 100644
--- a/testing/test_package/lib/csspub.dart
+++ b/testing/test_package/lib/csspub.dart
@@ -1,5 +1,3 @@
-// @dart=2.9
-
library csspub;
String theOnlyThingInTheLibrary = 'hello';
diff --git a/testing/test_package/lib/example.dart b/testing/test_package/lib/example.dart
index 7d6a25afcd..fe205248cb 100644
--- a/testing/test_package/lib/example.dart
+++ b/testing/test_package/lib/example.dart
@@ -1,8 +1,6 @@
/// a library. testing string escaping: `var s = 'a string'`
/// {@category Real Libraries}
-// @dart=2.9
-
library ex;
import 'dart:async';
@@ -65,12 +63,12 @@ const List PRETTY_COLORS = const [
'blue'
];
@deprecated
-int deprecatedField;
+int deprecatedField = 1;
-double number;
+double number = 0.5;
@deprecated
-int get deprecatedGetter => null;
+int? get deprecatedGetter => null;
@deprecated
void set deprecatedSetter(int value) {}
@@ -91,7 +89,7 @@ typedef String ParameterizedTypedef(T msg, int foo);
abstract class ParameterizedClass {
AnotherParameterizedClass aInheritedMethod(int foo);
ParameterizedTypedef aInheritedTypedefReturningMethod();
- AnotherParameterizedClass aInheritedField;
+ AnotherParameterizedClass? aInheritedField;
AnotherParameterizedClass get aInheritedGetter;
ParameterizedClass operator +(ParameterizedClass other);
set aInheritedSetter(AnotherParameterizedClass thingToSet);
@@ -103,7 +101,7 @@ class AnotherParameterizedClass {}
abstract class TemplatedInterface implements ParameterizedClass> {
AnotherParameterizedClass> aMethodInterface(A value);
ParameterizedTypedef> aTypedefReturningMethodInterface();
- AnotherParameterizedClass>> aField;
+ AnotherParameterizedClass>>? aField;
AnotherParameterizedClass