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

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

Issue 2511753002: Fix crash while inferencing instance field type. (Closed)
Patch Set: Created 4 years, 1 month 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 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 2944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2955 2955
2956 @override 2956 @override
2957 List<FunctionElementForLink_Local_NonSynthetic> get functions => 2957 List<FunctionElementForLink_Local_NonSynthetic> get functions =>
2958 _functions ??= _variable.unlinkedVariable.initializer.localFunctions 2958 _functions ??= _variable.unlinkedVariable.initializer.localFunctions
2959 .map((UnlinkedExecutable ex) => 2959 .map((UnlinkedExecutable ex) =>
2960 new FunctionElementForLink_Local_NonSynthetic( 2960 new FunctionElementForLink_Local_NonSynthetic(
2961 _variable.compilationUnit, this, ex)) 2961 _variable.compilationUnit, this, ex))
2962 .toList(); 2962 .toList();
2963 2963
2964 @override 2964 @override
2965 String get identifier => '';
2966
2967 @override
2965 DartType get returnType { 2968 DartType get returnType {
2966 // If this is a variable whose type needs inferring, infer it. 2969 // If this is a variable whose type needs inferring, infer it.
2967 if (_variable.hasImplicitType) { 2970 if (_variable.hasImplicitType) {
2968 return _variable.inferredType; 2971 return _variable.inferredType;
2969 } else { 2972 } else {
2970 // There's no reason linking should need to access the type of 2973 // There's no reason linking should need to access the type of
2971 // this FunctionElement, since the variable doesn't need its 2974 // this FunctionElement, since the variable doesn't need its
2972 // type inferred. 2975 // type inferred.
2973 assert(false); 2976 assert(false);
2974 // But for robustness, return the dynamic type. 2977 // But for robustness, return the dynamic type.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 3081
3079 @override 3082 @override
3080 List<FunctionElementForLink_Local_NonSynthetic> get functions => 3083 List<FunctionElementForLink_Local_NonSynthetic> get functions =>
3081 _functions ??= _unlinkedExecutable.localFunctions 3084 _functions ??= _unlinkedExecutable.localFunctions
3082 .map((UnlinkedExecutable ex) => 3085 .map((UnlinkedExecutable ex) =>
3083 new FunctionElementForLink_Local_NonSynthetic( 3086 new FunctionElementForLink_Local_NonSynthetic(
3084 compilationUnit, this, ex)) 3087 compilationUnit, this, ex))
3085 .toList(); 3088 .toList();
3086 3089
3087 @override 3090 @override
3091 String get identifier {
3092 String identifier = _unlinkedExecutable.name;
3093 Element enclosing = this.enclosingElement;
3094 if (enclosing is ExecutableElement) {
3095 int id =
3096 ElementImpl.findElementIndexUsingIdentical(enclosing.functions, this);
3097 identifier += "@$id";
3098 }
3099 return identifier;
3100 }
3101
3102 @override
3088 bool get _hasTypeBeenInferred => _inferredReturnType != null; 3103 bool get _hasTypeBeenInferred => _inferredReturnType != null;
3089 3104
3090 @override 3105 @override
3091 DartType buildType( 3106 DartType buildType(
3092 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { 3107 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) {
3093 assert(implicitFunctionTypeIndices.isEmpty); 3108 assert(implicitFunctionTypeIndices.isEmpty);
3094 return type; 3109 return type;
3095 } 3110 }
3096 3111
3097 @override 3112 @override
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after
4974 } 4989 }
4975 } 4990 }
4976 4991
4977 @override 4992 @override
4978 PropertyAccessorElementForLink_Variable get getter => 4993 PropertyAccessorElementForLink_Variable get getter =>
4979 _getter ??= new PropertyAccessorElementForLink_Variable(this, false); 4994 _getter ??= new PropertyAccessorElementForLink_Variable(this, false);
4980 4995
4981 @override 4996 @override
4982 bool get hasImplicitType => unlinkedVariable.type == null; 4997 bool get hasImplicitType => unlinkedVariable.type == null;
4983 4998
4999 @override
5000 String get identifier => unlinkedVariable.name;
5001
4984 /** 5002 /**
4985 * Return the inferred type of the variable element. Should only be called if 5003 * Return the inferred type of the variable element. Should only be called if
4986 * no type was explicitly declared. 5004 * no type was explicitly declared.
4987 */ 5005 */
4988 DartType get inferredType { 5006 DartType get inferredType {
4989 // We should only try to infer a type when none is explicitly declared. 5007 // We should only try to infer a type when none is explicitly declared.
4990 assert(unlinkedVariable.type == null); 5008 assert(unlinkedVariable.type == null);
4991 if (_inferredType == null) { 5009 if (_inferredType == null) {
4992 if (_typeInferenceNode != null) { 5010 if (_typeInferenceNode != null) {
4993 assert(Linker._initializerTypeInferenceCycle == null); 5011 assert(Linker._initializerTypeInferenceCycle == null);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5061 * there are no type parameters in scope. 5079 * there are no type parameters in scope.
5062 */ 5080 */
5063 TypeParameterizedElementMixin get _typeParameterContext; 5081 TypeParameterizedElementMixin get _typeParameterContext;
5064 5082
5065 @override 5083 @override
5066 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 5084 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
5067 5085
5068 @override 5086 @override
5069 String toString() => '$enclosingElement.$name'; 5087 String toString() => '$enclosingElement.$name';
5070 } 5088 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698