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

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

Issue 2818543002: [Reapply] Pass ElementImpl as a context for resynthesizing types. (Closed)
Patch Set: Created 3 years, 8 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 /** 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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 } 676 }
677 677
678 @override 678 @override
679 String toString() => '$enclosingElement.$name'; 679 String toString() => '$enclosingElement.$name';
680 680
681 /** 681 /**
682 * Convert [typeRef] into an [InterfaceType]. 682 * Convert [typeRef] into an [InterfaceType].
683 */ 683 */
684 InterfaceType _computeInterfaceType(EntityRef typeRef) { 684 InterfaceType _computeInterfaceType(EntityRef typeRef) {
685 if (typeRef != null) { 685 if (typeRef != null) {
686 DartType type = enclosingElement.resolveTypeRef(typeRef, this); 686 DartType type = enclosingElement.resolveTypeRef(this, typeRef);
687 if (type is InterfaceType && !type.element.isEnum) { 687 if (type is InterfaceType && !type.element.isEnum) {
688 return type; 688 return type;
689 } 689 }
690 // In the event that the `typeRef` isn't an interface type (which may 690 // In the event that the `typeRef` isn't an interface type (which may
691 // happen in the event of erroneous code) just fall through and pretend 691 // happen in the event of erroneous code) just fall through and pretend
692 // the supertype is `Object`. 692 // the supertype is `Object`.
693 } 693 }
694 return enclosingElement.enclosingElement._linker.typeProvider.objectType; 694 return enclosingElement.enclosingElement._linker.typeProvider.objectType;
695 } 695 }
696 } 696 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 } 993 }
994 // TODO(paulberry): fill in other top level entities (typedefs 994 // TODO(paulberry): fill in other top level entities (typedefs
995 // and executables). 995 // and executables).
996 } 996 }
997 return _containedNames.putIfAbsent( 997 return _containedNames.putIfAbsent(
998 name, () => UndefinedElementForLink.instance); 998 name, () => UndefinedElementForLink.instance);
999 } 999 }
1000 1000
1001 /** 1001 /**
1002 * Compute the type referred to by the given linked type [slot] (interpreted 1002 * Compute the type referred to by the given linked type [slot] (interpreted
1003 * relative to [typeParameterContext]). If there is no inferred type in the 1003 * in [context]). If there is no inferred type in the
1004 * given slot, `dynamic` is returned. 1004 * given slot, `dynamic` is returned.
1005 */ 1005 */
1006 DartType getLinkedType( 1006 DartType getLinkedType(ElementImpl context, int slot);
1007 int slot, TypeParameterizedElementMixin typeParameterContext);
1008 1007
1009 @override 1008 @override
1010 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 1009 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
1011 1010
1012 /** 1011 /**
1013 * Return the class element for the constructor referred to by the given 1012 * Return the class element for the constructor referred to by the given
1014 * [index] in [UnlinkedUnit.references]. If the reference is unresolved, 1013 * [index] in [UnlinkedUnit.references]. If the reference is unresolved,
1015 * return [UndefinedElementForLink.instance]. 1014 * return [UndefinedElementForLink.instance].
1016 */ 1015 */
1017 ReferenceableElementForLink resolveConstructorClassRef(int index) { 1016 ReferenceableElementForLink resolveConstructorClassRef(int index) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 } else { 1068 } else {
1070 LibraryElementForLink dependency = 1069 LibraryElementForLink dependency =
1071 enclosingElement._getDependency(linkedReference.dependency); 1070 enclosingElement._getDependency(linkedReference.dependency);
1072 _references[index] = dependency.getContainedName(name); 1071 _references[index] = dependency.getContainedName(name);
1073 } 1072 }
1074 } 1073 }
1075 return _references[index]; 1074 return _references[index];
1076 } 1075 }
1077 1076
1078 @override 1077 @override
1079 DartType resolveTypeRef( 1078 DartType resolveTypeRef(ElementImpl context, EntityRef type,
1080 EntityRef type, TypeParameterizedElementMixin typeParameterContext,
1081 {bool defaultVoid: false, 1079 {bool defaultVoid: false,
1082 bool instantiateToBoundsAllowed: true, 1080 bool instantiateToBoundsAllowed: true,
1083 bool declaredType: false}) { 1081 bool declaredType: false}) {
1084 if (type == null) { 1082 if (type == null) {
1085 if (defaultVoid) { 1083 if (defaultVoid) {
1086 return VoidTypeImpl.instance; 1084 return VoidTypeImpl.instance;
1087 } else { 1085 } else {
1088 return DynamicTypeImpl.instance; 1086 return DynamicTypeImpl.instance;
1089 } 1087 }
1090 } 1088 }
1091 if (type.paramReference != 0) { 1089 if (type.paramReference != 0) {
1092 return typeParameterContext.getTypeParameterType(type.paramReference); 1090 return context.typeParameterContext
1091 .getTypeParameterType(type.paramReference);
1093 } else if (type.syntheticReturnType != null) { 1092 } else if (type.syntheticReturnType != null) {
1094 // TODO(paulberry): implement. 1093 // TODO(paulberry): implement.
1095 throw new UnimplementedError(); 1094 throw new UnimplementedError();
1096 } else if (type.implicitFunctionTypeIndices.isNotEmpty) { 1095 } else if (type.implicitFunctionTypeIndices.isNotEmpty) {
1097 // TODO(paulberry): implement. 1096 // TODO(paulberry): implement.
1098 throw new UnimplementedError(); 1097 throw new UnimplementedError();
1099 } else { 1098 } else {
1100 DartType getTypeArgument(int i) { 1099 DartType getTypeArgument(int i) {
1101 if (i < type.typeArguments.length) { 1100 if (i < type.typeArguments.length) {
1102 return resolveTypeRef(type.typeArguments[i], typeParameterContext); 1101 return resolveTypeRef(context, type.typeArguments[i]);
1103 } else if (!instantiateToBoundsAllowed) { 1102 } else if (!instantiateToBoundsAllowed) {
1104 // Do not allow buildType to instantiate the bounds; force dynamic. 1103 // Do not allow buildType to instantiate the bounds; force dynamic.
1105 return DynamicTypeImpl.instance; 1104 return DynamicTypeImpl.instance;
1106 } else { 1105 } else {
1107 return null; 1106 return null;
1108 } 1107 }
1109 } 1108 }
1110 1109
1111 ReferenceableElementForLink element = resolveRef(type.reference); 1110 ReferenceableElementForLink element = resolveRef(type.reference);
1112 return element.buildType( 1111 return element.buildType(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 // [LinkedReference.numTypeParameters]). 1271 // [LinkedReference.numTypeParameters]).
1273 return addRawReference(element.name, 1272 return addRawReference(element.name,
1274 containingReference: addReference(enclosingClass), 1273 containingReference: addReference(enclosingClass),
1275 kind: ReferenceKind.propertyAccessor); 1274 kind: ReferenceKind.propertyAccessor);
1276 } 1275 }
1277 // TODO(paulberry): implement other cases 1276 // TODO(paulberry): implement other cases
1278 throw new UnimplementedError('${element.runtimeType}'); 1277 throw new UnimplementedError('${element.runtimeType}');
1279 } 1278 }
1280 1279
1281 @override 1280 @override
1282 DartType getLinkedType( 1281 DartType getLinkedType(ElementImpl context, int slot) {
1283 int slot, TypeParameterizedElementMixin typeParameterContext) {
1284 // This method should only be called on compilation units that come from 1282 // This method should only be called on compilation units that come from
1285 // dependencies, never on compilation units that are part of the current 1283 // dependencies, never on compilation units that are part of the current
1286 // build unit. 1284 // build unit.
1287 throw new StateError( 1285 throw new StateError(
1288 'Linker tried to access linked type from current build unit'); 1286 'Linker tried to access linked type from current build unit');
1289 } 1287 }
1290 1288
1291 /** 1289 /**
1292 * Perform type inference and const cycle detection on this 1290 * Perform type inference and const cycle detection on this
1293 * compilation unit. 1291 * compilation unit.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 _linkedTypeRefs = new List<EntityRef>(maxLinkedTypeSlot + 1); 1397 _linkedTypeRefs = new List<EntityRef>(maxLinkedTypeSlot + 1);
1400 for (EntityRef ref in _linkedUnit.types) { 1398 for (EntityRef ref in _linkedUnit.types) {
1401 _linkedTypeRefs[ref.slot] = ref; 1399 _linkedTypeRefs[ref.slot] = ref;
1402 } 1400 }
1403 } 1401 }
1404 1402
1405 @override 1403 @override
1406 bool get isInBuildUnit => false; 1404 bool get isInBuildUnit => false;
1407 1405
1408 @override 1406 @override
1409 DartType getLinkedType( 1407 DartType getLinkedType(ElementImpl context, int slot) {
1410 int slot, TypeParameterizedElementMixin typeParameterContext) {
1411 if (slot < _linkedTypeRefs.length) { 1408 if (slot < _linkedTypeRefs.length) {
1412 return resolveTypeRef(_linkedTypeRefs[slot], typeParameterContext); 1409 return resolveTypeRef(context, _linkedTypeRefs[slot]);
1413 } else { 1410 } else {
1414 return DynamicTypeImpl.instance; 1411 return DynamicTypeImpl.instance;
1415 } 1412 }
1416 } 1413 }
1417 } 1414 }
1418 1415
1419 /** 1416 /**
1420 * Instance of [ConstNode] representing a constant constructor. 1417 * Instance of [ConstNode] representing a constant constructor.
1421 */ 1418 */
1422 class ConstConstructorNode extends ConstNode { 1419 class ConstConstructorNode extends ConstNode {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 1822
1826 /** 1823 /**
1827 * If the executable element had an explicitly declared return type, return 1824 * If the executable element had an explicitly declared return type, return
1828 * it. Otherwise return `null`. 1825 * it. Otherwise return `null`.
1829 */ 1826 */
1830 DartType get declaredReturnType { 1827 DartType get declaredReturnType {
1831 if (_unlinkedExecutable.returnType == null) { 1828 if (_unlinkedExecutable.returnType == null) {
1832 return null; 1829 return null;
1833 } else { 1830 } else {
1834 return _declaredReturnType ??= 1831 return _declaredReturnType ??=
1835 compilationUnit.resolveTypeRef(_unlinkedExecutable.returnType, this); 1832 compilationUnit.resolveTypeRef(this, _unlinkedExecutable.returnType);
1836 } 1833 }
1837 } 1834 }
1838 1835
1839 @override 1836 @override
1840 String get displayName { 1837 String get displayName {
1841 if (_displayName == null) { 1838 if (_displayName == null) {
1842 _displayName = _unlinkedExecutable.name; 1839 _displayName = _unlinkedExecutable.name;
1843 if (_unlinkedExecutable.kind == UnlinkedExecutableKind.setter) { 1840 if (_unlinkedExecutable.kind == UnlinkedExecutableKind.setter) {
1844 _displayName = _displayName.substring(0, _displayName.length - 1); 1841 _displayName = _displayName.substring(0, _displayName.length - 1);
1845 } 1842 }
(...skipping 26 matching lines...) Expand all
1872 return _computeDefaultReturnType(); 1869 return _computeDefaultReturnType();
1873 } 1870 }
1874 if (_inferredReturnType == null) { 1871 if (_inferredReturnType == null) {
1875 if (_unlinkedExecutable.kind == UnlinkedExecutableKind.constructor) { 1872 if (_unlinkedExecutable.kind == UnlinkedExecutableKind.constructor) {
1876 // TODO(paulberry): implement. 1873 // TODO(paulberry): implement.
1877 throw new UnimplementedError(); 1874 throw new UnimplementedError();
1878 } else if (compilationUnit.isInBuildUnit) { 1875 } else if (compilationUnit.isInBuildUnit) {
1879 _inferredReturnType = _computeDefaultReturnType(); 1876 _inferredReturnType = _computeDefaultReturnType();
1880 } else { 1877 } else {
1881 _inferredReturnType = compilationUnit.getLinkedType( 1878 _inferredReturnType = compilationUnit.getLinkedType(
1882 _unlinkedExecutable.inferredReturnTypeSlot, this); 1879 this, _unlinkedExecutable.inferredReturnTypeSlot);
1883 } 1880 }
1884 } 1881 }
1885 return _inferredReturnType; 1882 return _inferredReturnType;
1886 } 1883 }
1887 1884
1888 @override 1885 @override
1889 bool get isStatic => _unlinkedExecutable.isStatic; 1886 bool get isStatic => _unlinkedExecutable.isStatic;
1890 1887
1891 @override 1888 @override
1892 bool get isSynthetic => false; 1889 bool get isSynthetic => false;
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 2317
2321 EntityRef ref = _getNextRef(); 2318 EntityRef ref = _getNextRef();
2322 ReferenceableElementForLink refElement = unit.resolveRef(ref.reference); 2319 ReferenceableElementForLink refElement = unit.resolveRef(ref.reference);
2323 ConstructorElementForLink constructorElement = refElement.asConstructor; 2320 ConstructorElementForLink constructorElement = refElement.asConstructor;
2324 2321
2325 if (constructorElement != null) { 2322 if (constructorElement != null) {
2326 stack.add(() { 2323 stack.add(() {
2327 if (ref.typeArguments.isNotEmpty) { 2324 if (ref.typeArguments.isNotEmpty) {
2328 return constructorElement.enclosingClass.buildType((int i) { 2325 return constructorElement.enclosingClass.buildType((int i) {
2329 if (i < ref.typeArguments.length) { 2326 if (i < ref.typeArguments.length) {
2330 return unit.resolveTypeRef( 2327 return unit.resolveTypeRef(function, ref.typeArguments[i]);
2331 ref.typeArguments[i], function.typeParameterContext);
2332 } else { 2328 } else {
2333 return null; 2329 return null;
2334 } 2330 }
2335 }, const <int>[]); 2331 }, const <int>[]);
2336 } else { 2332 } else {
2337 FunctionType rawType = StaticTypeAnalyzer 2333 FunctionType rawType = StaticTypeAnalyzer
2338 .constructorToGenericFunctionType(constructorElement); 2334 .constructorToGenericFunctionType(constructorElement);
2339 FunctionType inferredType = _inferExecutableType( 2335 FunctionType inferredType = _inferExecutableType(
2340 rawType, 2336 rawType,
2341 numNamed, 2337 numNamed,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 List<String> _getNextStrings(int n) { 2517 List<String> _getNextStrings(int n) {
2522 List<String> result = new List<String>(n); 2518 List<String> result = new List<String>(n);
2523 for (int i = 0; i < n; i++) { 2519 for (int i = 0; i < n; i++) {
2524 result[i] = _getNextString(); 2520 result[i] = _getNextString();
2525 } 2521 }
2526 return result; 2522 return result;
2527 } 2523 }
2528 2524
2529 DartType _getNextTypeRef() { 2525 DartType _getNextTypeRef() {
2530 EntityRef ref = _getNextRef(); 2526 EntityRef ref = _getNextRef();
2531 return unit.resolveTypeRef(ref, function.typeParameterContext); 2527 return unit.resolveTypeRef(function, ref);
2532 } 2528 }
2533 2529
2534 List<DartType> _getTypeArguments() { 2530 List<DartType> _getTypeArguments() {
2535 int numTypeArguments = _getNextInt(); 2531 int numTypeArguments = _getNextInt();
2536 List<DartType> typeArguments = new List<DartType>(numTypeArguments); 2532 List<DartType> typeArguments = new List<DartType>(numTypeArguments);
2537 for (int i = 0; i < numTypeArguments; i++) { 2533 for (int i = 0; i < numTypeArguments; i++) {
2538 typeArguments[i] = _getNextTypeRef(); 2534 typeArguments[i] = _getNextTypeRef();
2539 } 2535 }
2540 return typeArguments; 2536 return typeArguments;
2541 } 2537 }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 return _implicitFunctionTypeIndices; 2874 return _implicitFunctionTypeIndices;
2879 } 2875 }
2880 2876
2881 @override 2877 @override
2882 DartType get returnType { 2878 DartType get returnType {
2883 if (_returnType == null) { 2879 if (_returnType == null) {
2884 if (enclosingElement._unlinkedParam.type == null) { 2880 if (enclosingElement._unlinkedParam.type == null) {
2885 _returnType = DynamicTypeImpl.instance; 2881 _returnType = DynamicTypeImpl.instance;
2886 } else { 2882 } else {
2887 _returnType = enclosingElement.compilationUnit.resolveTypeRef( 2883 _returnType = enclosingElement.compilationUnit.resolveTypeRef(
2888 enclosingElement._unlinkedParam.type, typeParameterContext); 2884 enclosingElement, enclosingElement._unlinkedParam.type);
2889 } 2885 }
2890 } 2886 }
2891 return _returnType; 2887 return _returnType;
2892 } 2888 }
2893 2889
2894 @override 2890 @override
2895 List<TypeParameterElement> get typeParameters => const []; 2891 List<TypeParameterElement> get typeParameters => const [];
2896 2892
2897 @override 2893 @override
2898 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 2894 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 bool get isSynthetic => false; 3189 bool get isSynthetic => false;
3194 3190
3195 @override 3191 @override
3196 LibraryElementForLink get library => enclosingElement.library; 3192 LibraryElementForLink get library => enclosingElement.library;
3197 3193
3198 @override 3194 @override
3199 String get name => _unlinkedTypedef.name; 3195 String get name => _unlinkedTypedef.name;
3200 3196
3201 @override 3197 @override
3202 DartType get returnType => _returnType ??= 3198 DartType get returnType => _returnType ??=
3203 enclosingElement.resolveTypeRef(_unlinkedTypedef.returnType, this); 3199 enclosingElement.resolveTypeRef(this, _unlinkedTypedef.returnType);
3204 3200
3205 @override 3201 @override
3206 TypeParameterizedElementMixin get typeParameterContext => this; 3202 TypeParameterizedElementMixin get typeParameterContext => this;
3207 3203
3208 @override 3204 @override
3209 List<UnlinkedParam> get unlinkedParameters => _unlinkedTypedef.parameters; 3205 List<UnlinkedParam> get unlinkedParameters => _unlinkedTypedef.parameters;
3210 3206
3211 @override 3207 @override
3212 List<UnlinkedTypeParam> get unlinkedTypeParams => 3208 List<UnlinkedTypeParam> get unlinkedTypeParams =>
3213 _unlinkedTypedef.typeParameters; 3209 _unlinkedTypedef.typeParameters;
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
4186 if (_inferredType != null) { 4182 if (_inferredType != null) {
4187 return _inferredType; 4183 return _inferredType;
4188 } else if (_declaredType == null) { 4184 } else if (_declaredType == null) {
4189 if (_unlinkedParam.isFunctionTyped) { 4185 if (_unlinkedParam.isFunctionTyped) {
4190 _declaredType = new FunctionTypeImpl( 4186 _declaredType = new FunctionTypeImpl(
4191 new FunctionElementForLink_FunctionTypedParam( 4187 new FunctionElementForLink_FunctionTypedParam(
4192 this, _typeParameterContext, _unlinkedParam.parameters)); 4188 this, _typeParameterContext, _unlinkedParam.parameters));
4193 } else if (_unlinkedParam.type == null) { 4189 } else if (_unlinkedParam.type == null) {
4194 if (!compilationUnit.isInBuildUnit) { 4190 if (!compilationUnit.isInBuildUnit) {
4195 _inferredType = compilationUnit.getLinkedType( 4191 _inferredType = compilationUnit.getLinkedType(
4196 _unlinkedParam.inferredTypeSlot, _typeParameterContext); 4192 this, _unlinkedParam.inferredTypeSlot);
4197 return _inferredType; 4193 return _inferredType;
4198 } else { 4194 } else {
4199 _declaredType = DynamicTypeImpl.instance; 4195 _declaredType = DynamicTypeImpl.instance;
4200 } 4196 }
4201 } else { 4197 } else {
4202 _declaredType = compilationUnit.resolveTypeRef( 4198 _declaredType =
4203 _unlinkedParam.type, _typeParameterContext); 4199 compilationUnit.resolveTypeRef(this, _unlinkedParam.type);
4204 } 4200 }
4205 } 4201 }
4206 return _declaredType; 4202 return _declaredType;
4207 } 4203 }
4208 4204
4209 @override 4205 @override
4210 void set type(DartType inferredType) { 4206 void set type(DartType inferredType) {
4211 assert(_inferredType == null); 4207 assert(_inferredType == null);
4212 _inferredType = inferredType; 4208 _inferredType = inferredType;
4213 } 4209 }
4214 4210
4211 @override
4212 TypeParameterizedElementMixin get typeParameterContext {
4213 return _typeParameterContext;
4214 }
4215
4215 /** 4216 /**
4216 * Store the results of type inference for this parameter in 4217 * Store the results of type inference for this parameter in
4217 * [compilationUnit]. 4218 * [compilationUnit].
4218 */ 4219 */
4219 void link(CompilationUnitElementInBuildUnit compilationUnit) { 4220 void link(CompilationUnitElementInBuildUnit compilationUnit) {
4220 compilationUnit._storeLinkedType( 4221 compilationUnit._storeLinkedType(
4221 _unlinkedParam.inferredTypeSlot, _inferredType, _typeParameterContext); 4222 _unlinkedParam.inferredTypeSlot, _inferredType, _typeParameterContext);
4222 compilationUnit._storeLinkedTypeError( 4223 compilationUnit._storeLinkedTypeError(
4223 _unlinkedParam.inferredTypeSlot, _inferenceError); 4224 _unlinkedParam.inferredTypeSlot, _inferenceError);
4224 if (inheritsCovariant) { 4225 if (inheritsCovariant) {
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
5179 } 5180 }
5180 5181
5181 /** 5182 /**
5182 * If the variable has an explicitly declared return type, return it. 5183 * If the variable has an explicitly declared return type, return it.
5183 * Otherwise return `null`. 5184 * Otherwise return `null`.
5184 */ 5185 */
5185 DartType get declaredType { 5186 DartType get declaredType {
5186 if (unlinkedVariable.type == null) { 5187 if (unlinkedVariable.type == null) {
5187 return null; 5188 return null;
5188 } else { 5189 } else {
5189 return _declaredType ??= compilationUnit.resolveTypeRef( 5190 return _declaredType ??=
5190 unlinkedVariable.type, _typeParameterContext); 5191 compilationUnit.resolveTypeRef(this, unlinkedVariable.type);
5191 } 5192 }
5192 } 5193 }
5193 5194
5194 @override 5195 @override
5195 String get displayName => unlinkedVariable.name; 5196 String get displayName => unlinkedVariable.name;
5196 5197
5197 @override 5198 @override
5198 PropertyAccessorElementForLink_Variable get getter => 5199 PropertyAccessorElementForLink_Variable get getter =>
5199 _getter ??= new PropertyAccessorElementForLink_Variable(this, false); 5200 _getter ??= new PropertyAccessorElementForLink_Variable(this, false);
5200 5201
(...skipping 18 matching lines...) Expand all
5219 try { 5220 try {
5220 new TypeInferenceDependencyWalker().walk(_typeInferenceNode); 5221 new TypeInferenceDependencyWalker().walk(_typeInferenceNode);
5221 assert(_inferredType != null); 5222 assert(_inferredType != null);
5222 } finally { 5223 } finally {
5223 Linker._initializerTypeInferenceCycle = null; 5224 Linker._initializerTypeInferenceCycle = null;
5224 } 5225 }
5225 } else if (compilationUnit.isInBuildUnit) { 5226 } else if (compilationUnit.isInBuildUnit) {
5226 _inferredType = DynamicTypeImpl.instance; 5227 _inferredType = DynamicTypeImpl.instance;
5227 } else { 5228 } else {
5228 _inferredType = compilationUnit.getLinkedType( 5229 _inferredType = compilationUnit.getLinkedType(
5229 unlinkedVariable.inferredTypeSlot, _typeParameterContext); 5230 this, unlinkedVariable.inferredTypeSlot);
5230 } 5231 }
5231 } 5232 }
5232 return _inferredType; 5233 return _inferredType;
5233 } 5234 }
5234 5235
5235 @override 5236 @override
5236 FunctionElementForLink_Initializer get initializer { 5237 FunctionElementForLink_Initializer get initializer {
5237 if (unlinkedVariable.initializer == null) { 5238 if (unlinkedVariable.initializer == null) {
5238 return null; 5239 return null;
5239 } else { 5240 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5278 } 5279 }
5279 5280
5280 @override 5281 @override
5281 DartType get type => declaredType ?? inferredType; 5282 DartType get type => declaredType ?? inferredType;
5282 5283
5283 @override 5284 @override
5284 void set type(DartType newType) { 5285 void set type(DartType newType) {
5285 // TODO(paulberry): store inferred type. 5286 // TODO(paulberry): store inferred type.
5286 } 5287 }
5287 5288
5289 @override
5290 TypeParameterizedElementMixin get typeParameterContext {
5291 return _typeParameterContext;
5292 }
5293
5288 /** 5294 /**
5289 * The context in which type parameters should be interpreted, or `null` if 5295 * The context in which type parameters should be interpreted, or `null` if
5290 * there are no type parameters in scope. 5296 * there are no type parameters in scope.
5291 */ 5297 */
5292 TypeParameterizedElementMixin get _typeParameterContext; 5298 TypeParameterizedElementMixin get _typeParameterContext;
5293 5299
5294 @override 5300 @override
5295 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 5301 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
5296 5302
5297 @override 5303 @override
5298 String toString() => '$enclosingElement.$name'; 5304 String toString() => '$enclosingElement.$name';
5299 } 5305 }
5300 5306
5301 /** 5307 /**
5302 * This exception is thrown when [ExprTypeComputer] cannot inference the type. 5308 * This exception is thrown when [ExprTypeComputer] cannot inference the type.
5303 */ 5309 */
5304 class _InferenceFailedError { 5310 class _InferenceFailedError {
5305 final String message; 5311 final String message;
5306 5312
5307 _InferenceFailedError(this.message); 5313 _InferenceFailedError(this.message);
5308 } 5314 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698