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

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

Issue 2943273002: Implement type inference of getters/setters based on inheritance. (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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 visitMapLiteral(MapLiteral node) { 445 visitMapLiteral(MapLiteral node) {
446 super.visitMapLiteral(node); 446 super.visitMapLiteral(node);
447 if (node.typeArguments == null) { 447 if (node.typeArguments == null) {
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
456 visitMethodDeclaration(MethodDeclaration node) {
457 super.visitMethodDeclaration(node);
458 if (node.element.enclosingElement is ClassElement) {
459 if (node.isGetter && node.returnType == null) {
460 _recordTopType(node.name.offset, node.element.returnType);
461 }
462 if (node.isSetter) {
463 for (var parameter in node.parameters.parameters) {
464 if (parameter.element.hasImplicitType) {
scheglov 2017/06/18 23:03:43 Would "parameter.type == null" work? It would be c
Paul Berry 2017/06/18 23:34:31 I considered that too, but it wouldn't work becaus
Paul Berry 2017/06/19 18:18:27 After further experimentation it turns out that Pa
465 _recordTopType(parameter.identifier.offset, parameter.element.type);
466 }
467 }
468 }
469 }
470 }
471
455 visitMethodInvocation(MethodInvocation node) { 472 visitMethodInvocation(MethodInvocation node) {
456 super.visitMethodInvocation(node); 473 super.visitMethodInvocation(node);
457 if (node.typeArguments == null) { 474 if (node.typeArguments == null) {
458 var inferredTypeArguments = _getInferredFunctionTypeArguments( 475 var inferredTypeArguments = _getInferredFunctionTypeArguments(
459 node.function.staticType, 476 node.function.staticType,
460 node.staticInvokeType, 477 node.staticInvokeType,
461 node.typeArguments) 478 node.typeArguments)
462 .toList(); 479 .toList();
463 if (inferredTypeArguments.isNotEmpty) { 480 if (inferredTypeArguments.isNotEmpty) {
464 _recordTypeArguments(node.methodName.offset, inferredTypeArguments); 481 _recordTypeArguments(node.methodName.offset, inferredTypeArguments);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 581
565 /// Based on DDC code generator's `_recoverTypeArguments` 582 /// Based on DDC code generator's `_recoverTypeArguments`
566 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) { 583 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
567 assert(identical(g.element, f.element)); 584 assert(identical(g.element, f.element));
568 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty); 585 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty);
569 assert(g.typeFormals.length + g.typeArguments.length == 586 assert(g.typeFormals.length + g.typeArguments.length ==
570 f.typeArguments.length); 587 f.typeArguments.length);
571 return f.typeArguments.skip(g.typeArguments.length); 588 return f.typeArguments.skip(g.typeArguments.length);
572 } 589 }
573 } 590 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698