Skip to content

Commit 64a0903

Browse files
eernstgCommit Queue
authored andcommitted
Add test to check that dot shorthands do not have an obvious type
This PR adds a test to confirm that the lint `omit_obvious_local_variable_types` considers a dot shorthand to be an expression whose type is not obvious. This is crucial because the dot shorthand would no longer work if the context type is turned into `_` because the type annotation is removed. Similarly for the lint `omit_obvious_property_types`. Fixes #60910 Change-Id: Ie31026286eb496c0cd76c7bb5ca64e04340b4aaa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434660 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent 087c496 commit 64a0903

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/linter/test/rules/omit_obvious_local_variable_types_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ class A {
5858
);
5959
}
6060

61+
test_dot_shorthand() async {
62+
await assertNoDiagnostics(r'''
63+
f() {
64+
int i = .parse('1');
65+
}
66+
''');
67+
}
68+
6169
test_forEach_inferredList() async {
6270
await assertDiagnostics(
6371
r'''

pkg/linter/test/rules/omit_obvious_property_types_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ class C {
9191
);
9292
}
9393

94+
test_dot_shorthand() async {
95+
await assertNoDiagnostics(r'''
96+
int i = .parse('1');
97+
''');
98+
}
99+
94100
test_genericInvocation_paramIsType_static() async {
95101
await assertNoDiagnostics(r'''
96102
T bar<T>(T d) => d;

0 commit comments

Comments
 (0)