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

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

Issue 2808093004: Fix use of generic function type aliases for fields (issue 29237) (Closed)
Patch Set: restore test 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) 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...) Expand 10 before | Expand all | Expand 10 after
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) {
scheglov 2017/04/10 21:37:16 Per offline discussion, this is OK to close the is
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...) Expand 10 before | Expand all | Expand 10 after
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
scheglov 2017/04/10 21:37:16 Can we put FunctionTypeAliasElementHandle into a s
1853 is GenericTypeAliasElement) {
1854 element = new GenericTypeAliasElementHandle(
scheglov 2017/04/10 21:37:17 It's a bit scary that we request the actual elemen
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...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698