Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart

Issue 2977303002: Issue 30179. Infer return type of static setters to 'void'. (Closed)
Patch Set: Update Analyzer inference test to handle 'void' return type. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
index 539a7f2a84f3c0bb2319111cfe7f1d7374c681a6..c035505d9313b3fff774a1b458be3925575d0218 100644
--- a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
+++ b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
@@ -17,8 +17,8 @@ import 'package:analyzer/src/generated/scanner.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:front_end/src/base/instrumentation.dart' as fasta;
-import 'package:front_end/src/fasta/compiler_context.dart' as fasta;
import 'package:front_end/src/fasta/compiler_command_line.dart' as fasta;
+import 'package:front_end/src/fasta/compiler_context.dart' as fasta;
import 'package:front_end/src/fasta/testing/validating_instrumentation.dart'
as fasta;
import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri;
@@ -389,13 +389,17 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
@override
visitFunctionDeclaration(FunctionDeclaration node) {
super.visitFunctionDeclaration(node);
- if (node.element is LocalElement &&
- node.element.enclosingElement is! CompilationUnitElement) {
+
+ bool isSetter = node.element.kind == ElementKind.SETTER;
+ bool isLocalFunction = node.element is LocalElement &&
+ node.element.enclosingElement is! CompilationUnitElement;
+
+ if (isSetter || isLocalFunction) {
if (node.returnType == null) {
_instrumentation.record(
uri,
node.name.offset,
- 'returnType',
+ isSetter ? 'topType' : 'returnType',
new _InstrumentationValueForType(
node.element.returnType, elementNamer));
}
@@ -496,10 +500,10 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
@override
visitMethodDeclaration(MethodDeclaration node) {
super.visitMethodDeclaration(node);
+ if (node.returnType == null) {
+ _recordTopType(node.name.offset, node.element.returnType);
+ }
if (node.element.enclosingElement is ClassElement && !node.isStatic) {
- if (node.returnType == null) {
- _recordTopType(node.name.offset, node.element.returnType);
- }
if (node.parameters != null) {
for (var parameter in node.parameters.parameters) {
// Note: it's tempting to check `parameter.type == null`, but that
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698