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

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

Issue 2835903003: Issue 29388. Resynthesize non-generic types for ReferenceInfo lazily. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 * The element referred to by this reference, or `null` if there is no 1214 * The element referred to by this reference, or `null` if there is no
1215 * associated element (e.g. because it is a reference to an undefined 1215 * associated element (e.g. because it is a reference to an undefined
1216 * entity). 1216 * entity).
1217 */ 1217 */
1218 final Element element; 1218 final Element element;
1219 1219
1220 /** 1220 /**
1221 * If this reference refers to a non-generic type, the type it refers to. 1221 * If this reference refers to a non-generic type, the type it refers to.
1222 * Otherwise `null`. 1222 * Otherwise `null`.
1223 */ 1223 */
1224 DartType type; 1224 DartType _type;
1225 1225
1226 /** 1226 /**
1227 * The number of type parameters accepted by the entity referred to by this 1227 * The number of type parameters accepted by the entity referred to by this
1228 * reference, or zero if it doesn't accept any type parameters. 1228 * reference, or zero if it doesn't accept any type parameters.
1229 */ 1229 */
1230 final int numTypeParameters; 1230 final int numTypeParameters;
1231 1231
1232 /** 1232 /**
1233 * Create a new [_ReferenceInfo] object referring to an element called [name] 1233 * Create a new [_ReferenceInfo] object referring to an element called [name]
1234 * via the element handle [element], and having [numTypeParameters] type 1234 * via the element handle [element], and having [numTypeParameters] type
1235 * parameters. 1235 * parameters.
1236 * 1236 *
1237 * For the special types `dynamic` and `void`, [specialType] should point to 1237 * For the special types `dynamic` and `void`, [specialType] should point to
1238 * the type itself. Otherwise, pass `null` and the type will be computed 1238 * the type itself. Otherwise, pass `null` and the type will be computed
1239 * when appropriate. 1239 * when appropriate.
1240 */ 1240 */
1241 _ReferenceInfo( 1241 _ReferenceInfo(
1242 this.libraryResynthesizer, 1242 this.libraryResynthesizer,
1243 this.enclosing, 1243 this.enclosing,
1244 this.name, 1244 this.name,
1245 this.isDeclarableType, 1245 this.isDeclarableType,
1246 this.element, 1246 this.element,
1247 DartType specialType, 1247 DartType specialType,
1248 this.numTypeParameters) { 1248 this.numTypeParameters) {
1249 if (specialType != null) { 1249 if (specialType != null) {
1250 type = specialType; 1250 _type = specialType;
1251 } else {
1252 type = _buildType(true, 0, (_) => DynamicTypeImpl.instance, const []);
1253 } 1251 }
1254 } 1252 }
1255 1253
1256 /** 1254 /**
1255 * If this reference refers to a non-generic type, the type it refers to.
1256 * Otherwise `null`.
1257 */
1258 DartType get type {
1259 if (_type == null) {
1260 _type = _buildType(true, 0, (_) => DynamicTypeImpl.instance, const []);
1261 }
1262 return _type;
1263 }
1264
1265 /**
1257 * Build a [DartType] corresponding to the result of applying some type 1266 * Build a [DartType] corresponding to the result of applying some type
1258 * arguments to the entity referred to by this [_ReferenceInfo]. The type 1267 * arguments to the entity referred to by this [_ReferenceInfo]. The type
1259 * arguments are retrieved by calling [getTypeArgument]. 1268 * arguments are retrieved by calling [getTypeArgument].
1260 * 1269 *
1261 * If [implicitFunctionTypeIndices] is not empty, a [DartType] should be 1270 * If [implicitFunctionTypeIndices] is not empty, a [DartType] should be
1262 * created which refers to a function type implicitly defined by one of the 1271 * created which refers to a function type implicitly defined by one of the
1263 * element's parameters. [implicitFunctionTypeIndices] is interpreted as in 1272 * element's parameters. [implicitFunctionTypeIndices] is interpreted as in
1264 * [EntityRef.implicitFunctionTypeIndices]. 1273 * [EntityRef.implicitFunctionTypeIndices].
1265 * 1274 *
1266 * If the entity referred to by this [_ReferenceInfo] is not a type, `null` 1275 * If the entity referred to by this [_ReferenceInfo] is not a type, `null`
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 List<DartType> argumentTypes = 1340 List<DartType> argumentTypes =
1332 new List.generate(numTypeArguments, getTypeArgument); 1341 new List.generate(numTypeArguments, getTypeArgument);
1333 return actualElement.typeAfterSubstitution(argumentTypes); 1342 return actualElement.typeAfterSubstitution(argumentTypes);
1334 } else if (element is FunctionTypedElement) { 1343 } else if (element is FunctionTypedElement) {
1335 if (element is FunctionTypeAliasElementHandle) { 1344 if (element is FunctionTypeAliasElementHandle) {
1336 List<DartType> typeArguments; 1345 List<DartType> typeArguments;
1337 if (numTypeArguments == numTypeParameters) { 1346 if (numTypeArguments == numTypeParameters) {
1338 typeArguments = 1347 typeArguments =
1339 _buildTypeArguments(numTypeArguments, getTypeArgument); 1348 _buildTypeArguments(numTypeArguments, getTypeArgument);
1340 } else if (libraryResynthesizer.summaryResynthesizer.strongMode && 1349 } else if (libraryResynthesizer.summaryResynthesizer.strongMode &&
1341 instantiateToBoundsAllowed) { 1350 instantiateToBoundsAllowed
1351 // && !_isBeingInstantiatedToBounds
Brian Wilkerson 2017/04/24 18:35:47 Should we remove the commented out code?
1352 ) {
1353 // _isBeingInstantiatedToBounds = true;
1354 // try {
1342 FunctionType instantiatedToBounds = libraryResynthesizer 1355 FunctionType instantiatedToBounds = libraryResynthesizer
1343 .summaryResynthesizer.context.typeSystem 1356 .summaryResynthesizer.context.typeSystem
1344 .instantiateToBounds(element.type) as FunctionType; 1357 .instantiateToBounds(element.type) as FunctionType;
1345 typeArguments = instantiatedToBounds.typeArguments; 1358 typeArguments = instantiatedToBounds.typeArguments;
1359 // } finally {
1360 // _isBeingInstantiatedToBounds = false;
1361 // }
1346 } else { 1362 } else {
1347 typeArguments = new List<DartType>.filled( 1363 typeArguments = new List<DartType>.filled(
1348 numTypeParameters, DynamicTypeImpl.instance); 1364 numTypeParameters, DynamicTypeImpl.instance);
1349 } 1365 }
1350 return new FunctionTypeImpl.elementWithNameAndArgs( 1366 return new FunctionTypeImpl.elementWithNameAndArgs(
1351 element, name, typeArguments, numTypeParameters != 0); 1367 element, name, typeArguments, numTypeParameters != 0);
1352 } else { 1368 } else {
1353 FunctionTypedElementComputer computer; 1369 FunctionTypedElementComputer computer;
1354 if (implicitFunctionTypeIndices.isNotEmpty) { 1370 if (implicitFunctionTypeIndices.isNotEmpty) {
1355 numTypeArguments = numTypeParameters; 1371 numTypeArguments = numTypeParameters;
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 static String _getElementIdentifier(String name, ReferenceKind kind) { 2000 static String _getElementIdentifier(String name, ReferenceKind kind) {
1985 if (kind == ReferenceKind.topLevelPropertyAccessor || 2001 if (kind == ReferenceKind.topLevelPropertyAccessor ||
1986 kind == ReferenceKind.propertyAccessor) { 2002 kind == ReferenceKind.propertyAccessor) {
1987 if (!name.endsWith('=')) { 2003 if (!name.endsWith('=')) {
1988 return name + '?'; 2004 return name + '?';
1989 } 2005 }
1990 } 2006 }
1991 return name; 2007 return name;
1992 } 2008 }
1993 } 2009 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698