Fix for hasImplicitReturnType.
R=brianwilkerson@google.com
Change-Id: I94e1e0f8246f3ff0d284ef7b1de6f618ad464592
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102984
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@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 a68d7da..2abe4c3 100644
--- a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
@@ -670,7 +670,7 @@
bool hasImplicitReturnType(AstNode node) {
if (node is FunctionDeclaration) {
- LazyFunctionDeclaration.readFunctionExpression(_astReader, node);
+ LazyFunctionDeclaration.readReturnTypeNode(_astReader, node);
return node.returnType == null;
}
if (node is MethodDeclaration) {
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index b8536df..c201a7c 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -6065,6 +6065,22 @@
''');
}
+ test_function_hasImplicitReturnType_false() async {
+ var library = await checkLibrary('''
+int f() => 0;
+''');
+ var f = library.definingCompilationUnit.functions.single;
+ expect(f.hasImplicitReturnType, isFalse);
+ }
+
+ test_function_hasImplicitReturnType_true() async {
+ var library = await checkLibrary('''
+f() => 0;
+''');
+ var f = library.definingCompilationUnit.functions.single;
+ expect(f.hasImplicitReturnType, isTrue);
+ }
+
test_function_parameter_final() async {
var library = await checkLibrary('f(final x) {}');
checkElementText(library, r'''
@@ -8471,6 +8487,28 @@
''');
}
+ test_method_hasImplicitReturnType_false() async {
+ var library = await checkLibrary('''
+class C {
+ int m() => 0;
+}
+''');
+ var c = library.definingCompilationUnit.types.single;
+ var m = c.methods.single;
+ expect(m.hasImplicitReturnType, isFalse);
+ }
+
+ test_method_hasImplicitReturnType_true() async {
+ var library = await checkLibrary('''
+class C {
+ m() => 0;
+}
+''');
+ var c = library.definingCompilationUnit.types.single;
+ var m = c.methods.single;
+ expect(m.hasImplicitReturnType, isTrue);
+ }
+
test_method_inferred_type_nonStatic_implicit_param() async {
var library = await checkLibrary('class C extends D { void f(value) {} }'
' abstract class D { void f(int value); }');