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

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

Issue 2092873002: fix #25794, infer parameter type from default value (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge remote-tracking branch 'origin/master' into 25794_param_infer 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.elements; 5 library serialization.elements;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 case ParameterKind.NAMED: 895 case ParameterKind.NAMED:
896 b.kind = UnlinkedParamKind.named; 896 b.kind = UnlinkedParamKind.named;
897 break; 897 break;
898 } 898 }
899 b.annotations = serializeAnnotations(parameter); 899 b.annotations = serializeAnnotations(parameter);
900 b.codeRange = serializeCodeRange(parameter); 900 b.codeRange = serializeCodeRange(parameter);
901 b.isInitializingFormal = parameter.isInitializingFormal; 901 b.isInitializingFormal = parameter.isInitializingFormal;
902 DartType type = parameter.type; 902 DartType type = parameter.type;
903 if (parameter.hasImplicitType) { 903 if (parameter.hasImplicitType) {
904 Element contextParent = context.enclosingElement; 904 Element contextParent = context.enclosingElement;
905 // Strong mode infers parameters in two cases:
906 // - instance members (i.e. not constructors or static members),
907 // - parameters with default values, except initializing formals
908 // (the type comes from the field).
905 if (!parameter.isInitializingFormal && 909 if (!parameter.isInitializingFormal &&
906 contextParent is ExecutableElement && 910 contextParent is ExecutableElement &&
907 !contextParent.isStatic && 911 (!contextParent.isStatic && contextParent is! ConstructorElement ||
908 contextParent is! ConstructorElement) { 912 parameter.parameterKind != ParameterKind.REQUIRED)) {
909 b.inferredTypeSlot = storeInferredType(type, context); 913 b.inferredTypeSlot = storeInferredType(type, context);
910 } 914 }
911 } else { 915 } else {
912 if (type is FunctionType && type.element.isSynthetic) { 916 if (type is FunctionType && type.element.isSynthetic) {
913 b.isFunctionTyped = true; 917 b.isFunctionTyped = true;
914 b.type = serializeTypeRef(type.returnType, parameter); 918 b.type = serializeTypeRef(type.returnType, parameter);
915 b.parameters = type.parameters 919 b.parameters = type.parameters
916 .map((parameter) => serializeParam(parameter, context)) 920 .map((parameter) => serializeParam(parameter, context))
917 .toList(); 921 .toList();
918 } else { 922 } else {
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 exportNames.add(new LinkedExportNameBuilder( 1679 exportNames.add(new LinkedExportNameBuilder(
1676 name: name, 1680 name: name,
1677 dependency: serializeDependency(dependentLibrary), 1681 dependency: serializeDependency(dependentLibrary),
1678 unit: unit, 1682 unit: unit,
1679 kind: kind)); 1683 kind: kind));
1680 } 1684 }
1681 pb.exportNames = exportNames; 1685 pb.exportNames = exportNames;
1682 return pb; 1686 return pb;
1683 } 1687 }
1684 } 1688 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698