diff --git a/pkg/linter/test/rules/omit_obvious_local_variable_types_test.dart b/pkg/linter/test/rules/omit_obvious_local_variable_types_test.dart index e7160d981f9..73530e43286 100644 --- a/pkg/linter/test/rules/omit_obvious_local_variable_types_test.dart +++ b/pkg/linter/test/rules/omit_obvious_local_variable_types_test.dart @@ -58,6 +58,18 @@ class A { ); } + test_cascade_dotShorthand() async { + await assertNoDiagnostics(r''' +f() { + A a = .new()..x..x..x; +} + +class A { + final x = 0; +} +'''); + } + test_dot_shorthand() async { await assertNoDiagnostics(r''' f() { @@ -77,6 +89,16 @@ f() { ); } + test_forEach_inferredList_dotShorthands() async { + await assertNoDiagnostics(r''' +enum E { a, b, c } + +f() { + for (E e in [.a, .b, .c]) { } +} +'''); + } + test_forEach_listWithNonObviousElement() async { await assertNoDiagnostics(r''' f() { @@ -183,6 +205,16 @@ class A {} ); } + test_instanceCreation_nonGeneric_dotShorthand() async { + await assertNoDiagnostics(r''' +f() { + A a = .new(); +} + +class A {} +'''); + } + test_list() async { await assertDiagnostics( r''' @@ -194,6 +226,16 @@ f() { ); } + test_list_dotShorthand() async { + await assertNoDiagnostics(r''' +enum E { a, b, c } + +f() { + List a = [.a, .b, .c]; +} +'''); + } + test_list_ok1() async { await assertNoDiagnostics(r''' f() { diff --git a/pkg/linter/test/rules/omit_obvious_property_types_test.dart b/pkg/linter/test/rules/omit_obvious_property_types_test.dart index 636a2871e78..b0e328094cd 100644 --- a/pkg/linter/test/rules/omit_obvious_property_types_test.dart +++ b/pkg/linter/test/rules/omit_obvious_property_types_test.dart @@ -203,6 +203,16 @@ class C {} ); } + test_instanceCreation_nonGeneric_static_dotShorthand() async { + await assertNoDiagnostics(r''' +class A { + static C c = .new(); +} + +class C {} +'''); + } + test_instanceCreation_nonGeneric_topLevel() async { await assertDiagnostics( r''' @@ -214,6 +224,14 @@ class C {} ); } + test_instanceCreation_nonGeneric_topLevel_dotShorthand() async { + await assertNoDiagnostics(r''' +C c = .new(); + +class C {} +'''); + } + test_list_ok1_static() async { await assertNoDiagnostics(r''' class A {