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>> get aGetter; set aSetter(AnotherParameterizedClass> thingToSet); } @@ -148,13 +146,13 @@ enum Animal { class Apple { static const int n = 5; static String string = 'hello'; - String _s2; + String? _s2; /// The read-write field `m`. int m = 0; /// no docs - int notDocumented; + int? notDocumented; ///Constructor Apple(); @@ -171,12 +169,12 @@ class Apple { /** * The getter for `s` */ - String get s => _s2; + String? get s => _s2; /** * The setter for `s` */ - void set s(String something) { + void set s(String? something) { _s2 = something; } @@ -200,7 +198,7 @@ class Apple { void paramFromExportLib(Helper helper) {} - void printMsg(String msg, [bool linebreak]) {} + void printMsg(String msg, [bool linebreak = false]) {} /** * fieldWithTypedef docs here @@ -240,12 +238,12 @@ class B extends Apple with Cat { * The default value is `false` (compression disabled). * To enable, set `autoCompress` to `true`. */ - bool autoCompress; + late bool autoCompress; /** * A list of Strings */ - List list; + List? list; @override bool get isImplemented => false; @@ -263,7 +261,7 @@ class B extends Apple with Cat { b * 2; } - void writeMsg(String msg, [String transformMsg(String origMsg, bool flag)]) { + void writeMsg(String msg, [String transformMsg(String origMsg, bool flag)?]) { // do nothing } @@ -278,7 +276,7 @@ class RefsWithQsAndBangs {} class FieldAndCtorWithSameName { FieldAndCtorWithSameName.named(); - int named; + int? named; } // Do NOT add a doc comment to C. Testing blank comments. @@ -307,10 +305,10 @@ class ConstantCat implements Cat { /// implements [Cat], [E] class Dog implements Cat, E { - String name; + String? name; @deprecated - int deprecatedField; + int? deprecatedField; final int aFinalField = 42; @@ -330,7 +328,7 @@ class Dog implements Cat, E { Dog.deprecatedCreate(this.name); @deprecated - int get deprecatedGetter => null; + int? get deprecatedGetter => null; @deprecated void set deprecatedSetter(int value) {} @@ -343,7 +341,7 @@ class Dog implements Cat, E { @override operator ==(other) => other is Dog && name == other.name; - Dog operator +(Dog other) => Dog()..name = name + other.name; + Dog operator +(Dog other) => Dog()..name = name! + other.name!; foo() async => 42; @@ -442,7 +440,7 @@ class Dog implements Cat, E { abstract class E {} class F extends Dog with _PrivateAbstractClass { - void methodWithGenericParam([List msgs]) {} + void methodWithGenericParam([List? msgs]) {} } class ForAnnotation { @@ -471,7 +469,7 @@ class Klass { /// A shadowed method @override - toString() {} + toString() => ''; /// A method with a custom annotation @aThingToDo('from', 'thing') @@ -482,7 +480,7 @@ class MyError extends Error {} class MyErrorImplements implements Error { @override - StackTrace get stackTrace => null; + StackTrace? get stackTrace => null; } class MyException implements Exception {} @@ -517,12 +515,12 @@ class SpecializedDuration extends Duration {} * class */ class unDocumented { - String s; + String? s; } /// @nodoc class unDocumented2 { - String s; + String? s; } abstract class _PrivateAbstractClass { @@ -615,7 +613,7 @@ extension AnExtension on WithGeneric { } class AnExtendableThing { - int aMember; + int? aMember; } extension SimpleStringExtension on AnExtendableThing { @@ -638,7 +636,7 @@ extension FancyList on List { List operator -() => this.reversed.toList(); List> split(int at) => >[this.sublist(0, at), this.sublist(at)]; - static List big() => List(1000000); + static List big() => List.filled(100, null); } extension SymDiff on Set { @@ -662,7 +660,7 @@ extension on Object { } extension StaticFieldExtension on Object { - static int aStatic; + static int? aStatic; } /// This class has nothing to do with [_Shhh], [FancyList], or [AnExtension.call], @@ -675,12 +673,12 @@ class ToolPrintingMacroWhichInjectsHtml { /// {@template html-macro} /// {@inject-html}
Title
{@end-inject-html} /// {@endtemplate} - int a; + int a = 1; /// Text. /// /// {@tool print_macro} /// Text for tool. /// {@end-tool} - int b; + int b = 2; } diff --git a/testing/test_package/lib/excluded.dart b/testing/test_package/lib/excluded.dart index 66d5cbd782..c04bd7cc6c 100644 --- a/testing/test_package/lib/excluded.dart +++ b/testing/test_package/lib/excluded.dart @@ -2,8 +2,6 @@ /// even though it is located in the lib folder by /// using the tag -// @dart=2.9 - library excluded; export 'example.dart' show Apple; diff --git a/testing/test_package/lib/fake.dart b/testing/test_package/lib/fake.dart index 02a7a3f956..c8124285e1 100644 --- a/testing/test_package/lib/fake.dart +++ b/testing/test_package/lib/fake.dart @@ -45,8 +45,6 @@ /// /// [pkg]: http://example.org -// @dart=2.9 - library fake; import 'dart:async'; @@ -88,7 +86,7 @@ abstract class ImplementingThingy implements BaseThingy {} abstract class BaseThingy { // ignore: public_member_api_docs ImplementingThingy get aImplementingThingy; - ImplementingThingy aImplementingThingyField; + ImplementingThingy? aImplementingThingyField; void aImplementingThingyMethod(ImplementingThingy parameter); } @@ -123,14 +121,14 @@ class ConstructorTester { class HasGenerics { HasGenerics(X x, Y y, Z z) {} - X returnX() => null; + X? returnX() => null; - Z returnZ() => null; + Z? returnZ() => null; - Z doStuff(String s, X x) => null; + Z? doStuff(String s, X x) => null; /// Converts itself to a map. - Map convertToMap() => null; + Map? convertToMap() => null; } /// Coderef to ambiguous parameter of function parameter should not crash us. @@ -138,8 +136,8 @@ class HasGenerics { /// /// Here is a coderef: [aThingParameter] void doAComplicatedThing(int x, - {void doSomething(int aThingParameter, String anotherThing), - void doSomethingElse(int aThingParameter, double somethingElse)}) {} + {void doSomething(int aThingParameter, String anotherThing)?, + void doSomethingElse(int aThingParameter, double somethingElse)?}) {} /// Bullet point documentation. /// @@ -202,8 +200,8 @@ dynamic get mustGetThis => null; Map mapWithDynamicKeys = {}; -Required useSomethingInAnotherPackage; -String useSomethingInTheSdk; +Required? useSomethingInAnotherPackage; +String? useSomethingInTheSdk; /// Useful for annotations. class Annotation { @@ -252,7 +250,7 @@ class AClassWithFancyProperties { /// } /// } /// ``` - String aProperty; + String? aProperty; } const _APrivateConstClass CUSTOM_CLASS_PRIVATE = const _APrivateConstClass(); @@ -302,10 +300,10 @@ typedef T GenericTypedef(T input); typedef NewGenericTypedef = List Function(T, int, bool); /// A top level variable with a generic typedef type. -NewGenericTypedef genericTypedefCombo; +NewGenericTypedef? genericTypedefCombo; /// A complicated type parameter to ATypeTakingClass. -ATypeTakingClass get complicatedReturn => null; +ATypeTakingClass? get complicatedReturn => null; /// Lots and lots of parameters. typedef int LotsAndLotsOfParameters(so, many, parameters, it, should, wrap, @@ -313,7 +311,7 @@ typedef int LotsAndLotsOfParameters(so, many, parameters, it, should, wrap, /// This class is cool! class Cool { - // ignore: missing_return + // ignore: body_might_complete_normally Cool returnCool() {} } @@ -361,71 +359,72 @@ class AClassUsingNewStyleMixin extends NotAMixin /// A generic class for testing type inference. class GenericClass { - T member; + T? member; /// Destined to be overridden by [ModifierClass]. - T overrideByModifierClass; + T? overrideByModifierClass; /// Destined to be overridden by [GenericMixin]. - T overrideByGenericMixin; + T? overrideByGenericMixin; /// Destined to be overridden by [ModifierClass] and [GenericMixin], both. - T overrideByBoth; + T? overrideByBoth; /// Destined to be overridden by everything. - T overrideByEverything; + T? overrideByEverything; } /// A class extending a generic class. class ModifierClass extends GenericClass { - T modifierMember; + T? modifierMember; @override - T overrideByModifierClass; + T? overrideByModifierClass; @override - T overrideByBoth; + T? overrideByBoth; @override - T overrideByEverything; + T? overrideByEverything; } /// A generic mixin that requires GenericClass as a superclass. mixin GenericMixin on GenericClass { - T mixinMember; + T? mixinMember; @override - T overrideByGenericMixin; + T? overrideByGenericMixin; @override - T overrideByBoth; + T? overrideByBoth; @override - T overrideByEverything; + T? overrideByEverything; } /// A class verifying type inference across new-style mixins. class TypeInferenceMixedIn extends ModifierClass with GenericMixin { @override - int overrideByEverything; + int? overrideByEverything; } -GenericMixin aMixinReturningFunction() => null; +GenericMixin? aMixinReturningFunction() => null; functionUsingMixinReturningFunction() { - GenericClass using = aMixinReturningFunction(); + // ignore: unused_local_variable + GenericClass? using = aMixinReturningFunction(); } /// A super class, with many powers. Link to [Apple] from another library. @deprecated class SuperAwesomeClass { /// In the super class. - List powers; + List? powers; /// In the super class. /// /// Another comment line. - void fly(int height, Cool superCool, {String msg}) { + void fly(int height, Cool superCool, {String? msg}) { // ignore: unused_local_variable, avoid_init_to_null var x = null; // ignore: unused_local_variable @@ -435,7 +434,7 @@ class SuperAwesomeClass { } } - SuperAwesomeClass operator -(other) { + SuperAwesomeClass? operator -(other) { return null; } } @@ -456,7 +455,12 @@ void aVoidParameter(Future p1) {} /// This class extends Future abstract class ExtendsFutureVoid extends Future { // ignore: missing_return - factory ExtendsFutureVoid(FutureOr computation()) {} + factory ExtendsFutureVoid(FutureOr computation()) => + _ExtendsFutureVoidImpl(); +} + +class _ExtendsFutureVoidImpl implements ExtendsFutureVoid { + dynamic noSuchMethod(Invocation _) => null; } /// This class implements Future @@ -465,7 +469,7 @@ abstract class ImplementsFutureVoid implements Future {} /// This class takes a type, and it might be void. class ATypeTakingClass { // ignore: missing_return - T aMethodMaybeReturningVoid() {} + T? aMethodMaybeReturningVoid() {} } class ABaseClass {} @@ -487,13 +491,13 @@ class MixedInImplementation with MixInImplementation {} /// they are correct. class ImplicitProperties { /// Docs for implicitGetterExplicitSetter from ImplicitProperties. - String implicitGetterExplicitSetter; + String? implicitGetterExplicitSetter; /// Docs for explicitGetterImplicitSetter from ImplicitProperties. - List explicitGetterImplicitSetter; + List? explicitGetterImplicitSetter; /// A simple property to inherit. - int forInheriting; + int? forInheriting; /// @nodoc for you String get explicitNonDocumentedGetter => "something"; @@ -508,7 +512,7 @@ class ImplicitProperties { set explicitPartiallyDocumentedField(double foo) {} /// @nodoc here, you should never see this - String documentedPartialFieldInSubclassOnly; + String? documentedPartialFieldInSubclassOnly; /// Explicit getter for inheriting. int get explicitGetterSetterForInheriting => 12; @@ -529,14 +533,14 @@ abstract class ClassWithUnusualProperties extends ImplicitProperties { @override /// Docs for setter of implicitGetterExplicitSetter. - set implicitGetterExplicitSetter(String x) {} + set implicitGetterExplicitSetter(String? x) {} @override /// Getter doc for explicitGetterImplicitSetter - List get explicitGetterImplicitSetter => List(); + List get explicitGetterImplicitSetter => List.filled(1, 1); - myCoolTypedef _aFunction; + myCoolTypedef? _aFunction; /// Since I have a different doc, I should be documented. @override @@ -544,12 +548,12 @@ abstract class ClassWithUnusualProperties extends ImplicitProperties { /// Getter doc for explicitGetterSetter. @Annotation('a Getter Annotation') - myCoolTypedef get explicitGetterSetter { + myCoolTypedef? get explicitGetterSetter { return _aFunction; } /// @nodoc for a simple hidden property. - String simpleHidden; + String? simpleHidden; /// @nodoc on setter set explicitNodocGetterSetter(String s) {} @@ -559,10 +563,10 @@ abstract class ClassWithUnusualProperties extends ImplicitProperties { /// This property is not synthetic, so it might reference [f] -- display it. @Annotation('a Setter Annotation') - set explicitGetterSetter(myCoolTypedef f) => _aFunction = f; + set explicitGetterSetter(myCoolTypedef? f) => _aFunction = f; /// This property only has a getter and no setter; no parameters to print. - myCoolTypedef get explicitGetter { + myCoolTypedef? get explicitGetter { return _aFunction; } @@ -572,7 +576,7 @@ abstract class ClassWithUnusualProperties extends ImplicitProperties { /// This property has some docs, too. final Set finalProperty = Set(); - Map implicitReadWrite; + Map? implicitReadWrite; /// Hey there, more things not to warn about: [f], [x], or [q]. String aMethod(Function f(Cool x, bool q)) { @@ -582,13 +586,13 @@ abstract class ClassWithUnusualProperties extends ImplicitProperties { class HtmlEscapableImplicitProperties { /// Docs for implicitGetterExplicitSetter from HtmlEscapableImplicitProperties. - List implicitGetterExplicitSetter; + List? implicitGetterExplicitSetter; /// Docs for explicitGetterImplicitSetter from HtmlEscapableImplicitProperties. - List explicitGetterImplicitSetter; + List? explicitGetterImplicitSetter; /// A simple property to inherit. - List forInheriting; + List? forInheriting; /// Explicit getter for inheriting. List get explicitGetterSetterForInheriting => [1, 2]; @@ -601,27 +605,27 @@ class HtmlEscapableProperties extends HtmlEscapableImplicitProperties { @override /// Docs for setter of implicitGetterExplicitSetter. - set implicitGetterExplicitSetter(List x) {} + set implicitGetterExplicitSetter(List? x) {} @override /// Getter doc for explicitGetterImplicitSetter - List get explicitGetterImplicitSetter => List(); + List get explicitGetterImplicitSetter => List.filled(1, 1); /// Getter doc for explicitGetterSetter. - List get explicitGetterSetter => List(); + List get explicitGetterSetter => List.filled(1, 1); /// Setter doc for explicitGetterSetter. set explicitGetterSetter(List aList) {} /// A final property. - final List finalProperty = List(); + final List finalProperty = List.filled(1, 1); /// A simple property. - List simpleProperty = List(); + List simpleProperty = List.filled(1, 1); /// A long multiple variable declaration. - List iAmALongLongLongLongLongLongLongLongLongName, + List? iAmALongLongLongLongLongLongLongLongLongName, ensureWholeDeclarationIsVisible; } @@ -638,7 +642,7 @@ class LongFirstLine extends SuperAwesomeClass static const int ANSWER = 42; /// An instance string property. Readable and writable. - String aStringProperty; + String? aStringProperty; /// A static int property. static int meaningOfLife = 42; @@ -665,7 +669,7 @@ class LongFirstLine extends SuperAwesomeClass int twoParams(String one, two) => 42; /// One dynamic param, two named optionals. - bool optionalParams(first, {second, int third}) => true; + bool optionalParams(first, {second, int? third}) => true; /// Dynamic getter. Readable only. get dynamicGetter => 'could be anything'; @@ -674,12 +678,12 @@ class LongFirstLine extends SuperAwesomeClass void set onlySetter(double d) {} /// Adds another one of these thingies. - LongFirstLine operator +(LongFirstLine other) { + LongFirstLine? operator +(LongFirstLine other) { return null; } /// Multiplies a thingies to this thingie and then returns a new thingie. - LongFirstLine operator *(LongFirstLine other) { + LongFirstLine? operator *(LongFirstLine other) { return null; } @@ -735,7 +739,7 @@ class Foo2 { } class OtherGenericsThing
{ - HasGenerics convert() => null; + HasGenerics? convert() => null; } /// Constant property. @@ -746,10 +750,10 @@ const double PI = 3.14159; final int meaningOfLife = 42; /// Simple property -String simpleProperty; +String? simpleProperty; /// Simple @nodoc property. -String simplePropertyHidden; +String? simplePropertyHidden; /// Setter docs should be shown. set getterSetterNodocGetter(int value) {} @@ -801,7 +805,7 @@ get dynamicGetter => 'i could be anything'; /// /// Thanks for using this function! @deprecated -String topLevelFunction(int param1, bool param2, Cool coolBeans, +String? topLevelFunction(int param1, bool param2, Cool coolBeans, [double optionalPositional = 0.0]) { return null; } @@ -815,7 +819,7 @@ void onlyPositionalWithNoDefaultNoType([@greatestAnnotation anything]) {} /// Top-level function with 1 param and 2 optional named params, 1 with a /// default value. -void soIntense(anything, {bool flag: true, int value}) {} +void soIntense(anything, {bool flag: true, int? value}) {} /// [FooBar] comes from another library. void paramFromAnotherLib(Apple thing) {} @@ -833,7 +837,7 @@ FutureOr thisIsFutureOr() => null; FutureOr thisIsFutureOrNull() => null; /// Explicitly return a `FutureOr`. -FutureOr thisIsFutureOrT() => null; +FutureOr? thisIsFutureOrT() => null; /// Has a parameter explicitly typed `FutureOr`. void paramOfFutureOrNull(FutureOr future) {} @@ -855,7 +859,7 @@ const greatestAnnotation = 'greatest'; /// This function has two parameters that are functions. /// /// Check out the [number] parameter. It's the first one. -String functionWithFunctionParameters(int number, void thing(one, two), +String? functionWithFunctionParameters(int number, void thing(one, two), String string, Future asyncThing(three, four, five, six, seven)) => null; @@ -880,7 +884,7 @@ class WithGetterAndSetter { /// Test that we can properly handle covariant member parameters. class CovariantMemberParams { - covariant int covariantField; + covariant int? covariantField; set covariantSetter(covariant int x) {} @@ -895,7 +899,7 @@ class HasGenericWithExtends {} class SpecialList extends ListBase { // ignore: annotate_overrides E operator [](int index) { - return null; + return first; } // ignore: annotate_overrides @@ -966,7 +970,7 @@ class BaseForDocComments { /// Reference to an inherited member in another library via class name: [ExtendedBaseReexported.action] /// /// Link to an existing file: [link](../SubForDocComments/localMethod.html) - String doAwesomeStuff(int value) => null; + String? doAwesomeStuff(int value) => null; void anotherMethod() {} @@ -975,20 +979,20 @@ class BaseForDocComments { String operator [](String key) => "${key}'s value"; - final bool initializeMe; + final bool? initializeMe; - int somethingShadowy; + int? somethingShadowy; /// I'm not really a constructor, but I'm allowed to exist anyway. - int aConstructorShadowed; + int? aConstructorShadowed; - BaseForDocComments(this.initializeMe, [bool somethingShadowy]); + BaseForDocComments(this.initializeMe, [bool? somethingShadowy]); BaseForDocComments.aNonDefaultConstructor(this.initializeMe); BaseForDocComments.aConstructorShadowed(this.initializeMe); - factory BaseForDocComments.aFactoryFunction() => null; + factory BaseForDocComments.aFactoryConstructor() => BaseForDocComments(true); } /// Verify that we can define and use macros inside accessors. @@ -1030,20 +1034,20 @@ const required = 'required'; /// Paints an image into the given rectangle in the canvas. void paintImage1( - {@required String canvas, - @required int rect, - @required ExtraSpecialList image, - BaseForDocComments colorFilter, + {required String canvas, + required int rect, + required ExtraSpecialList image, + BaseForDocComments? colorFilter, String repeat: LongFirstLine.THING}) { // nothing to do here - } /// Paints an image into the given rectangle in the canvas. void paintImage2(String fooParam, - [@required String canvas, - @required int rect, - @required ExtraSpecialList image, - BaseForDocComments colorFilter, + [@required String? canvas, + @required int? rect, + @required ExtraSpecialList? image, + BaseForDocComments? colorFilter, String repeat = LongFirstLine.THING]) { // nothing to do here - } @@ -1268,7 +1272,7 @@ class Super6 implements _Super5 {} abstract class IntermediateAbstract extends Object { /// This is an override. @override - bool operator ==(Object other) {} + bool operator ==(Object other) => false; } /// This should inherit [==] from [IntermediateAbstract]. @@ -1276,9 +1280,9 @@ class IntermediateAbstractSubclass extends IntermediateAbstract {} /// Test parameter comment resolution in factory constructors and methods. class FactoryConstructorThings { - bool aName; - int anotherName; - String yetAnotherName; + bool? aName; + int? anotherName; + String? yetAnotherName; final List initViaFieldFormal; final int fieldFormalWithDefault; @@ -1286,35 +1290,35 @@ class FactoryConstructorThings { {this.fieldFormalWithDefault = 7}); factory FactoryConstructorThings.anotherName({ - bool aName, - List anotherName, - int anotherDifferentName, - String differentName, + bool? aName, + List? anotherName, + int? anotherDifferentName, + String? differentName, }) { - return null; + return FactoryConstructorThings([]); } factory FactoryConstructorThings.anotherConstructor({ - bool anotherName, - bool redHerring, + bool? anotherName, + bool? redHerring, }) { - return null; + return FactoryConstructorThings([]); } void aMethod(bool yetAnotherName) {} } -DTypeParam +DTypeParam? aTopLevelTypeParameterFunction( DTypeParam typedParam) {} abstract class TypeParameterThings { - ATypeParam aName; - List aThing; + ATypeParam? aName; + List? aThing; /// Here are some docs to inherit referencing [ATypeParam], [BTypeParam], and [CTypeParam]. - BTypeParam aMethod(ATypeParam aParam, CTypeParam anotherParam); + BTypeParam? aMethod(ATypeParam aParam, CTypeParam anotherParam); } /// Test that inheriting documentation can still reference parent type @@ -1322,7 +1326,7 @@ abstract class TypeParameterThings { @override - FactoryConstructorThings aMethod( + FactoryConstructorThings? aMethod( String aParam, QTypeParam anotherParam) => null; } @@ -1333,7 +1337,7 @@ class TypeParameterThingsExtendedQ @override /// I override documentation so I can reference [QTypeParam]. - FactoryConstructorThings aMethod( + FactoryConstructorThings? aMethod( String aParam, QTypeParam anotherParam) => null; } diff --git a/testing/test_package/lib/gadget_extender.dart b/testing/test_package/lib/gadget_extender.dart index 74beaa273d..bbb10c3a41 100644 --- a/testing/test_package/lib/gadget_extender.dart +++ b/testing/test_package/lib/gadget_extender.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 - import 'src/gadget.dart'; class GadgetExtender extends Gadget {} diff --git a/testing/test_package/lib/implementors.dart b/testing/test_package/lib/implementors.dart index 33d041cbde..f5c73a2425 100644 --- a/testing/test_package/lib/implementors.dart +++ b/testing/test_package/lib/implementors.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 - // A library useful to check implementer chain edge cases. library implementors; diff --git a/testing/test_package/lib/is_deprecated.dart b/testing/test_package/lib/is_deprecated.dart index b82532cf0f..181ce021fe 100644 --- a/testing/test_package/lib/is_deprecated.dart +++ b/testing/test_package/lib/is_deprecated.dart @@ -1,6 +1,4 @@ /// This lib is deprecated. It never had a chance -// @dart=2.9 - @deprecated library is_deprecated; diff --git a/testing/test_package/lib/mylibpub.dart b/testing/test_package/lib/mylibpub.dart index 564774587c..e4d9af04fb 100644 --- a/testing/test_package/lib/mylibpub.dart +++ b/testing/test_package/lib/mylibpub.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library mylibpub; void helperFunction(String message, int i) => print(message); diff --git a/testing/test_package/lib/override_class.dart b/testing/test_package/lib/override_class.dart index d93fc1662b..3e0bee6abb 100644 --- a/testing/test_package/lib/override_class.dart +++ b/testing/test_package/lib/override_class.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'base_class.dart'; class BoxConstraints extends Constraints { diff --git a/testing/test_package/lib/reexport_one.dart b/testing/test_package/lib/reexport_one.dart index 6fb0913aaf..8f33931940 100644 --- a/testing/test_package/lib/reexport_one.dart +++ b/testing/test_package/lib/reexport_one.dart @@ -2,8 +2,6 @@ /// {@canonicalFor reexport.somelib.AUnicornClass} /// {@category Unreal} -// @dart=2.9 - library reexport_one; export 'src/somelib.dart'; diff --git a/testing/test_package/lib/reexport_three.dart b/testing/test_package/lib/reexport_three.dart index ec5d00d2d5..10e4b1a399 100644 --- a/testing/test_package/lib/reexport_three.dart +++ b/testing/test_package/lib/reexport_three.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library reexport_three; // Test show/hide handling. diff --git a/testing/test_package/lib/reexport_two.dart b/testing/test_package/lib/reexport_two.dart index 3aab944e86..383a773323 100644 --- a/testing/test_package/lib/reexport_two.dart +++ b/testing/test_package/lib/reexport_two.dart @@ -4,8 +4,6 @@ /// {@canonicalFor reexport.somelib.DocumentThisExtensionOnce} /// {@category Unreal} -// @dart=2.9 - library reexport_two; // Intentionally create some duplicates via reexporting. diff --git a/testing/test_package/lib/set_literals.dart b/testing/test_package/lib/set_literals.dart index a22b1cf63d..92ea506f30 100644 --- a/testing/test_package/lib/set_literals.dart +++ b/testing/test_package/lib/set_literals.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - const inferredTypeSet = const {1, 3, 5}; const Set specifiedSet = const {}; const untypedMap = const {}; diff --git a/testing/test_package/lib/src/base.dart b/testing/test_package/lib/src/base.dart index b8df2e8ace..fcb93ea3cf 100644 --- a/testing/test_package/lib/src/base.dart +++ b/testing/test_package/lib/src/base.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library two_exports.src.base; import '../fake.dart'; @@ -9,15 +7,15 @@ import 'local_scope.dart'; class BaseClass extends WithGetterAndSetter {} class BaseWithMembers { - int aField; + int? aField; /// Here is some documentation that links to [aNotReexportedVariable] /// for documentationFrom processing. - bool anotherField; + bool? anotherField; static aStaticMethod() {} - static String aStaticField; + static String? aStaticField; BaseWithMembers() {} diff --git a/testing/test_package/lib/src/extending.dart b/testing/test_package/lib/src/extending.dart index 0e7bcce60c..14c9a1486b 100644 --- a/testing/test_package/lib/src/extending.dart +++ b/testing/test_package/lib/src/extending.dart @@ -1,12 +1,10 @@ -// @dart=2.9 - library two_exports.src.extending; import 'base.dart'; int topLevelVariable = 1; -bool someConflictingNameSymbol; +bool? someConflictingNameSymbol; /// Extending class extends [BaseClass]. /// @@ -17,5 +15,5 @@ class ExtendingClass extends BaseClass {} class ExtendingAgain extends BaseWithMembers { @override - bool anotherField; + bool? anotherField; } diff --git a/testing/test_package/lib/src/gadget.dart b/testing/test_package/lib/src/gadget.dart index ceb7c784eb..f7054a19c4 100644 --- a/testing/test_package/lib/src/gadget.dart +++ b/testing/test_package/lib/src/gadget.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 - class _GadgetBase { int get gadgetGetter => 5; } diff --git a/testing/test_package/lib/src/import_unusual.dart b/testing/test_package/lib/src/import_unusual.dart index 030f71f2d9..52bb1f7fd9 100644 --- a/testing/test_package/lib/src/import_unusual.dart +++ b/testing/test_package/lib/src/import_unusual.dart @@ -1,5 +1,3 @@ /// This library exists only to be imported with an unusual URI. -// @dart=2.9 - library import_unusual; diff --git a/testing/test_package/lib/src/intermediate_implements.dart b/testing/test_package/lib/src/intermediate_implements.dart index e9d85c1453..fdec5c6279 100644 --- a/testing/test_package/lib/src/intermediate_implements.dart +++ b/testing/test_package/lib/src/intermediate_implements.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 - // A src-private library for intermediate classes to implement. library intermediate_implements; diff --git a/testing/test_package/lib/src/local_scope.dart b/testing/test_package/lib/src/local_scope.dart index 396744aef5..cf8ae36ef4 100644 --- a/testing/test_package/lib/src/local_scope.dart +++ b/testing/test_package/lib/src/local_scope.dart @@ -1,8 +1,6 @@ -// @dart=2.9 - /// Imported by a library but not reexported. library two_exports.src.local_scope; -String aNotReexportedVariable; +String? aNotReexportedVariable; -bool anotherNotReexportedVariable; +bool? anotherNotReexportedVariable; diff --git a/testing/test_package/lib/src/mixins.dart b/testing/test_package/lib/src/mixins.dart index 50c2326deb..f52a7c6d0d 100644 --- a/testing/test_package/lib/src/mixins.dart +++ b/testing/test_package/lib/src/mixins.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library mixins; export 'mixins_base.dart'; diff --git a/testing/test_package/lib/src/mixins_base.dart b/testing/test_package/lib/src/mixins_base.dart index 86197667e9..26646fc609 100644 --- a/testing/test_package/lib/src/mixins_base.dart +++ b/testing/test_package/lib/src/mixins_base.dart @@ -1,11 +1,9 @@ -// @dart=2.9 - library mixins_base; mixin AMixin {} class ThisClass { - String property; + String? property; } /// A class that extends another class with a new-style mixin, then is diff --git a/testing/test_package/lib/src/mylib.dart b/testing/test_package/lib/src/mylib.dart index 35c5624a7c..d9e423d539 100644 --- a/testing/test_package/lib/src/mylib.dart +++ b/testing/test_package/lib/src/mylib.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library src.mylib; void helperFunction(String message) => print(message); diff --git a/testing/test_package/lib/src/nodocme.dart b/testing/test_package/lib/src/nodocme.dart index 36d9b3f4c2..707a399fb6 100644 --- a/testing/test_package/lib/src/nodocme.dart +++ b/testing/test_package/lib/src/nodocme.dart @@ -3,8 +3,6 @@ /// reexported, due to dartdoc_options.yaml in the package root. /// -// @dart=2.9 - library nodocme; /// I should not appear in documentation. diff --git a/testing/test_package/lib/src/reexport_this.dart b/testing/test_package/lib/src/reexport_this.dart index 77255cf53c..9dfaf7a1f2 100644 --- a/testing/test_package/lib/src/reexport_this.dart +++ b/testing/test_package/lib/src/reexport_this.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library reexport_this; /// {@template example:templateMemberTest} diff --git a/testing/test_package/lib/src/shadow_lib.dart b/testing/test_package/lib/src/shadow_lib.dart index 57e1901e74..8afe83d6aa 100644 --- a/testing/test_package/lib/src/shadow_lib.dart +++ b/testing/test_package/lib/src/shadow_lib.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library shadow_lib; class ADuplicateClass { diff --git a/testing/test_package/lib/src/shadowing_lib.dart b/testing/test_package/lib/src/shadowing_lib.dart index 72ea97805c..c3412ba1c4 100644 --- a/testing/test_package/lib/src/shadowing_lib.dart +++ b/testing/test_package/lib/src/shadowing_lib.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library shadowing_lib; class ADuplicateClass { diff --git a/testing/test_package/lib/src/somelib.dart b/testing/test_package/lib/src/somelib.dart index 1bfa7e15b1..ad7f083f64 100644 --- a/testing/test_package/lib/src/somelib.dart +++ b/testing/test_package/lib/src/somelib.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library reexport.somelib; class SomeClass {} @@ -11,7 +9,7 @@ class YetAnotherClass {} class AUnicornClass {} class BaseReexported { - String action; + String? action; } class ExtendedBaseReexported extends BaseReexported {} diff --git a/testing/test_package/lib/src/tool.dart b/testing/test_package/lib/src/tool.dart index bba37f211a..d08a33dd0d 100644 --- a/testing/test_package/lib/src/tool.dart +++ b/testing/test_package/lib/src/tool.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library test_package.tool; abstract class PrivateLibraryToolUser { diff --git a/testing/test_package/lib/two_exports.dart b/testing/test_package/lib/two_exports.dart index d1773f8a5a..826fa5a989 100644 --- a/testing/test_package/lib/two_exports.dart +++ b/testing/test_package/lib/two_exports.dart @@ -1,13 +1,11 @@ /// {@category Real Libraries} /// {@category Misc} -// @dart=2.9 - library two_exports; export 'src/base.dart'; export 'src/extending.dart' hide someConflictingNameSymbol; -int aSymbolOnlyAvailableInExportContext; +int? aSymbolOnlyAvailableInExportContext; -bool someConflictingNameSymbol; +bool? someConflictingNameSymbol; diff --git a/testing/test_package/lib/unrelated_factories.dart b/testing/test_package/lib/unrelated_factories.dart index ad11cbe132..83051acedf 100644 --- a/testing/test_package/lib/unrelated_factories.dart +++ b/testing/test_package/lib/unrelated_factories.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - class A { /// A link to [AB.fromMap], [fromMap], and [AB] and [A]. factory A.fromMap(Map map) => A._A(); diff --git a/testing/test_package/pubspec.yaml b/testing/test_package/pubspec.yaml index 0ff1a4cc49..244d34693b 100644 --- a/testing/test_package/pubspec.yaml +++ b/testing/test_package/pubspec.yaml @@ -4,8 +4,8 @@ description: Best package ever. version: 0.0.1 dependencies: meta: ^1.4.0 - args: ^1.5.0 + args: ^2.0.0 test_package_imported: path: "../test_package_imported" environment: - sdk: '>=2.14.0-0 <3.0.0' + sdk: '>=2.14.0 <3.0.0' diff --git a/testing/test_package_bad/lib/test_package_bad.dart b/testing/test_package_bad/lib/test_package_bad.dart index 72e4c623b8..5216a07899 100644 --- a/testing/test_package_bad/lib/test_package_bad.dart +++ b/testing/test_package_bad/lib/test_package_bad.dart @@ -1,8 +1,10 @@ +// This library does not exist. import 'foo.dart'; /// Some sample `dartdoc` comments here. void myTestFunction() { print('one'); print('two'); + // This class cannot be found. Foo foo = Foo('three'); } diff --git a/testing/test_package_imported/pubspec.yaml b/testing/test_package_imported/pubspec.yaml index 31338a7d89..5e5478407b 100644 --- a/testing/test_package_imported/pubspec.yaml +++ b/testing/test_package_imported/pubspec.yaml @@ -2,4 +2,4 @@ name: test_package_imported description: Doomed to be imported from other packages version: 0.0.1 environment: - sdk: '>=2.0.0-dev.68 <3.0.0' + sdk: '>=2.13.0 <3.0.0'