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 summary_resynthesizer; | 5 library summary_resynthesizer; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
(...skipping 1238 matching lines...) Loading... |
1249 * If [implicitFunctionTypeIndices] is not empty, a [DartType] should be | 1249 * If [implicitFunctionTypeIndices] is not empty, a [DartType] should be |
1250 * created which refers to a function type implicitly defined by one of the | 1250 * created which refers to a function type implicitly defined by one of the |
1251 * element's parameters. [implicitFunctionTypeIndices] is interpreted as in | 1251 * element's parameters. [implicitFunctionTypeIndices] is interpreted as in |
1252 * [EntityRef.implicitFunctionTypeIndices]. | 1252 * [EntityRef.implicitFunctionTypeIndices]. |
1253 * | 1253 * |
1254 * If the entity referred to by this [_ReferenceInfo] is not a type, `null` | 1254 * If the entity referred to by this [_ReferenceInfo] is not a type, `null` |
1255 * is returned. | 1255 * is returned. |
1256 */ | 1256 */ |
1257 DartType buildType(bool instantiateToBoundsAllowed, int numTypeArguments, | 1257 DartType buildType(bool instantiateToBoundsAllowed, int numTypeArguments, |
1258 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { | 1258 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { |
1259 DartType result = | 1259 DartType result; |
1260 (numTypeParameters == 0 && implicitFunctionTypeIndices.isEmpty) | 1260 if (numTypeParameters == 0 && implicitFunctionTypeIndices.isEmpty) { |
1261 ? type | 1261 if (element is GenericTypeAliasElementHandle) { |
1262 : _buildType(instantiateToBoundsAllowed, numTypeArguments, | 1262 List<DartType> argumentTypes = <DartType>[]; |
1263 getTypeArgument, implicitFunctionTypeIndices); | 1263 for (int i = 0; i < numTypeArguments; i++) { |
| 1264 argumentTypes.add(getTypeArgument(i)); |
| 1265 } |
| 1266 GenericTypeAliasElementImpl actualElement = |
| 1267 (element as GenericTypeAliasElementHandle).actualElement; |
| 1268 result = actualElement.typeAfterSubstitution(argumentTypes); |
| 1269 } else { |
| 1270 result = type; |
| 1271 } |
| 1272 } else { |
| 1273 result = _buildType(instantiateToBoundsAllowed, numTypeArguments, |
| 1274 getTypeArgument, implicitFunctionTypeIndices); |
| 1275 } |
1264 if (result == null) { | 1276 if (result == null) { |
1265 return DynamicTypeImpl.instance; | 1277 return DynamicTypeImpl.instance; |
1266 } | 1278 } |
1267 return result; | 1279 return result; |
1268 } | 1280 } |
1269 | 1281 |
1270 /** | 1282 /** |
1271 * If this reference refers to a type, build a [DartType]. Otherwise return | 1283 * If this reference refers to a type, build a [DartType]. Otherwise return |
1272 * `null`. If [numTypeArguments] is the same as the [numTypeParameters], | 1284 * `null`. If [numTypeArguments] is the same as the [numTypeParameters], |
1273 * the type is instantiated with type arguments returned by [getTypeArgument], | 1285 * the type is instantiated with type arguments returned by [getTypeArgument], |
(...skipping 556 matching lines...) Loading... |
1830 assert(location.components.length == 3); | 1842 assert(location.components.length == 3); |
1831 element = new FunctionElementHandle(summaryResynthesizer, location); | 1843 element = new FunctionElementHandle(summaryResynthesizer, location); |
1832 break; | 1844 break; |
1833 case ReferenceKind.topLevelPropertyAccessor: | 1845 case ReferenceKind.topLevelPropertyAccessor: |
1834 element = new PropertyAccessorElementHandle( | 1846 element = new PropertyAccessorElementHandle( |
1835 summaryResynthesizer, location); | 1847 summaryResynthesizer, location); |
1836 break; | 1848 break; |
1837 case ReferenceKind.typedef: | 1849 case ReferenceKind.typedef: |
1838 element = new FunctionTypeAliasElementHandle( | 1850 element = new FunctionTypeAliasElementHandle( |
1839 summaryResynthesizer, location); | 1851 summaryResynthesizer, location); |
| 1852 if ((element as ElementHandle).actualElement |
| 1853 is GenericTypeAliasElement) { |
| 1854 element = new GenericTypeAliasElementHandle( |
| 1855 summaryResynthesizer, location); |
| 1856 } |
1840 isDeclarableType = true; | 1857 isDeclarableType = true; |
1841 break; | 1858 break; |
1842 case ReferenceKind.variable: | 1859 case ReferenceKind.variable: |
1843 Element enclosingElement = enclosingInfo.element; | 1860 Element enclosingElement = enclosingInfo.element; |
1844 if (enclosingElement is ExecutableElement) { | 1861 if (enclosingElement is ExecutableElement) { |
1845 element = new _DeferredLocalVariableElement( | 1862 element = new _DeferredLocalVariableElement( |
1846 enclosingElement, linkedReference.localIndex); | 1863 enclosingElement, linkedReference.localIndex); |
1847 } else { | 1864 } else { |
1848 throw new StateError('Unexpected element enclosing variable:' | 1865 throw new StateError('Unexpected element enclosing variable:' |
1849 ' ${enclosingElement.runtimeType}'); | 1866 ' ${enclosingElement.runtimeType}'); |
(...skipping 112 matching lines...) Loading... |
1962 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1979 static String _getElementIdentifier(String name, ReferenceKind kind) { |
1963 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1980 if (kind == ReferenceKind.topLevelPropertyAccessor || |
1964 kind == ReferenceKind.propertyAccessor) { | 1981 kind == ReferenceKind.propertyAccessor) { |
1965 if (!name.endsWith('=')) { | 1982 if (!name.endsWith('=')) { |
1966 return name + '?'; | 1983 return name + '?'; |
1967 } | 1984 } |
1968 } | 1985 } |
1969 return name; | 1986 return name; |
1970 } | 1987 } |
1971 } | 1988 } |
OLD | NEW |