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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_ast.dart

Issue 2092333002: fix #25794, infer parameter type from default value, in AST summaries (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix comment Created 4 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library serialization.summarize_ast; 5 library serialization.summarize_ast;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/type.dart' show DartType; 10 import 'package:analyzer/dart/element/type.dart' show DartType;
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 serializeTypeParameters(typeParameters, typeParameterScope); 636 serializeTypeParameters(typeParameters, typeParameterScope);
637 if (!isTopLevel) { 637 if (!isTopLevel) {
638 b.isStatic = isDeclaredStatic; 638 b.isStatic = isDeclaredStatic;
639 } 639 }
640 b.returnType = serializeTypeName(returnType); 640 b.returnType = serializeTypeName(returnType);
641 bool isSemanticallyStatic = isTopLevel || isDeclaredStatic; 641 bool isSemanticallyStatic = isTopLevel || isDeclaredStatic;
642 if (formalParameters != null) { 642 if (formalParameters != null) {
643 b.parameters = formalParameters.parameters 643 b.parameters = formalParameters.parameters
644 .map((FormalParameter p) => p.accept(this)) 644 .map((FormalParameter p) => p.accept(this))
645 .toList(); 645 .toList();
646 if (!isSemanticallyStatic) { 646
647 for (int i = 0; i < formalParameters.parameters.length; i++) { 647 for (int i = 0; i < formalParameters.parameters.length; i++) {
648 if (!b.parameters[i].isFunctionTyped && 648 UnlinkedParamBuilder p = b.parameters[i];
649 b.parameters[i].type == null) { 649 if (!p.isFunctionTyped && p.type == null) {
650 b.parameters[i].inferredTypeSlot = assignSlot(); 650 // Strong mode infers parameters in two cases:
651 // - instance members (i.e. not semantically static),
652 // - parameters with default values, except initializing formals
653 // (the type comes from the field).
654 if (!isSemanticallyStatic ||
655 p.initializer != null && !p.isInitializingFormal) {
656 p.inferredTypeSlot = assignSlot();
651 } 657 }
652 } 658 }
653 } 659 }
654 } 660 }
655 b.documentationComment = serializeDocumentation(documentationComment); 661 b.documentationComment = serializeDocumentation(documentationComment);
656 b.annotations = serializeAnnotations(annotations); 662 b.annotations = serializeAnnotations(annotations);
657 b.codeRange = serializeCodeRange(node); 663 b.codeRange = serializeCodeRange(node);
658 if (returnType == null && !isSemanticallyStatic) { 664 if (returnType == null && !isSemanticallyStatic) {
659 b.inferredReturnTypeSlot = assignSlot(); 665 b.inferredReturnTypeSlot = assignSlot();
660 } 666 }
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 /** 1382 /**
1377 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 1383 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
1378 */ 1384 */
1379 class _TypeParameterScope extends _Scope { 1385 class _TypeParameterScope extends _Scope {
1380 /** 1386 /**
1381 * Get the number of [_ScopedTypeParameter]s defined in this 1387 * Get the number of [_ScopedTypeParameter]s defined in this
1382 * [_TypeParameterScope]. 1388 * [_TypeParameterScope].
1383 */ 1389 */
1384 int get length => _definedNames.length; 1390 int get length => _definedNames.length;
1385 } 1391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698