commit | 03776172c120c27af5d9911129c2c2e1b48bed9c | [log] [tgz] |
---|---|---|
author | Konstantin Shcheglov <scheglov@google.com> | Thu May 02 23:22:33 2019 +0000 |
committer | Konstantin Shcheglov <scheglov@google.com> | Thu May 02 23:22:33 2019 +0000 |
tree | 786742d55e0069a9b761bd2219046f8a9f4dc8ec | |
parent | d5eba9b77dc1dc27ff353cefcfa710b04fb25011 [diff] |
Read VariableDeclaration type during checking for implicitly typed. R=brianwilkerson@google.com Change-Id: Ide32d69775df15aa3524893734a11dc7299bdc72 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101221 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart index a1a58c1..b32ee0c 100644 --- a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart +++ b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
@@ -743,6 +743,7 @@ return node.type == null; } else if (node is VariableDeclaration) { VariableDeclarationList parent = node.parent; + LazyVariableDeclarationList.readTypeNode(_astReader, parent); return parent.type == null; } return false;
diff --git a/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart b/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart index 8427700..2a28469 100644 --- a/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart +++ b/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart
@@ -52,6 +52,19 @@ expect(b.variables.variables[0].declaredElement.type.toString(), 'int'); } + test_field_imported() async { + newFile('/test/lib/a.dart', content: ''' +class A { + int f; +} +'''); + await assertNoErrorsInCode(''' +import 'a.dart'; +var b = new A().f; +'''); + assertElementTypeString(findElement.topVar('b').type, 'int'); + } + test_field_prefixedIdentifier() async { await assertNoErrorsInCode(''' class A {