OLD | NEW |
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 Loading... |
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). | |
909 if (!parameter.isInitializingFormal && | 905 if (!parameter.isInitializingFormal && |
910 contextParent is ExecutableElement && | 906 contextParent is ExecutableElement && |
911 (!contextParent.isStatic && contextParent is! ConstructorElement || | 907 !contextParent.isStatic && |
912 parameter.parameterKind != ParameterKind.REQUIRED)) { | 908 contextParent is! ConstructorElement) { |
913 b.inferredTypeSlot = storeInferredType(type, context); | 909 b.inferredTypeSlot = storeInferredType(type, context); |
914 } | 910 } |
915 } else { | 911 } else { |
916 if (type is FunctionType && type.element.isSynthetic) { | 912 if (type is FunctionType && type.element.isSynthetic) { |
917 b.isFunctionTyped = true; | 913 b.isFunctionTyped = true; |
918 b.type = serializeTypeRef(type.returnType, parameter); | 914 b.type = serializeTypeRef(type.returnType, parameter); |
919 b.parameters = type.parameters | 915 b.parameters = type.parameters |
920 .map((parameter) => serializeParam(parameter, context)) | 916 .map((parameter) => serializeParam(parameter, context)) |
921 .toList(); | 917 .toList(); |
922 } else { | 918 } else { |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 exportNames.add(new LinkedExportNameBuilder( | 1675 exportNames.add(new LinkedExportNameBuilder( |
1680 name: name, | 1676 name: name, |
1681 dependency: serializeDependency(dependentLibrary), | 1677 dependency: serializeDependency(dependentLibrary), |
1682 unit: unit, | 1678 unit: unit, |
1683 kind: kind)); | 1679 kind: kind)); |
1684 } | 1680 } |
1685 pb.exportNames = exportNames; | 1681 pb.exportNames = exportNames; |
1686 return pb; | 1682 return pb; |
1687 } | 1683 } |
1688 } | 1684 } |
OLD | NEW |