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

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

Issue 2946273002: Implement override-based type inference for instance methods. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 DartType type = node.staticType; 448 DartType type = node.staticType;
449 if (type is InterfaceType) { 449 if (type is InterfaceType) {
450 _recordTypeArguments(node.offset, type.typeArguments); 450 _recordTypeArguments(node.offset, type.typeArguments);
451 } 451 }
452 } 452 }
453 } 453 }
454 454
455 @override 455 @override
456 visitMethodDeclaration(MethodDeclaration node) { 456 visitMethodDeclaration(MethodDeclaration node) {
457 super.visitMethodDeclaration(node); 457 super.visitMethodDeclaration(node);
458 if (node.element.enclosingElement is ClassElement) { 458 if (node.element.enclosingElement is ClassElement && !node.isStatic) {
459 if (node.isGetter && node.returnType == null) { 459 if (node.returnType == null) {
460 _recordTopType(node.name.offset, node.element.returnType); 460 // For now, we skip inferred return types of setters.
461 // TODO(paulberry): fix this.
462 if (!node.isSetter) {
463 _recordTopType(node.name.offset, node.element.returnType);
464 }
461 } 465 }
462 if (node.isSetter) { 466 if (node.parameters != null) {
463 for (var parameter in node.parameters.parameters) { 467 for (var parameter in node.parameters.parameters) {
464 // Note: it's tempting to check `parameter.type == null`, but that 468 // Note: it's tempting to check `parameter.type == null`, but that
465 // doesn't work because of function-typed formal parameter syntax. 469 // doesn't work because of function-typed formal parameter syntax.
466 if (parameter.element.hasImplicitType) { 470 if (parameter.element.hasImplicitType) {
467 _recordTopType(parameter.identifier.offset, parameter.element.type); 471 _recordTopType(parameter.identifier.offset, parameter.element.type);
468 } 472 }
469 } 473 }
470 } 474 }
471 } 475 }
472 } 476 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 587
584 /// Based on DDC code generator's `_recoverTypeArguments` 588 /// Based on DDC code generator's `_recoverTypeArguments`
585 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) { 589 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
586 assert(identical(g.element, f.element)); 590 assert(identical(g.element, f.element));
587 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty); 591 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty);
588 assert(g.typeFormals.length + g.typeArguments.length == 592 assert(g.typeFormals.length + g.typeArguments.length ==
589 f.typeArguments.length); 593 f.typeArguments.length);
590 return f.typeArguments.skip(g.typeArguments.length); 594 return f.typeArguments.skip(g.typeArguments.length);
591 } 595 }
592 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698