| 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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 } | 931 } |
| 932 ElementLocationImpl location = new ElementLocationImpl.con3( | 932 ElementLocationImpl location = new ElementLocationImpl.con3( |
| 933 getReferencedLocationComponents( | 933 getReferencedLocationComponents( |
| 934 exportName.dependency, exportName.unit, name)); | 934 exportName.dependency, exportName.unit, name)); |
| 935 switch (exportName.kind) { | 935 switch (exportName.kind) { |
| 936 case ReferenceKind.classOrEnum: | 936 case ReferenceKind.classOrEnum: |
| 937 return new ClassElementHandle(summaryResynthesizer, location); | 937 return new ClassElementHandle(summaryResynthesizer, location); |
| 938 case ReferenceKind.typedef: | 938 case ReferenceKind.typedef: |
| 939 return new FunctionTypeAliasElementHandle( | 939 return new FunctionTypeAliasElementHandle( |
| 940 summaryResynthesizer, location); | 940 summaryResynthesizer, location); |
| 941 case ReferenceKind.genericFunctionTypedef: |
| 942 return new GenericTypeAliasElementHandle( |
| 943 summaryResynthesizer, location); |
| 941 case ReferenceKind.topLevelFunction: | 944 case ReferenceKind.topLevelFunction: |
| 942 return new FunctionElementHandle(summaryResynthesizer, location); | 945 return new FunctionElementHandle(summaryResynthesizer, location); |
| 943 case ReferenceKind.topLevelPropertyAccessor: | 946 case ReferenceKind.topLevelPropertyAccessor: |
| 944 return new PropertyAccessorElementHandle( | 947 return new PropertyAccessorElementHandle( |
| 945 summaryResynthesizer, location); | 948 summaryResynthesizer, location); |
| 946 case ReferenceKind.constructor: | 949 case ReferenceKind.constructor: |
| 947 case ReferenceKind.function: | 950 case ReferenceKind.function: |
| 948 case ReferenceKind.propertyAccessor: | 951 case ReferenceKind.propertyAccessor: |
| 949 case ReferenceKind.method: | 952 case ReferenceKind.method: |
| 950 case ReferenceKind.prefix: | 953 case ReferenceKind.prefix: |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 } | 1310 } |
| 1308 return typeArguments; | 1311 return typeArguments; |
| 1309 }); | 1312 }); |
| 1310 // Mark the type as having implicit type arguments, so that we don't | 1313 // Mark the type as having implicit type arguments, so that we don't |
| 1311 // attempt to request them during constant expression resynthesizing. | 1314 // attempt to request them during constant expression resynthesizing. |
| 1312 if (typeArguments == null) { | 1315 if (typeArguments == null) { |
| 1313 libraryResynthesizer.typesWithImplicitTypeArguments.add(type); | 1316 libraryResynthesizer.typesWithImplicitTypeArguments.add(type); |
| 1314 } | 1317 } |
| 1315 // Done. | 1318 // Done. |
| 1316 return type; | 1319 return type; |
| 1320 } else if (element is GenericTypeAliasElementHandle) { |
| 1321 GenericTypeAliasElementImpl actualElement = element.actualElement; |
| 1322 List<DartType> argumentTypes = |
| 1323 new List.generate(numTypeArguments, getTypeArgument); |
| 1324 return actualElement.typeAfterSubstitution(argumentTypes); |
| 1317 } else if (element is FunctionTypedElement) { | 1325 } else if (element is FunctionTypedElement) { |
| 1318 if (element is FunctionTypeAliasElementHandle) { | 1326 if (element is FunctionTypeAliasElementHandle) { |
| 1319 List<DartType> typeArguments; | 1327 List<DartType> typeArguments; |
| 1320 if (numTypeArguments == numTypeParameters) { | 1328 if (numTypeArguments == numTypeParameters) { |
| 1321 typeArguments = | 1329 typeArguments = |
| 1322 _buildTypeArguments(numTypeArguments, getTypeArgument); | 1330 _buildTypeArguments(numTypeArguments, getTypeArgument); |
| 1323 } else if (libraryResynthesizer.summaryResynthesizer.strongMode && | 1331 } else if (libraryResynthesizer.summaryResynthesizer.strongMode && |
| 1324 instantiateToBoundsAllowed) { | 1332 instantiateToBoundsAllowed) { |
| 1325 FunctionType instantiatedToBounds = libraryResynthesizer | 1333 FunctionType instantiatedToBounds = libraryResynthesizer |
| 1326 .summaryResynthesizer.context.typeSystem | 1334 .summaryResynthesizer.context.typeSystem |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 break; | 1840 break; |
| 1833 case ReferenceKind.topLevelPropertyAccessor: | 1841 case ReferenceKind.topLevelPropertyAccessor: |
| 1834 element = new PropertyAccessorElementHandle( | 1842 element = new PropertyAccessorElementHandle( |
| 1835 summaryResynthesizer, location); | 1843 summaryResynthesizer, location); |
| 1836 break; | 1844 break; |
| 1837 case ReferenceKind.typedef: | 1845 case ReferenceKind.typedef: |
| 1838 element = new FunctionTypeAliasElementHandle( | 1846 element = new FunctionTypeAliasElementHandle( |
| 1839 summaryResynthesizer, location); | 1847 summaryResynthesizer, location); |
| 1840 isDeclarableType = true; | 1848 isDeclarableType = true; |
| 1841 break; | 1849 break; |
| 1850 case ReferenceKind.genericFunctionTypedef: |
| 1851 element = new GenericTypeAliasElementHandle( |
| 1852 summaryResynthesizer, location); |
| 1853 isDeclarableType = true; |
| 1854 break; |
| 1842 case ReferenceKind.variable: | 1855 case ReferenceKind.variable: |
| 1843 Element enclosingElement = enclosingInfo.element; | 1856 Element enclosingElement = enclosingInfo.element; |
| 1844 if (enclosingElement is ExecutableElement) { | 1857 if (enclosingElement is ExecutableElement) { |
| 1845 element = new _DeferredLocalVariableElement( | 1858 element = new _DeferredLocalVariableElement( |
| 1846 enclosingElement, linkedReference.localIndex); | 1859 enclosingElement, linkedReference.localIndex); |
| 1847 } else { | 1860 } else { |
| 1848 throw new StateError('Unexpected element enclosing variable:' | 1861 throw new StateError('Unexpected element enclosing variable:' |
| 1849 ' ${enclosingElement.runtimeType}'); | 1862 ' ${enclosingElement.runtimeType}'); |
| 1850 } | 1863 } |
| 1851 break; | 1864 break; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1962 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1975 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 1963 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1976 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 1964 kind == ReferenceKind.propertyAccessor) { | 1977 kind == ReferenceKind.propertyAccessor) { |
| 1965 if (!name.endsWith('=')) { | 1978 if (!name.endsWith('=')) { |
| 1966 return name + '?'; | 1979 return name + '?'; |
| 1967 } | 1980 } |
| 1968 } | 1981 } |
| 1969 return name; | 1982 return name; |
| 1970 } | 1983 } |
| 1971 } | 1984 } |
| OLD | NEW |